Question: Capistrano SQLite3::SQLException: no such table: users

Question

Capistrano SQLite3::SQLException: no such table: users

Answers 2
Added at 2016-12-13 12:12
Tags
Question

Ubuntu 16, ruby, 3.2, framework Sinatra.

After cap deploy not running migration on production.

I deploy with command cap deploy production my project to remote server.

In app.rb connection setting for db:

#app.rb

require "sinatra"
require "pry"
require "sinatra/activerecord"
require 'sinatra/flash'
require 'sinatra/base'
require "./models/user"
require "./models/game_counter"
require "./models/stash"
require "json"
require "pony"
require 'logger'


enable :static
enable :sessions


set :public_folder, File.dirname(__FILE__) + '/assets'

set :database, { adapter: "sqlite3", database: "sudoku_database.sqlite3" }

Gemfile

gem "rake"
gem "heroku"
gem "sinatra"
gem "sinatra-activerecord"
gem "sinatra-flash"
gem "sqlite3"
gem "pg"
gem "bcrypt"
gem "pry"
gem "pony"
gem "capistrano", '~> 3.1.0'
gem "capistrano-bundler", '~> 1.1.2'
gem 'passenger'

I installed sqllite on remote server.

Installed and customized capistrano.

config/deploy.rb

lock '3.4.0'

set :application, 'projectname'
set :repo_url, 'git@github.com:user/projectname.git'

set :deploy_to, '/home/deploy/projectname'

set :linked_dirs, %w{ log }


namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :publishing, 'deploy:restart'
  after :finishing, 'deploy:cleanup'
end

config/production.rb

set :stage, :production

server '188.177.76.190', user: 'deploy', roles: %w{web app db}, port: 2503

When i run web site in browser, in logs nginx display error:

2016-12-13 10:40:58 - ActiveRecord::StatementInvalid - SQLite3::SQLException: no such table: users: SELECT "users".* FROM "user 

Help me please, can`t undestand why dont running migration for database on production and how me solve this problem?

Answers to

Capistrano SQLite3::SQLException: no such table: users

nr: #1 dodano: 2016-12-13 12:12

Go to your application on live and migrate database on server in production environment.

rake db:migrate RAILS_ENV=production
nr: #2 dodano: 2016-12-13 12:12

There is no capistrano task for migration. You should add it in your deploy config. Like this (it depends on your config):

task :migrate do
  on roles(:app) do
    within release_path do
      with rack_env: fetch(:rack_env) do
        execute :rake, "db:migrate"
      end
    end
  end
end

after 'deploy', 'migrate'
Source Show
◀ Wstecz