export async function up({ context: db }) {
    const existingTables = db
        .prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='epics'")
        .all();
    if (existingTables.length === 0) {
        db.exec(`
      CREATE TABLE epics (
        id          TEXT PRIMARY KEY,
        project_id  TEXT NOT NULL,
        name        TEXT NOT NULL,
        description TEXT,
        status      TEXT NOT NULL DEFAULT 'Backlog',
        start_date  INTEGER,
        end_date    INTEGER,
        created_at  INTEGER NOT NULL,
        updated_at  INTEGER NOT NULL,
        deleted_at  INTEGER,
        FOREIGN KEY (project_id) REFERENCES pm_projects(id)
      )
    `);
        db.exec('CREATE INDEX idx_epics_project_id ON epics(project_id)');
    }
}
export async function down({ context: db }) {
    db.exec('DROP TABLE IF EXISTS epics');
}
