import { mysqlTable, index, primaryKey, unique, varchar, int, tinyint, datetime } from "drizzle-orm/mysql-core"
import { sql } from "drizzle-orm"
import { bigintString } from '~/drizzle/customType';
const bigint = bigintString;
export const blogMenu = mysqlTable("blog_menu", {
	id: bigint({ mode: "number" }).notNull(),
	pid: bigint({ mode: "number" }).default('0').notNull(),
	name: varchar({ length: 255 }).notNull(),
	desc: varchar({ length: 255 }),
	icon: varchar({ length: 255 }).default("").notNull(),
	label: varchar({ length: 255 }),
	background: varchar({ length: 255 }),
	sort: int().default(0).notNull(),
	read: int().default(0).notNull(),
	like: int().default(0).notNull(),
	public: tinyint().default(1).notNull(),
	deleted: tinyint().default(0).notNull(),
	createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(),
	updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`),
	deletedAt: varchar("deleted_at", { length: 255 }),
	createdBy: bigint("created_by", { mode: "number" }).notNull(),
},
(table) => [
	index("create_at").on(table.createdAt),
	index("name").on(table.name),
	primaryKey({ columns: [table.id], name: "blog_menu_id"}),
	unique("unique_checkname").on(table.pid, table.name, table.deletedAt),
]);
