-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
22 changed files
with
214 additions
and
36 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
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,4 @@ | ||
class ChapterAccountAssignment < ApplicationRecord | ||
belongs_to :chapter | ||
belongs_to :account | ||
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
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
17 changes: 17 additions & 0 deletions
17
db/migrate/20240924161806_create_chapter_account_assignments.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,17 @@ | ||
class CreateChapterAccountAssignments < ActiveRecord::Migration[6.1] | ||
def change | ||
create_table :chapter_account_assignments do |t| | ||
t.belongs_to :chapter | ||
t.belongs_to :account | ||
|
||
t.string :profile_type | ||
t.integer :season, limit: 2 | ||
t.boolean :primary | ||
|
||
t.index [:chapter_id, :account_id], name: "index_table_chapter_account_assignments_on_chapter_account_ids" | ||
t.index [:account_id, :chapter_id], name: "index_table_chapter_account_assignments_on_account_chapter_ids" | ||
|
||
t.timestamps | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddPrimaryAccountToChapters < ActiveRecord::Migration[6.1] | ||
def change | ||
add_reference :chapters, :primary_account, null: true, foreign_key: {to_table: :accounts} | ||
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
20 changes: 20 additions & 0 deletions
20
lib/tasks/migrate_chapter_ambassador_chapter_assignments.rake
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 @@ | ||
desc "Migrate Chapter Ambassador Chapter Assignments" | ||
task migrate_cha_chapter_assignments: :environment do | ||
chapter_ambassadors_with_chapters = ChapterAmbassadorProfile | ||
.where.not(chapter_id: nil) | ||
|
||
if chapter_ambassadors_with_chapters.present? | ||
chapter_ambassadors_with_chapters.find_each do |chapter_ambassador| | ||
chapter_ambassador.account.chapter_assignments.create( | ||
chapter_id: chapter_ambassador.chapter_id, | ||
profile_type: "ChapterAmbassadorProfile", | ||
season: 2025, | ||
primary: true | ||
) | ||
|
||
chapter_ambassador.update_column(:chapter_id, nil) | ||
|
||
puts "Migrated #{chapter_ambassador.account.full_name} to new chapter assignments model" | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
desc "Migrate Chapter Primary Contacts" | ||
task migrate_chapter_primary_contacts: :environment do | ||
chapters = Chapter | ||
.where.not(primary_contact_id: nil) | ||
|
||
if chapters.present? | ||
chapters.find_each do |chapter| | ||
primary_account = ChapterAmbassadorProfile.find(chapter.primary_contact_id).account | ||
|
||
chapter.update_column(:primary_account_id, primary_account.id) | ||
|
||
puts "Migrated primary contact #{primary_account.full_name} for chapter #{chapter.name}" | ||
end | ||
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
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
Oops, something went wrong.