36 lines
911 B
Ruby
36 lines
911 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class MigrateAdbutlerToExcludeGroups < ActiveRecord::Migration[7.0]
|
||
|
def up
|
||
|
adbutler_display_groups_raw =
|
||
|
DB.query_single(
|
||
|
"SELECT value FROM site_settings WHERE name = 'adbutler_display_groups'",
|
||
|
).first
|
||
|
|
||
|
if adbutler_display_groups_raw.present?
|
||
|
adbutler_exclude_groups =
|
||
|
case adbutler_display_groups_raw
|
||
|
when "10"
|
||
|
"3|11|12|13|14"
|
||
|
when "10|11"
|
||
|
"3|12|13|14"
|
||
|
when "10|11|12"
|
||
|
"3|13|14"
|
||
|
when "10|11|12|13"
|
||
|
"3|14"
|
||
|
when "10|11|12|14"
|
||
|
"3"
|
||
|
end
|
||
|
|
||
|
DB.exec(<<~SQL, setting: adbutler_exclude_groups)
|
||
|
INSERT INTO site_settings(name, value, data_type, created_at, updated_at)
|
||
|
VALUES('adbutler_exclude_groups', :setting, '20', NOW(), NOW())
|
||
|
SQL
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def down
|
||
|
raise ActiveRecord::IrreversibleMigration
|
||
|
end
|
||
|
end
|