import type { Kysely } from "kysely";
import { sql } from "kysely";

export async function up(db: Kysely<any>): Promise<void> {
    await db.schema
        .createTable("default_emails")
        .addColumn("id", "uuid", (col) =>
            col.primaryKey().defaultTo(sql`gen_random_uuid()`),)
        .addColumn("email", "text", (col) => col.notNull().unique())
        .addColumn("is_active", "boolean", (col) => col.notNull().defaultTo(true))
        .addColumn("created_at", "timestamptz", (col) =>
            col.notNull().defaultTo(sql`now()`),)
        .addColumn("updated_at", "timestamptz", (col) =>
            col.notNull().defaultTo(sql`now()`),)
        .execute();
}

export async function down(db: Kysely<any>): Promise<void> {
    await db.schema.dropTable("default_emails").execute();
}
