import type { Kysely } from "kysely";

const FEATURES = [
  { name: "Notifications", slug: "notifications" },
];

export async function up(db: Kysely<any>): Promise<void> {
  const insertValues = FEATURES.map((f) => ({
    name: f.name,
    slug: f.slug,
    is_active: true,
  }));

  // Create known backend features for the admin console role UI
  await db
    .insertInto("console_features")
    .values(insertValues)
    .onConflict((oc) => oc.column("slug").doNothing())
    .execute();
}

export async function down(db: Kysely<any>): Promise<void> {
  const slugs = FEATURES.map((f) => f.slug);
  await db
    .deleteFrom("console_features")
    .where("slug", "in", slugs)
    .execute();
}
