From 0e5155141f5f48b842bf59a271bcb8c6d25b7ae5 Mon Sep 17 00:00:00 2001 From: Mark Liffiton Date: Fri, 26 Jul 2024 11:24:02 -0500 Subject: [PATCH] Move contexts table def into app-specific schema (no migration required). --- src/codehelp/schema.sql | 17 +++++++++++++++++ src/gened/schema_common.sql | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/codehelp/schema.sql b/src/codehelp/schema.sql index 3e384a4..076c9d7 100644 --- a/src/codehelp/schema.sql +++ b/src/codehelp/schema.sql @@ -48,6 +48,23 @@ CREATE INDEX chats_by_user ON chats(user_id); DROP INDEX IF EXISTS chats_by_role; CREATE INDEX chats_by_role ON chats(role_id); +-- Contexts for use in a class +-- Config stored as JSON for flexibility, esp. during development +DROP TABLE IF EXISTS contexts; +CREATE TABLE contexts ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + class_id INTEGER NOT NULL, + class_order INTEGER NOT NULL, -- position within manual ordering of contexts within a class + available DATE NOT NULL, -- date on which this context will be available to students (& mindate=available, maxdate=disabled) + config TEXT NOT NULL DEFAULT "{}", -- JSON containing context config options + created DATETIME DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY(class_id) REFERENCES classes(id) +); +-- names must be unique within a class, and we often look up by class and name +DROP INDEX IF EXISTS contexts_by_class_name; +CREATE UNIQUE INDEX contexts_by_class_name ON contexts(class_id, name); + DROP TABLE IF EXISTS context_strings; CREATE TABLE context_strings ( id INTEGER PRIMARY KEY AUTOINCREMENT, diff --git a/src/gened/schema_common.sql b/src/gened/schema_common.sql index 9712e04..a88a530 100644 --- a/src/gened/schema_common.sql +++ b/src/gened/schema_common.sql @@ -15,7 +15,6 @@ DROP TABLE IF EXISTS roles; DROP TABLE IF EXISTS classes; DROP TABLE IF EXISTS classes_lti; DROP TABLE IF EXISTS classes_user; -DROP TABLE IF EXISTS contexts; DROP TABLE IF EXISTS demo_links; DROP TABLE IF EXISTS migrations; DROP TABLE IF EXISTS models; @@ -124,22 +123,6 @@ CREATE TABLE classes_user ( DROP INDEX IF EXISTS classes_user_by_link_ident; CREATE UNIQUE INDEX classes_user_by_link_ident ON classes_user(link_ident); --- Contexts for use in a class --- Config stored as JSON for flexibility, esp. during development -CREATE TABLE contexts ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, - class_id INTEGER NOT NULL, - class_order INTEGER NOT NULL, -- position within manual ordering of contexts within a class - available DATE NOT NULL, -- date on which this context will be available to students (& mindate=available, maxdate=disabled) - config TEXT NOT NULL DEFAULT "{}", -- JSON containing context config options - created DATETIME DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY(class_id) REFERENCES classes(id) -); --- names must be unique within a class, and we often look up by class and name -DROP INDEX IF EXISTS contexts_by_class_name; -CREATE UNIQUE INDEX contexts_by_class_name ON contexts(class_id, name); - -- Roles for users in classes CREATE TABLE roles ( id INTEGER PRIMARY KEY AUTOINCREMENT,