forked from mtusi2026/mtusi2026lab3
feat(app) lab 3 implemented
This commit is contained in:
@@ -1,8 +1,3 @@
|
||||
-- AGENT: Single versioned baseline migration for lab 2. The application records
|
||||
-- applied versions in schema_migrations, so rerunning it never duplicates rows.
|
||||
-- The unique username constraint is the authoritative defence against the
|
||||
-- concurrent-registration race, not a SELECT followed by an INSERT.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id uuid PRIMARY KEY,
|
||||
username text NOT NULL,
|
||||
@@ -39,8 +34,5 @@ CREATE TABLE IF NOT EXISTS messages (
|
||||
CONSTRAINT messages_text_len CHECK (char_length(text) BETWEEN 1 AND 4000)
|
||||
);
|
||||
|
||||
-- AGENT: This composite index matches the only history predicate and sort order:
|
||||
-- (chat_id, created_at, id). It lets each keyset page seek directly to the cursor
|
||||
-- instead of scanning the chat history from the beginning.
|
||||
CREATE INDEX IF NOT EXISTS messages_chat_created_id_idx
|
||||
ON messages (chat_id, created_at, id);
|
||||
|
||||
Reference in New Issue
Block a user