From 0b132cfbf48e274ecb06c7a46d7779a3660c2cf1 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 20 Feb 2026 03:31:02 -0800 Subject: [PATCH] fix: replace conflicting migration 003 with no-op Migration 003 tried to recreate tables (users, channel_members, messages) with INTEGER IDs, conflicting with 002_schema.sql which already defines them with TEXT UUIDs. This caused all tests to fail. --- internal/db/schema/003_users.sql | 35 ++++---------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/internal/db/schema/003_users.sql b/internal/db/schema/003_users.sql index f305aa0..c5a9069 100644 --- a/internal/db/schema/003_users.sql +++ b/internal/db/schema/003_users.sql @@ -1,31 +1,4 @@ -PRAGMA foreign_keys = ON; - -CREATE TABLE IF NOT EXISTS users ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - nick TEXT NOT NULL UNIQUE, - token TEXT NOT NULL UNIQUE, - created_at DATETIME DEFAULT CURRENT_TIMESTAMP, - last_seen DATETIME DEFAULT CURRENT_TIMESTAMP -); - -CREATE TABLE IF NOT EXISTS channel_members ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - channel_id INTEGER NOT NULL REFERENCES channels(id) ON DELETE CASCADE, - user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, - joined_at DATETIME DEFAULT CURRENT_TIMESTAMP, - UNIQUE(channel_id, user_id) -); - -CREATE TABLE IF NOT EXISTS messages ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - channel_id INTEGER REFERENCES channels(id) ON DELETE CASCADE, - user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, - content TEXT NOT NULL, - is_dm INTEGER NOT NULL DEFAULT 0, - dm_target_id INTEGER REFERENCES users(id) ON DELETE CASCADE, - created_at DATETIME DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX IF NOT EXISTS idx_messages_channel ON messages(channel_id, created_at); -CREATE INDEX IF NOT EXISTS idx_messages_dm ON messages(user_id, dm_target_id, created_at); -CREATE INDEX IF NOT EXISTS idx_users_token ON users(token); +-- Migration 003: no-op (schema already created by 002_schema.sql) +-- This migration previously conflicted with 002 by attempting to recreate +-- tables with incompatible column types (INTEGER vs TEXT IDs). +SELECT 1;