defer drop alias_level

This commit is contained in:
Sam 2017-08-28 13:26:03 -04:00
parent fa69e0dd77
commit e282f10d94
2 changed files with 9 additions and 5 deletions

View File

@ -7,8 +7,8 @@ Group.where(name: 'everyone').update_all(visibility_level: Group.visibility_leve
ColumnDropper.drop(
table: 'groups',
after_migration: 'RemovePublicFromGroups',
columns: %w[visible public],
after_migration: 'SplitAliasLevels',
columns: %w[visible public alias_level],
on_drop: ->() {
STDERR.puts 'Removing superflous visible group column!'
}

View File

@ -1,8 +1,12 @@
class SplitAliasLevels < ActiveRecord::Migration
def change
rename_column :groups, :alias_level, :mentionable_level
def up
add_column :groups, :messageable_level, :integer, default: 0
add_column :groups, :mentionable_level, :integer, default: 0
Group.update_all('messageable_level=mentionable_level')
execute 'UPDATE groups SET messageable_level = alias_level, mentionable_level = alias_level'
end
def down
raise ActiveRecord::IrreversibleMigration
end
end