chore: Campaign ID migration for existing accounts (#2189)

* chore: Campaign ID migration for existing accounts

* chore: update factory

* chore: minor fixes

* chore: fixes
This commit is contained in:
Sojan Jose
2021-04-30 18:45:24 +05:30
committed by GitHub
parent bd7e9d2790
commit a07200bedf
8 changed files with 42 additions and 15 deletions

View File

@@ -0,0 +1,20 @@
class AddCampDpIdSeqForExistingAccounts < ActiveRecord::Migration[6.0]
def up
::Account.find_in_batches do |accounts_batch|
Rails.logger.info "migrated till #{accounts_batch.first.id}\n"
accounts_batch.each do |account|
display_id = account.campaigns.count
ActiveRecord::Base.connection.exec_query("create sequence IF NOT EXISTS camp_dpid_seq_#{account.id} START #{display_id + 1}")
end
end
end
def down
::Account.find_in_batches do |accounts_batch|
Rails.logger.info "migrated till #{accounts_batch.first.id}\n"
accounts_batch.each do |account|
ActiveRecord::Base.connection.exec_query("drop sequence IF EXISTS camp_dpid_seq_#{account.id}")
end
end
end
end

View File

@@ -0,0 +1,5 @@
class RenameCampaignContentToMessage < ActiveRecord::Migration[6.0]
def change
rename_column :campaigns, :content, :message
end
end