Table schemas
✓ PostgreSQL
✓ MySQL
✕ SQLite
Drizzle ORM provides you an API for declaring SQL schemas for PostgreSQL and MySQL dialects
If you declare table within a schema - query builder will prepend schema names in queries select * from "schema"."users"
import { serial, text, pgTable, pgSchema } from "drizzle-orm/pg-core";
export const mySchema = pgSchema("my_schema")
export const mySchemaUsers = mySchema.table('users', {
id: serial('id').primaryKey(),
name: text('name'),
});
CREATE SCHEMA "my_schema";
CREATE TABLE "my_schema"."users" (
"id" serial PRIMARY KEY,
"name" text
);