Rails Gem strong_migrations防止架构加载

发布于 2025-01-28 17:30:33 字数 1251 浏览 2 评论 0原文

我最近尝试在项目中添加了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倚栏听风 2025-02-04 17:30:33

升级GEM应解决错误。在0.8.0中添加了对版本的模式的支持。

Upgrading the gem should fix the error. Support for versioned schemas was added in 0.8.0.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文