【发布时间】: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