테이블 스키마
테이블 스키마
PostgreSQL
MySQL
SQLite
SingleStore
MSSQL
CockroachDB
스키마 내에서 엔티티를 선언하면, 쿼리 빌더는 쿼리에서 스키마 이름을 자동으로 앞에 붙입니다:
select * from "schema"."users"
import { serial, text, pgSchema } from "drizzle-orm/pg-core";
export const mySchema = pgSchema("my_schema");
export const colors = mySchema.enum('colors', ['red', 'green', 'blue']);
export const mySchemaUsers = mySchema.table('users', {
id: serial('id').primaryKey(),
name: text('name'),
color: colors('color').default('red'),
});
CREATE SCHEMA "my_schema";
CREATE TYPE "my_schema"."colors" AS ENUM ('red', 'green', 'blue');
CREATE TABLE "my_schema"."users" (
"id" serial PRIMARY KEY,
"name" text,
"color" "my_schema"."colors" DEFAULT 'red'
);