44-- Target DEV database: gamefoundry_dev
55-- Scope: executable grouped table DDL for active server API migration.
66-- 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_tts_profiles, messages_records, messages_segments
7+ -- Owned tables: messages_categories, messages_emotion_profiles, messages_tts_profiles, messages_tts_profile_emotion_settings, messages_records, messages_segments, messages_event_actions
88CREATE TABLE IF NOT EXISTS messages_categories (
99 key text PRIMARY KEY ,
1010 " name" text NOT NULL UNIQUE,
@@ -31,30 +31,48 @@ CREATE TABLE IF NOT EXISTS messages_emotion_profiles (
3131 " updatedBy" text NOT NULL REFERENCES users(key)
3232);
3333
34- CREATE TABLE IF NOT EXISTS messages_records (
34+ CREATE TABLE IF NOT EXISTS messages_tts_profiles (
3535 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 ' ' ,
36+ " name" text NOT NULL UNIQUE,
37+ " description" text NOT NULL DEFAULT ' ' ,
38+ " providerKey" text NOT NULL ,
39+ " voiceName" text NOT NULL DEFAULT ' ' ,
40+ " language" text NOT NULL ,
41+ " volume" numeric NOT NULL DEFAULT 1 ,
42+ " pitch" numeric NOT NULL DEFAULT 1 ,
43+ " rate" numeric NOT NULL DEFAULT 1 ,
4144 " active" boolean NOT NULL DEFAULT true,
4245 " createdAt" timestamptz NOT NULL DEFAULT now(),
4346 " updatedAt" timestamptz NOT NULL DEFAULT now(),
4447 " createdBy" text NOT NULL REFERENCES users(key),
4548 " updatedBy" text NOT NULL REFERENCES users(key)
4649);
4750
48- CREATE TABLE IF NOT EXISTS messages_tts_profiles (
51+ CREATE TABLE IF NOT EXISTS messages_tts_profile_emotion_settings (
4952 key text PRIMARY KEY ,
50- " name" text NOT NULL UNIQUE,
51- " description" text NOT NULL DEFAULT ' ' ,
52- " providerKey" text NOT NULL ,
53- " voiceName" text NOT NULL DEFAULT ' ' ,
54- " language" text NOT NULL ,
53+ " ttsProfileKey" text NOT NULL REFERENCES messages_tts_profiles(key),
54+ " emotionProfileKey" text NOT NULL REFERENCES messages_emotion_profiles(key),
5555 " volume" numeric NOT NULL DEFAULT 1 ,
5656 " pitch" numeric NOT NULL DEFAULT 1 ,
5757 " rate" numeric NOT NULL DEFAULT 1 ,
58+ " displayOrder" integer NOT NULL DEFAULT 0 ,
59+ " ssmlLikePreset" text NOT NULL DEFAULT ' normal' ,
60+ " active" boolean NOT NULL DEFAULT true,
61+ " createdAt" timestamptz NOT NULL DEFAULT now(),
62+ " updatedAt" timestamptz NOT NULL DEFAULT now(),
63+ " createdBy" text NOT NULL REFERENCES users(key),
64+ " updatedBy" text NOT NULL REFERENCES users(key),
65+ UNIQUE (" ttsProfileKey" , " emotionProfileKey" )
66+ );
67+
68+ CREATE TABLE IF NOT EXISTS messages_records (
69+ key text PRIMARY KEY ,
70+ " name" text NOT NULL ,
71+ " categoryKey" text NOT NULL REFERENCES messages_categories(key),
72+ " emotionProfileKey" text NOT NULL REFERENCES messages_emotion_profiles(key),
73+ " voiceProfileKey" text NOT NULL REFERENCES messages_tts_profiles(key),
74+ " messageText" text NOT NULL ,
75+ " notes" text NOT NULL DEFAULT ' ' ,
5876 " active" boolean NOT NULL DEFAULT true,
5977 " createdAt" timestamptz NOT NULL DEFAULT now(),
6078 " updatedAt" timestamptz NOT NULL DEFAULT now(),
@@ -66,6 +84,7 @@ CREATE TABLE IF NOT EXISTS messages_segments (
6684 key text PRIMARY KEY ,
6785 " messageKey" text NOT NULL REFERENCES messages_records(key),
6886 " emotionProfileKey" text NOT NULL REFERENCES messages_emotion_profiles(key),
87+ " voiceProfileKey" text NOT NULL REFERENCES messages_tts_profiles(key),
6988 " segmentText" text NOT NULL ,
7089 " displayOrder" integer NOT NULL ,
7190 " active" boolean NOT NULL DEFAULT true,
@@ -75,15 +94,38 @@ CREATE TABLE IF NOT EXISTS messages_segments (
7594 " updatedBy" text NOT NULL REFERENCES users(key)
7695);
7796
97+ CREATE TABLE IF NOT EXISTS messages_event_actions (
98+ key text PRIMARY KEY ,
99+ " name" text NOT NULL ,
100+ " actionType" text NOT NULL ,
101+ " messageKey" text REFERENCES messages_records(key),
102+ " active" boolean NOT NULL DEFAULT true,
103+ " createdAt" timestamptz NOT NULL DEFAULT now(),
104+ " updatedAt" timestamptz NOT NULL DEFAULT now(),
105+ " createdBy" text NOT NULL REFERENCES users(key),
106+ " updatedBy" text NOT NULL REFERENCES users(key)
107+ );
108+
78109CREATE INDEX IF NOT EXISTS idx_messages_records_categorykey ON messages_records (" categoryKey" );
79110CREATE INDEX IF NOT EXISTS idx_messages_records_emotionprofilekey ON messages_records (" emotionProfileKey" );
111+ CREATE INDEX IF NOT EXISTS idx_messages_records_voiceprofilekey ON messages_records (" voiceProfileKey" );
80112CREATE INDEX IF NOT EXISTS idx_messages_records_createdby ON messages_records (" createdBy" );
81113CREATE INDEX IF NOT EXISTS idx_messages_records_updatedby ON messages_records (" updatedBy" );
82114CREATE INDEX IF NOT EXISTS idx_messages_segments_messagekey ON messages_segments (" messageKey" );
83115CREATE INDEX IF NOT EXISTS idx_messages_segments_emotionprofilekey ON messages_segments (" emotionProfileKey" );
116+ CREATE INDEX IF NOT EXISTS idx_messages_segments_voiceprofilekey ON messages_segments (" voiceProfileKey" );
84117CREATE INDEX IF NOT EXISTS idx_messages_segments_order ON messages_segments (" messageKey" , " displayOrder" );
85118CREATE INDEX IF NOT EXISTS idx_messages_segments_createdby ON messages_segments (" createdBy" );
86119CREATE INDEX IF NOT EXISTS idx_messages_segments_updatedby ON messages_segments (" updatedBy" );
120+ CREATE INDEX IF NOT EXISTS idx_messages_event_actions_actiontype ON messages_event_actions (" actionType" );
121+ CREATE INDEX IF NOT EXISTS idx_messages_event_actions_messagekey ON messages_event_actions (" messageKey" );
122+ CREATE INDEX IF NOT EXISTS idx_messages_event_actions_createdby ON messages_event_actions (" createdBy" );
123+ CREATE INDEX IF NOT EXISTS idx_messages_event_actions_updatedby ON messages_event_actions (" updatedBy" );
87124CREATE INDEX IF NOT EXISTS idx_messages_tts_profiles_providerkey ON messages_tts_profiles (" providerKey" );
88125CREATE INDEX IF NOT EXISTS idx_messages_tts_profiles_createdby ON messages_tts_profiles (" createdBy" );
89126CREATE INDEX IF NOT EXISTS idx_messages_tts_profiles_updatedby ON messages_tts_profiles (" updatedBy" );
127+ CREATE INDEX IF NOT EXISTS idx_messages_tts_profile_emotion_settings_ttsprofilekey ON messages_tts_profile_emotion_settings (" ttsProfileKey" );
128+ CREATE INDEX IF NOT EXISTS idx_messages_tts_profile_emotion_settings_emotionprofilekey ON messages_tts_profile_emotion_settings (" emotionProfileKey" );
129+ CREATE INDEX IF NOT EXISTS idx_messages_tts_profile_emotion_settings_order ON messages_tts_profile_emotion_settings (" ttsProfileKey" , " displayOrder" );
130+ CREATE INDEX IF NOT EXISTS idx_messages_tts_profile_emotion_settings_createdby ON messages_tts_profile_emotion_settings (" createdBy" );
131+ CREATE INDEX IF NOT EXISTS idx_messages_tts_profile_emotion_settings_updatedby ON messages_tts_profile_emotion_settings (" updatedBy" );
0 commit comments