import { config } from "dotenv";
import path from "node:path";
config({ path: path.resolve(process.cwd(), ".env.local") });

const { default: postgres } = await import("postgres");
const sql = postgres(process.env.DATABASE_URL, { max: 1 });

try {
  await sql`
    CREATE TABLE IF NOT EXISTS admin_settings (
      key text PRIMARY KEY NOT NULL,
      value jsonb NOT NULL,
      updated_at timestamp DEFAULT now() NOT NULL,
      updated_by uuid REFERENCES users(id) ON DELETE SET NULL
    )
  `;
  console.log("admin_settings table ready");
} finally {
  await sql.end();
}
