1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added a separate table to record background job status for tournaments and fixed migrations/schemas for solid dbs. Foreign key constraints are now added to the migrations where we do belongs_to.

This commit is contained in:
2025-04-15 16:16:44 -04:00
parent 4828d9b876
commit 6e61a7245a
37 changed files with 678 additions and 1169 deletions

View File

@@ -0,0 +1,15 @@
class CreateTournamentJobStatuses < ActiveRecord::Migration[8.0]
def change
create_table :tournament_job_statuses do |t|
t.bigint :tournament_id, null: false
t.string :job_name, null: false
t.string :status, null: false, default: "Queued" # Queued, Running, Errored
t.text :details # Additional details about the job (e.g., wrestler name, school name)
t.timestamps
end
add_index :tournament_job_statuses, :tournament_id
add_index :tournament_job_statuses, [:tournament_id, :job_name]
add_foreign_key :tournament_job_statuses, :tournaments
end
end

View File

@@ -0,0 +1,43 @@
class ChangeForeignKeyColumnsToBigint < ActiveRecord::Migration[7.0]
def change
# wrestlers table
change_column :wrestlers, :school_id, :bigint
change_column :wrestlers, :weight_id, :bigint
# weights table
change_column :weights, :tournament_id, :bigint
# tournament_delegates table
change_column :tournament_delegates, :tournament_id, :bigint
change_column :tournament_delegates, :user_id, :bigint
# tournaments table
change_column :tournaments, :user_id, :bigint
# tournament_backups table
change_column :tournament_backups, :tournament_id, :bigint
# teampointadjusts table
change_column :teampointadjusts, :wrestler_id, :bigint
change_column :teampointadjusts, :school_id, :bigint
# school_delegates table
change_column :school_delegates, :school_id, :bigint
change_column :school_delegates, :user_id, :bigint
# schools table
change_column :schools, :tournament_id, :bigint
# matches table
change_column :matches, :tournament_id, :bigint
change_column :matches, :weight_id, :bigint
change_column :matches, :mat_id, :bigint
# mat_assignment_rules table
change_column :mat_assignment_rules, :mat_id, :bigint
change_column :mat_assignment_rules, :tournament_id, :bigint
# mats table
change_column :mats, :tournament_id, :bigint
end
end

View File

@@ -0,0 +1,43 @@
class AddForeignKeys < ActiveRecord::Migration[7.0]
def change
# wrestlers table
add_foreign_key :wrestlers, :schools
add_foreign_key :wrestlers, :weights
# weights table
add_foreign_key :weights, :tournaments
# tournament_delegates table
add_foreign_key :tournament_delegates, :tournaments
add_foreign_key :tournament_delegates, :users
# tournaments table
add_foreign_key :tournaments, :users
# tournament_backups table
add_foreign_key :tournament_backups, :tournaments
# teampointadjusts table
add_foreign_key :teampointadjusts, :wrestlers
add_foreign_key :teampointadjusts, :schools
# school_delegates table
add_foreign_key :school_delegates, :schools
add_foreign_key :school_delegates, :users
# schools table
add_foreign_key :schools, :tournaments
# matches table
add_foreign_key :matches, :tournaments
add_foreign_key :matches, :weights
add_foreign_key :matches, :mats
# mat_assignment_rules table
add_foreign_key :mat_assignment_rules, :mats
add_foreign_key :mat_assignment_rules, :tournaments
# mats table
add_foreign_key :mats, :tournaments
end
end

View File

@@ -0,0 +1,17 @@
class AddMissingIndexesAndFixUnique < ActiveRecord::Migration[7.0]
def change
# Add missing indexes
add_index :tournament_delegates, :tournament_id
add_index :tournament_delegates, :user_id
add_index :tournament_backups, :tournament_id
add_index :teampointadjusts, :school_id
add_index :school_delegates, :school_id
add_index :school_delegates, :user_id
add_index :mat_assignment_rules, :tournament_id
end
end