You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on the documentation and the above comment, I expect safety_assured to skip all checks, regardless of the value of safe_by_default.
Actual behavior:
safety_assured is not ignoring custom checks when safe_by_default is true
Steps to reproduce
(For this example, my DB has a users table and a phone (string) column)
Set StrongMigrations.safe_by_default = true in the config file
Add a custom check in the config file (I've used the exact one from the documentation):
StrongMigrations.add_check do |method, args|
if method == :add_index && args[0].to_s == "users"
stop! "No more indexes on the users table"
end
end
Add a migration that violates the custom check, but wrap it in safety_assured:
class AddIndexOnPhoneToUsers < ActiveRecord::Migration[7.0]
disable_ddl_transaction!
def change
safety_assured {
add_index :users, :phone
}
end
end
Run the migration and note that it aborts:
Migrating to AddIndexOnPhoneToUsers (20230809182230)
== 20230809182230 AddIndexOnPhoneToUsers: migrating ===========================
(0.3ms) SHOW server_version_num
(0.2ms) SET statement_timeout TO 3600000
(0.2ms) SET lock_timeout TO 10000
(0.3ms) SELECT pg_advisory_unlock(400918011933137580)
rails aborted!
StandardError: An error has occurred, all later migrations canceled:
=== Custom check #strong_migrations ===
No more indexes on the users table
The text was updated successfully, but these errors were encountered:
Using:
ruby 3.2.1
rails 7.0.5.1
strong_migrations 1.6.0
Expectation:
Originally posted by @ankane in #66 (comment)
Based on the documentation and the above comment, I expect
safety_assured
to skip all checks, regardless of the value ofsafe_by_default
.Actual behavior:
safety_assured
is not ignoring custom checks whensafe_by_default
is trueSteps to reproduce
(For this example, my DB has a
users
table and aphone
(string) column)StrongMigrations.safe_by_default = true
in the config filesafety_assured
:The text was updated successfully, but these errors were encountered: