From 6918bcf9471cf22c816012a9ad07bde9da6a8450 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Wed, 16 Oct 2024 17:19:37 -0400 Subject: [PATCH] Update model and SQL with small_class flag definition. --- src/models/class.ts | 4 ++++ src/sql/create_class_table.sql | 1 + 2 files changed, 5 insertions(+) diff --git a/src/models/class.ts b/src/models/class.ts index cd74ea7..87a6093 100644 --- a/src/models/class.ts +++ b/src/models/class.ts @@ -12,6 +12,7 @@ export class Class extends Model, InferCreationAttributes declare asynchronous: CreationOptional; declare test: CreationOptional; declare expected_size: CreationOptional; + declare small_class: CreationOptional; } export function initializeClassModel(sequelize: Sequelize) { @@ -67,6 +68,9 @@ export function initializeClassModel(sequelize: Sequelize) { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, }, + small_class: { + type: "tinyint(1) GENERATED ALWAYS AS (expected_size < 10) VIRTUAL", + }, }, { sequelize, }); diff --git a/src/sql/create_class_table.sql b/src/sql/create_class_table.sql index d639b4d..5730330 100644 --- a/src/sql/create_class_table.sql +++ b/src/sql/create_class_table.sql @@ -9,6 +9,7 @@ CREATE TABLE Classes ( test tinyint(1) NOT NULL DEFAULT 0, updated datetime DEFAULT NULL, expected_size int(11) UNSIGNED NOT NULL, + small_class tinyint(1) GENERATED ALWAYS AS (expected_size < 10) VIRTUAL, PRIMARY KEY(id), INDEX(educator_id),