Why is the first deployment using Capistrano Run db: migrate?

I use Capistrano for deployment for production for the first time and I get an error message when I start

cap production deploy

Mistake:

** Invoke deploy:migrate (first_time)
** Invoke deploy:set_rails_env
** Execute deploy:migrate
DEBUG [048f89c6] Running /usr/bin/env if test ! -d /home/deployer_user/apps/ap_production/releases/20140209005208; then echo "Directory does not exist '/home/deployer_user/apps/ap_production/releases/20140209005208'" 1>&2; false; fi on eslope.net
DEBUG [048f89c6] Command: if test ! -d /home/deployer_user/apps/ap_production/releases/20140209005208; then echo "Directory does not exist '/home/deployer_user/apps/ap_production/releases/20140209005208'" 1>&2; false; fi
DEBUG [048f89c6] Finished in 0.160 seconds with exit status 0 (successful).
INFO [52f75214] Running ~/.rbenv/bin/rbenv exec bundle exec rake db:migrate on eserver.net
DEBUG [52f75214] Command: cd /home/deployer_user/apps/ap_production/releases/20140209005208 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.0 RAILS_ENV=production ~/.rbenv/bin/rbenv exec bundle exec rake db:migrate )
DEBUG [52f75214]    rake aborted!
DEBUG [52f75214]    An error has occurred, this and all later migrations canceled:
DEBUG [52f75214]    
DEBUG [52f75214]    PG::UndefinedTable: ERROR:  relation "client_infos" does not exist
DEBUG [52f75214]    : ALTER TABLE "client_infos" RENAME TO "clients

The mistake really makes sense. Link table does not exist. I don’t understand why migration works at all? Why the database is not created from the schema at the first start. I accidentally deleted a file that says which migrations were performed? Either just deleting it, or ".gitignoring"?

, , (rake db: create or similar), , Capistrano v3 , , ? , , , , , ... ( , , , ?) .

+4
4

db: migrate . , , . , :

  • rake db:create

2 Migrations

 `rake db:migrate`

, .

( ), ( ..), , db:schema:load

.

rake db: :

3.1.3?

0

, , , lmars, . - :

RAILS_ENV=production bundle exec rake db:drop
RAILS_ENV=production bundle exec rake db:schema:create
RAILS_ENV=production bundle exec rake db:schema:load

, , , .

, , ... .

+1

database.yml, , . , Postgresql , ( ) . , "deployer" - , , .

0

, client_infos clients, client_infos , , client_infos?

, client_infos, ? ? .

client_infos, schema_migrations ( Rails , ) - . , , , .

, ?

If spelled correctly, migration should have the same effect as loading the schema, they will just do it gradually. Of course, you can manually load the schema if you want, but Capistrano will not do this, since it is a rather dangerous task (you probably will never want to recreate your production database)

0
source

Source: https://habr.com/ru/post/1525992/


All Articles