From 24fc1ac1c4bbb3e9630357b8c845698b420881af Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Wed, 1 Jan 2025 17:50:51 +0100 Subject: New migrations. --- db/migrate/20250101125043_add_session_id_to_scores.rb | 6 ++++++ db/migrate/20250101141642_add_unique_index_to_scores.rb | 8 ++++++++ ...50101160120_add_not_null_constraint_to_session_id_in_scores.rb | 5 +++++ db/schema.rb | 5 ++++- 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20250101125043_add_session_id_to_scores.rb create mode 100644 db/migrate/20250101141642_add_unique_index_to_scores.rb create mode 100644 db/migrate/20250101160120_add_not_null_constraint_to_session_id_in_scores.rb diff --git a/db/migrate/20250101125043_add_session_id_to_scores.rb b/db/migrate/20250101125043_add_session_id_to_scores.rb new file mode 100644 index 0000000..574fa7f --- /dev/null +++ b/db/migrate/20250101125043_add_session_id_to_scores.rb @@ -0,0 +1,6 @@ +class AddSessionIdToScores < ActiveRecord::Migration[8.0] + def change + add_column :scores, :session_id, :string + add_index :scores, :session_id + end +end diff --git a/db/migrate/20250101141642_add_unique_index_to_scores.rb b/db/migrate/20250101141642_add_unique_index_to_scores.rb new file mode 100644 index 0000000..8efde1f --- /dev/null +++ b/db/migrate/20250101141642_add_unique_index_to_scores.rb @@ -0,0 +1,8 @@ +class AddUniqueIndexToScores < ActiveRecord::Migration[8.0] + def change + add_index :scores, + [:tartiflette_id, :scoring_criterium_id, :session_id], + unique: true, + name: "index_scores_on_tartiflette_criterium_session" + end +end diff --git a/db/migrate/20250101160120_add_not_null_constraint_to_session_id_in_scores.rb b/db/migrate/20250101160120_add_not_null_constraint_to_session_id_in_scores.rb new file mode 100644 index 0000000..71e174e --- /dev/null +++ b/db/migrate/20250101160120_add_not_null_constraint_to_session_id_in_scores.rb @@ -0,0 +1,5 @@ +class AddNotNullConstraintToSessionIdInScores < ActiveRecord::Migration[8.0] + def change + change_column_null :scores, :session_id, false + end +end diff --git a/db/schema.rb b/db/schema.rb index 4be092f..e750699 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,14 +10,17 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2024_12_31_134759) do +ActiveRecord::Schema[8.0].define(version: 2025_01_01_160120) do create_table "scores", force: :cascade do |t| t.integer "tartiflette_id", null: false t.integer "scoring_criterium_id", null: false t.integer "value" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "session_id", null: false t.index ["scoring_criterium_id"], name: "index_scores_on_scoring_criterium_id" + t.index ["session_id"], name: "index_scores_on_session_id" + t.index ["tartiflette_id", "scoring_criterium_id", "session_id"], name: "index_scores_on_tartiflette_criterium_session", unique: true t.index ["tartiflette_id"], name: "index_scores_on_tartiflette_id" end -- cgit v1.2.3