-- Remove unique constraint from documents.type field
-- This allows multiple documents of the same type

-- SQLite doesn't support DROP CONSTRAINT directly, so we need to recreate the table
-- First, create a backup of the existing data
CREATE TABLE documents_backup AS SELECT * FROM documents;

-- Drop the original table
DROP TABLE documents;

-- Recreate the table without the unique constraint
CREATE TABLE documents (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    type TEXT NOT NULL,
    title TEXT NOT NULL,
    filename TEXT NOT NULL,
    uri TEXT NOT NULL,
    sort_order INTEGER NOT NULL DEFAULT 999,
    uploaded_at DATETIME NOT NULL
);

-- Restore the data from backup
INSERT INTO documents SELECT * FROM documents_backup;

-- Drop the backup table
DROP TABLE documents_backup;

