【问题标题】:Rails gem strong_migrations preventing schema from loadingRails gem strong_migrations 防止模式加载
【发布时间】:2022-06-16 14:27:08
【问题描述】:

我最近尝试将 strong_migrations gem 添加到我的项目中,但它阻止我运行任何测试,因为我的架构中的所有表都有 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)

我不确定这是否相关,但我确实检查了 Strong Migrations 初始化程序,并且开始日期设置为我最近一次迁移之后:

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

有谁知道如何解决这个问题?

【问题讨论】:

    标签: ruby-on-rails ruby testing rubygems


    【解决方案1】:

    升级 gem 应该可以修复错误。在 0.8.0 中添加了对版本化模式的支持。

    【讨论】:

      猜你喜欢
      • 2012-02-13
      • 1970-01-01
      • 1970-01-01
      • 2018-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多