MySQL Table Schemas
I need to generate the following structure of tables:
Currently if I use what the docs say regarding the configuration of schemas, when I run
What I'm looking for is not to create a database for each tenant but only create their set of tables.
This is my schema definition:
Could someone please help me and point me in the right direction? Thanks in advance
1. Sales
2.Sales
....Currently if I use what the docs say regarding the configuration of schemas, when I run
drizzle-kit generate:mysql I get the following sql file:CREATE DATABASE 127;
--> statement-breakpoint
CREATE TABLE 127.sales (
id int AUTO_INCREMENT NOT NULL,
double double DEFAULT 0,
CONSTRAINT sales_id PRIMARY KEY(id)
);What I'm looking for is not to create a database for each tenant but only create their set of tables.
This is my schema definition:
import { mysqlTable, int, double, mysqlSchema } from "drizzle-orm/mysql-core";
export const mySchema = mysqlSchema("dynamic_value_here")
export const sales = mySchema.table("sales", {
id: int("id").primaryKey().autoincrement(),
total_price_dlrs: double("double").default(0),
});
export type Sale = typeof sales.$inferSelect;
export type NewSale = typeof sales.$inferInsert;Could someone please help me and point me in the right direction? Thanks in advance