import { index, pgTableCreator } from "drizzle-orm/pg-core"; /** * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same * database instance for multiple projects. * * @see https://orm.drizzle.team/docs/goodies#multi-project-schema */ export const createTable = pgTableCreator((name) => `web_${name}`); export const posts = createTable( "post", (columnBuilder) => ({ id: columnBuilder.integer().primaryKey().generatedByDefaultAsIdentity(), name: columnBuilder.varchar({ length: 256 }), createdById: columnBuilder.varchar({ length: 255 }).notNull(), createdAt: columnBuilder .timestamp({ withTimezone: true }) .$defaultFn(() => new Date()) .notNull(), updatedAt: columnBuilder .timestamp({ withTimezone: true }) .$onUpdate(() => new Date()), }), (t) => [ index("created_by_idx").on(t.createdById), index("name_idx").on(t.name), ], );