nicoalbanese / kirimase

Build full-stack Next.js apps, incredibly fast
https://kirimase.dev
MIT License
2.39k stars 107 forks source link

[Feature Request] Add CLI option to set a table name prefix when using Drizzle ORM #124

Open henrikvtcodes opened 5 months ago

henrikvtcodes commented 5 months ago

Is your feature request related to a problem? Please describe. I often find myself adding a database table name prefix when I set up projects, since I run a lot of my side projects on one database. Example:

import { mysqlTableCreator, bigint, varchar } from "drizzle-orm/mysql-core";

export const mysqlTable = mysqlTableCreator((name) => `project_${name}`);

export const users = mysqlTable("auth_user", {
  id: varchar("id", {
    length: 15,
  }).primaryKey(),
  // other user attributes
  name: varchar("name", { length: 255 }),
  email: varchar("email", { length: 255 }),
  username: varchar("username", { length: 255 }),
});

Describe the solution you'd like When the user selects Drizzle for their ORM, prompt for a prefix. If the user enters nothing, a prefix is not added. If they enter something, create a file like _table.ts in the schema folder which exports a custom mysqlTable/pgTable/sqliteTable function with the prefix. Additional context https://orm.drizzle.team/docs/goodies#multi-project-schema