Rails Gem strong_migrations防止架构加载
我最近尝试在项目中添加了strong_migrations宝石,但是它阻止了我进行任何测试,因为我的模式中的所有表都具有force :: cascade
选项。
当我尝试运行测试时,我会遇到以下错误:
bundle exec rake --trace
** Invoke default (first_time)
** Invoke test (first_time)
** Execute test
rails aborted!
StrongMigrations::UnsafeMigration:
=== Dangerous operation detected #strong_migrations ===
The force option will destroy existing tables.
If this is intended, drop the existing table first.
Otherwise, remove the force option.
/Users/ekapob/development/positive-sum-tech/friend-tested-jumpstart-pro-rails/db/schema.rb:17:in `block in <main>'
/Users/ekapob/development/positive-sum-tech/friend-tested-jumpstart-pro-rails/db/schema.rb:13:in `<main>'
Tasks: TOP => db:test:load_schema
(See full trace by running task with --trace)
我不确定这是否相关,但是我确实检查了强迁移初始日期,并且开始日期设置为我最近的迁移之后:
config/initializers/strong_migrations.rb
StrongMigrations.start_after = 20220505040931
db/schema.rb
ActiveRecord::Schema[7.0].define(version: 2022_04_26_075339)
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
end
是否有人知道如何解决这?
I've recently tried added the strong_migrations gem to my project, but it's preventing me from running any tests because all of the tables in my schema have the force: :cascade
option.
I get the following error when I attempt to run my tests:
bundle exec rake --trace
** Invoke default (first_time)
** Invoke test (first_time)
** Execute test
rails aborted!
StrongMigrations::UnsafeMigration:
=== Dangerous operation detected #strong_migrations ===
The force option will destroy existing tables.
If this is intended, drop the existing table first.
Otherwise, remove the force option.
/Users/ekapob/development/positive-sum-tech/friend-tested-jumpstart-pro-rails/db/schema.rb:17:in `block in <main>'
/Users/ekapob/development/positive-sum-tech/friend-tested-jumpstart-pro-rails/db/schema.rb:13:in `<main>'
Tasks: TOP => db:test:load_schema
(See full trace by running task with --trace)
I'm not sure if this is relevant, but I did check the Strong Migrations initializer and the start date is set to after my most recent migration:
config/initializers/strong_migrations.rb
StrongMigrations.start_after = 20220505040931
db/schema.rb
ActiveRecord::Schema[7.0].define(version: 2022_04_26_075339)
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
end
Does anyone know how to resolve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
升级GEM应解决错误。在0.8.0中添加了对版本的模式的支持。
Upgrading the gem should fix the error. Support for versioned schemas was added in 0.8.0.