Odd rake db: migration exit

Why rake db:migrate launches Execute db:schema:dump my output is all messed up (showing SQL).

It looks like:

  ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations" (3.7ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete FROM pg_constraint c JOIN pg_class t1 ON c.conrelid = t1.oid JOIN pg_class t2 ON c.confrelid = t2.oid JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid JOIN pg_namespace t3 ON c.connamespace = t3.oid WHERE c.contype = 'f' AND t1.relname = 'accounts' AND t3.nspname = ANY (current_schemas(false)) ORDER BY c.conname (3.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete FROM pg_constraint c JOIN pg_class t1 ON c.conrelid = t1.oid JOIN pg_class t2 ON c.confrelid = t2.oid JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid JOIN pg_namespace t3 ON c.connamespace = t3.oid WHERE c.contype = 'f' AND t1.relname = 'deliveries' AND t3.nspname = ANY (current_schemas(false)) ORDER BY c.conname (3.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete FROM pg_constraint c JOIN pg_class t1 ON c.conrelid = t1.oid JOIN pg_class t2 ON c.confrelid = t2.oid JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid JOIN pg_namespace t3 ON c.connamespace = t3.oid WHERE c.contype = 'f' AND t1.relname = 'posts' AND t3.nspname = ANY (current_schemas(false)) ORDER BY c.conname 

Tracing shows this:

 ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Invoke db:load_config (first_time) ** Execute db:load_config ** Execute db:migrate ** Invoke db:_dump (first_time) ** Execute db:_dump ** Invoke db:schema:dump (first_time) ** Invoke environment ** Invoke db:load_config ** Execute db:schema:dump 

It started after upgrading rails 4.1.6 to rails 4.2.0.

Why is this happening?

+5
source share
3 answers

The reason I got this strange cryptic SQL'ish output is because I had the hero Heroku rails_12factor in my gemfile and was not grouped into: production.

The solution was to execute:

 group :production do gem 'rails_12factor' end 

and run bundle

+3
source

I had the same problem after upgrading to Rails 4.2.1, which prevented me from deploying through migration through Codeship, expecting a special result from rake db:migrate to consider a successful click.

Setting config.log_level = :info in config/environments/production.rb fixed the problem for me, apparently because the log level was too verbose at the :debug level.

+1
source

This discussion allowed me the "odd" conclusion:
Just set dump_schema_after_migration to false in your environment settings as follows:

/config/environments/development.rb

 Application.configure do ... dump_schema_after_migration = false ... end 

EDIT
This is not what you want to do in most cases, because you need to have schema.rb in your version control.

0
source

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


All Articles