|
| 1 | +-- Game Foundry Studio DEV database DDL |
| 2 | +-- Group: Messages |
| 3 | +-- Ownership: docs_build/database/ddl/messages.sql |
| 4 | +-- Target DEV database: gamefoundry_dev |
| 5 | +-- Scope: executable grouped table DDL for active server API migration. |
| 6 | +-- Authoritative key values are generated by the server/API layer unless a later DEV-only seed exception explicitly applies. |
| 7 | +-- Owned tables: messages_categories, messages_emotion_profiles, messages_records |
| 8 | +CREATE TABLE IF NOT EXISTS messages_categories ( |
| 9 | + key text PRIMARY KEY, |
| 10 | + "name" text NOT NULL UNIQUE, |
| 11 | + "active" boolean NOT NULL DEFAULT true, |
| 12 | + "createdAt" timestamptz NOT NULL DEFAULT now(), |
| 13 | + "updatedAt" timestamptz NOT NULL DEFAULT now(), |
| 14 | + "createdBy" text NOT NULL REFERENCES users(key), |
| 15 | + "updatedBy" text NOT NULL REFERENCES users(key) |
| 16 | +); |
| 17 | + |
| 18 | +CREATE TABLE IF NOT EXISTS messages_emotion_profiles ( |
| 19 | + key text PRIMARY KEY, |
| 20 | + "name" text NOT NULL UNIQUE, |
| 21 | + "description" text NOT NULL DEFAULT '', |
| 22 | + "volume" numeric NOT NULL DEFAULT 1, |
| 23 | + "pitch" numeric NOT NULL DEFAULT 1, |
| 24 | + "rate" numeric NOT NULL DEFAULT 1, |
| 25 | + "pauseBeforeMs" integer NOT NULL DEFAULT 0, |
| 26 | + "pauseAfterMs" integer NOT NULL DEFAULT 0, |
| 27 | + "active" boolean NOT NULL DEFAULT true, |
| 28 | + "createdAt" timestamptz NOT NULL DEFAULT now(), |
| 29 | + "updatedAt" timestamptz NOT NULL DEFAULT now(), |
| 30 | + "createdBy" text NOT NULL REFERENCES users(key), |
| 31 | + "updatedBy" text NOT NULL REFERENCES users(key) |
| 32 | +); |
| 33 | + |
| 34 | +CREATE TABLE IF NOT EXISTS messages_records ( |
| 35 | + key text PRIMARY KEY, |
| 36 | + "name" text NOT NULL, |
| 37 | + "categoryKey" text NOT NULL REFERENCES messages_categories(key), |
| 38 | + "emotionProfileKey" text NOT NULL REFERENCES messages_emotion_profiles(key), |
| 39 | + "messageText" text NOT NULL, |
| 40 | + "notes" text NOT NULL DEFAULT '', |
| 41 | + "active" boolean NOT NULL DEFAULT true, |
| 42 | + "createdAt" timestamptz NOT NULL DEFAULT now(), |
| 43 | + "updatedAt" timestamptz NOT NULL DEFAULT now(), |
| 44 | + "createdBy" text NOT NULL REFERENCES users(key), |
| 45 | + "updatedBy" text NOT NULL REFERENCES users(key) |
| 46 | +); |
| 47 | + |
| 48 | +CREATE INDEX IF NOT EXISTS idx_messages_records_categorykey ON messages_records ("categoryKey"); |
| 49 | +CREATE INDEX IF NOT EXISTS idx_messages_records_emotionprofilekey ON messages_records ("emotionProfileKey"); |
| 50 | +CREATE INDEX IF NOT EXISTS idx_messages_records_createdby ON messages_records ("createdBy"); |
| 51 | +CREATE INDEX IF NOT EXISTS idx_messages_records_updatedby ON messages_records ("updatedBy"); |
0 commit comments