forked from chatwoot/chatwoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Campaign ID migration for existing accounts (chatwoot#2189)
* chore: Campaign ID migration for existing accounts * chore: update factory * chore: minor fixes * chore: fixes
- Loading branch information
1 parent
bd7e9d2
commit a07200b
Showing
8 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
json.id resource.display_id | ||
json.content resource.content | ||
json.description resource.description | ||
json.enabled resource.enabled | ||
json.title resource.title | ||
json.trigger_rules resource.trigger_rules | ||
json.description resource.description | ||
json.account_id resource.account_id | ||
json.inbox do | ||
json.partial! 'api/v1/models/inbox.json.jbuilder', resource: resource.inbox | ||
end | ||
json.sender do | ||
json.partial! 'api/v1/models/agent.json.jbuilder', resource: resource.sender if resource.sender.present? | ||
end | ||
json.message resource.message | ||
json.enabled resource.enabled | ||
json.trigger_rules resource.trigger_rules | ||
json.created_at resource.created_at | ||
json.updated_at resource.updated_at |
20 changes: 20 additions & 0 deletions
20
db/migrate/20210430095748_add_camp_dp_id_seq_for_existing_accounts.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
5 changes: 5 additions & 0 deletions
5
db/migrate/20210430100138_rename_campaign_content_to_message.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class RenameCampaignContentToMessage < ActiveRecord::Migration[6.0] | ||
def change | ||
rename_column :campaigns, :content, :message | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters