我想部署一个登台服务器,我使用 mina 进行部署。
我愿意mina staging deploy
(在迁移之前工作良好)
== 20161117192144 CreateHealthCenter: migrating ===============================
-- add_column(:places, :health_center, :boolean, {:default=>false})
-> 0.0152s
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: relation "versions" does not exist
LINE 5: WHERE a.attrelid = '"versions"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"versions"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
该Place
模型具有 has_paper_trail(在 app/models/place.rb 中)
paper_trail 的迁移是 2017 年的迁移
我有 4 个创建实例,例如:
Place.create( name: "CESFAM" , address: "Av R 740" , health_center: true )
我认为这是问题所在(现在我知道我不必在迁移中执行 data_migration),但我想知道替代解决方案
我认为这个解决方案
- 向 paper_trail 添加一些配置
- 编辑迁移删除数据迁移
- 其他
(对不起我糟糕的英语)
编辑: - Rails 4 - 纸迹 8.1.2
编辑2:
迁移 20161117192144
class CreateHealthCenter < ActiveRecord::Migration
def up
add_column :places, :health_center , :boolean , default: false
Place.create( name: "CESFAM" , address: "R 740" , health_center: true )
Place.create( name: "CECOF" , address: "S 185" , health_center: true )
Place.create( name: "COSAM" , address: "C 1892" , health_center: true )
end
def down
remove_column :places, :health_center
Place.where("name = 'CESFAM'").delete_all
Place.where("name = 'CECOF'").delete_all
Place.where("name = 'COSAM'").delete_all
end
end