From 0e0aa1618560270bec7f249b03fb4b533e48ced5 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Tue, 29 Oct 2024 17:39:55 -0400 Subject: [PATCH] Update merge groups table definition. --- src/stories/hubbles_law/models/hubble_class_merge_group.ts | 6 +++++- src/stories/hubbles_law/sql/create_merge_groups_table.sql | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/stories/hubbles_law/models/hubble_class_merge_group.ts b/src/stories/hubbles_law/models/hubble_class_merge_group.ts index a99bc83..b2c65fa 100644 --- a/src/stories/hubbles_law/models/hubble_class_merge_group.ts +++ b/src/stories/hubbles_law/models/hubble_class_merge_group.ts @@ -12,12 +12,13 @@ export function initializeHubbleClassMergeGroupModel(sequelize: Sequelize) { group_id: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, - autoIncrement: true, primaryKey: true, }, class_id: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, + unique: true, + primaryKey: true, references: { model: Class, key: "id", @@ -30,6 +31,9 @@ export function initializeHubbleClassMergeGroupModel(sequelize: Sequelize) { }, { sequelize, indexes: [ + { + fields: ["group_id"], + }, { fields: ["class_id"], }, diff --git a/src/stories/hubbles_law/sql/create_merge_groups_table.sql b/src/stories/hubbles_law/sql/create_merge_groups_table.sql index 42dac10..f5b3256 100644 --- a/src/stories/hubbles_law/sql/create_merge_groups_table.sql +++ b/src/stories/hubbles_law/sql/create_merge_groups_table.sql @@ -1,9 +1,10 @@ CREATE TABLE HubbleClassMergeGroups( - group_id int(11) UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT, + group_id int(11) UNSIGNED NOT NULL, class_id int(11) UNSIGNED NOT NULL UNIQUE, merge_order int(11) UNSIGNED NOT NULL, - PRIMARY KEY(group_id), + PRIMARY KEY(group_id, class_id), + INDEX(group_id), INDEX(class_id), FOREIGN KEY(class_id) REFERENCES Classes(id)