mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-04 13:43:48 +00:00
Added mat assignment rules for the bout board and fixed the bug where a delegate making the tournamnet info public changes them to the owner
This commit is contained in:
28
db/migrate/20241027203209_create_mat_assignment_rules.rb
Normal file
28
db/migrate/20241027203209_create_mat_assignment_rules.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
class CreateMatAssignmentRules < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
create_table :mat_assignment_rules do |t|
|
||||
t.references :tournament, null: false, foreign_key: true
|
||||
t.references :mat, null: false, foreign_key: true
|
||||
t.json :weight_classes, default: []
|
||||
t.json :bracket_positions, default: []
|
||||
t.json :rounds, default: []
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
# Add unique index on mat_id if it does not already exist
|
||||
add_index :mat_assignment_rules, :mat_id, unique: true unless index_exists?(:mat_assignment_rules, :mat_id)
|
||||
|
||||
# Add index on tournament_id for faster lookups
|
||||
add_index :mat_assignment_rules, :tournament_id unless index_exists?(:mat_assignment_rules, :tournament_id)
|
||||
end
|
||||
|
||||
def down
|
||||
# Remove indexes if they exist
|
||||
remove_index :mat_assignment_rules, :mat_id if index_exists?(:mat_assignment_rules, :mat_id)
|
||||
remove_index :mat_assignment_rules, :tournament_id if index_exists?(:mat_assignment_rules, :tournament_id)
|
||||
|
||||
# Drop the table
|
||||
drop_table :mat_assignment_rules
|
||||
end
|
||||
end
|
||||
16
db/schema.rb
16
db/schema.rb
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_03_11_103416) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_10_27_203209) do
|
||||
create_table "delayed_jobs", force: :cascade do |t|
|
||||
t.integer "priority", default: 0, null: false
|
||||
t.integer "attempts", default: 0, null: false
|
||||
@@ -28,6 +28,18 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_11_103416) do
|
||||
t.index ["priority", "run_at"], name: "delayed_jobs_priority"
|
||||
end
|
||||
|
||||
create_table "mat_assignment_rules", force: :cascade do |t|
|
||||
t.integer "tournament_id", null: false
|
||||
t.integer "mat_id", null: false
|
||||
t.json "weight_classes", default: []
|
||||
t.json "bracket_positions", default: []
|
||||
t.json "rounds", default: []
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["mat_id"], name: "index_mat_assignment_rules_on_mat_id"
|
||||
t.index ["tournament_id"], name: "index_mat_assignment_rules_on_tournament_id"
|
||||
end
|
||||
|
||||
create_table "matches", force: :cascade do |t|
|
||||
t.integer "w1"
|
||||
t.integer "w2"
|
||||
@@ -156,4 +168,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_11_103416) do
|
||||
t.index ["weight_id"], name: "index_wrestlers_on_weight_id"
|
||||
end
|
||||
|
||||
add_foreign_key "mat_assignment_rules", "mats"
|
||||
add_foreign_key "mat_assignment_rules", "tournaments"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user