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

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_04_28_151147) do
ActiveRecord::Schema.define(version: 2021_04_30_100138) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
@@ -117,7 +117,7 @@ ActiveRecord::Schema.define(version: 2021_04_28_151147) do
t.integer "display_id", null: false
t.string "title", null: false
t.text "description"
t.text "content", null: false
t.text "message", null: false
t.integer "sender_id"
t.boolean "enabled", default: true
t.bigint "account_id", null: false