-- Remove type column from documents table
-- This simplifies the documents structure by removing the type field entirely

-- SQLite doesn't support DROP COLUMN directly, so we need to recreate the table
-- First, create a backup of the existing data
CREATE TABLE documents_backup AS SELECT id, title, filename, uri, sort_order, uploaded_at FROM documents;

-- Drop the original table
DROP TABLE documents;

-- Recreate the table without the type column
CREATE TABLE documents (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    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 (excluding type column)
INSERT INTO documents SELECT id, title, filename, uri, sort_order, uploaded_at FROM documents_backup;

-- Drop the backup table
DROP TABLE documents_backup;
