feat: persist chat messages to SQLite
Chat messages were ephemeral — lost on page refresh or late join. Add a chat_messages table and load the last 50 messages on connect so players see conversation history.
This commit is contained in:
15
db/migrations/006_add_chat_messages.sql
Normal file
15
db/migrations/006_add_chat_messages.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE chat_messages (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
game_id TEXT NOT NULL,
|
||||
nickname TEXT NOT NULL,
|
||||
color INTEGER NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
created_at INTEGER NOT NULL,
|
||||
FOREIGN KEY (game_id) REFERENCES games(id) ON DELETE CASCADE
|
||||
);
|
||||
CREATE INDEX idx_chat_messages_game ON chat_messages(game_id, created_at);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX IF EXISTS idx_chat_messages_game;
|
||||
DROP TABLE IF EXISTS chat_messages;
|
||||
Reference in New Issue
Block a user