// v4: status 4분기 (active/completed/archived/trashed) + 사유 + status_changed_at.
// 기존 deleted_at != NULL 노트는 status='trashed' 로 migrate. deleted_at 컬럼은
// backward compat 위해 잔류 (status='trashed' 와 동기화). 향후 cut 에서 제거 가능.
import type Database from 'better-sqlite3';

export const version = 4;

export function up(db: Database.Database): void {
  db.exec(`
    ALTER TABLE notes ADD COLUMN status TEXT NOT NULL DEFAULT 'active';
    ALTER TABLE notes ADD COLUMN status_changed_at TEXT;
    ALTER TABLE notes ADD COLUMN move_reason TEXT;
  `);
  db.prepare(
    `UPDATE notes SET status='trashed', status_changed_at=deleted_at
     WHERE deleted_at IS NOT NULL`
  ).run();
}
