【发布时间】:2015-03-10 03:44:53
【问题描述】:
为什么rake db:migrate 运行Execute db:schema:dump 我的输出都搞砸了(显示SQL)。
看起来像这样:
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
Trace 显示:
** 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
这是在将 rails 4.1.6 升级到 rails 4.2.0 之后开始的。
为什么会这样?
【问题讨论】:
-
到底是什么问题?模式转储程序更新
schema.rb并且所有那些看起来很时髦的查询都用于找出表结构。 -
@mu 每次我运行 rake db:migrate 时都会发生这种情况......如果迁移是最新的,我预计不会发生任何事情。我不明白为什么我看到这个输出......
-
它总是以'first_time'运行
-
@muistooshort 你知道是什么导致它像这样转储架构吗?
-
不是我的头顶。我使用
structure.sql,因为我的数据库中有各种ActiveRecord 无法理解的东西。为什么这是个问题? “我的输出都搞砸了”是什么意思?
标签: ruby-on-rails ruby rake rails-activerecord