© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
11 replies
rfrancociavaldini

MySQL Table Schemas

I need to generate the following structure of tables:

1. Sales
2.Sales
....
1. Sales
2.Sales
....


Currently if I use what the docs say regarding the configuration of schemas, when I run
drizzle-kit generate:mysql
drizzle-kit generate:mysql
I get the following sql file:

CREATE DATABASE 
CREATE DATABASE 
127
;
--> statement-breakpoint
CREATE TABLE 
;
--> statement-breakpoint
CREATE TABLE 
127
.
.
sales
 (
    
 (
    
id
 int AUTO_INCREMENT NOT NULL,
    
 int AUTO_INCREMENT NOT NULL,
    
double
 double DEFAULT 0,
    CONSTRAINT 
 double DEFAULT 0,
    CONSTRAINT 
sales_id
 PRIMARY KEY(
 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;
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
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to define schemas for friendship table
Drizzle TeamDTDrizzle Team / help
3y ago
drizzle kit generate schemas for mysql had a little type mismatched problem.
Drizzle TeamDTDrizzle Team / help
2y ago
drizzle bug won't let me update mysql table
Drizzle TeamDTDrizzle Team / help
3y ago
Multi-File Schemas
Drizzle TeamDTDrizzle Team / help
3y ago