Skip to content

Commit

Permalink
Move contexts table def into app-specific schema (no migration requir…
Browse files Browse the repository at this point in the history
…ed).
  • Loading branch information
liffiton committed Jul 26, 2024
1 parent 896b5db commit 0e51551
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
17 changes: 17 additions & 0 deletions src/codehelp/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 0 additions & 17 deletions src/gened/schema_common.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0e51551

Please sign in to comment.