import { db, appsTable } from "@workspace/db";
import { inArray } from "drizzle-orm";

const SLUGS = ["calendar", "notifications", "documents"];

async function main() {
  console.log(`Disabling apps: ${SLUGS.join(", ")}...`);
  const updated = await db
    .update(appsTable)
    .set({ isActive: false })
    .where(inArray(appsTable.slug, SLUGS))
    .returning({ slug: appsTable.slug, isActive: appsTable.isActive });

  if (updated.length === 0) {
    console.warn("No matching apps found — did seed run yet?");
  } else {
    for (const row of updated) {
      console.log(`  - ${row.slug} (isActive=${row.isActive})`);
    }
  }
  console.log("Done.");
}

main()
  .catch((err) => {
    console.error(err);
    process.exit(1);
  })
  .finally(() => process.exit(0));
