-- Manual migration to add AppSetting table
-- This SQL is for SQLite and stores JSON in a TEXT column

CREATE TABLE IF NOT EXISTS "AppSetting" (
  "id" INTEGER PRIMARY KEY AUTOINCREMENT,
  "key" TEXT NOT NULL UNIQUE,
  "value" TEXT NOT NULL,
  "description" TEXT,
  "updatedAt" DATETIME NOT NULL DEFAULT (CURRENT_TIMESTAMP),
  "updatedBy" TEXT
);

-- Optional: trigger to update updatedAt on row update
CREATE TRIGGER IF NOT EXISTS "AppSetting_updatedAt"
AFTER UPDATE ON "AppSetting"
BEGIN
  UPDATE "AppSetting" SET "updatedAt" = CURRENT_TIMESTAMP WHERE "id" = NEW."id";
END;
