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
def change
safety_assured do
add_column :tournaments, :livestream_required, :boolean, default: false, null: false
add_column :tournament_templates, :livestream_required, :boolean, default: false, null: false
end
end
I am advised:
Active Record caches attributes, which causes problems
when removing columns. Be sure to ignore the column:
class TournamentTemplate < ApplicationRecord
self.ignored_columns = ["livestream_required"]
end
Deploy the code, then wrap this step in a safety_assured { ... } block.
class AddLivestreamRequired < ActiveRecord::Migration[7.0]
def change
safety_assured { remove_column :tournament_templates, :livestream_required, :boolean, default: false, null: false }
end
end
/Users/e86037/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `load'
/Users/e86037/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `<main>'
Caused by:
StrongMigrations::UnsafeMigration:
=== Dangerous operation detected #strong_migrations ===
Active Record caches attributes, which causes problems
when removing columns. Be sure to ignore the column:
class TournamentTemplate < ApplicationRecord
self.ignored_columns = ["livestream_required"]
end
Deploy the code, then wrap this step in a safety_assured { ... } block.
class AddLivestreamRequired < ActiveRecord::Migration[7.0]
def change
safety_assured { remove_column :tournament_templates, :livestream_required, :boolean, default: false, null: false }
end
end
Note that I got the advice twice for some reason. Perhaps because there are two tables involved, but both advice only mentions one of them.
I have these lines in my models:
class TournamentTemplate < ApplicationRecord
self.ignored_columns = ["livestream_required"]
…
class Tournament < ApplicationRecord
self.ignored_columns = ["livestream_required"]
yet the migration still refuses to run.
The text was updated successfully, but these errors were encountered:
Trying to rollback this:
I am advised:
Note that I got the advice twice for some reason. Perhaps because there are two tables involved, but both advice only mentions one of them.
I have these lines in my models:
yet the migration still refuses to run.
The text was updated successfully, but these errors were encountered: