Is it normal for drizzle to generate SQLs without "IF NOT EXISTS"?
Hello! New user here.
Let's assume we have this simple schema:
After
It generates:
Notice that it's generating only
and not
Is it by design or am I missing something?
Let's assume we have this simple schema:
import {datetime, mysqlTable, varchar} from "drizzle-orm/mysql-core";
export const userTable = mysqlTable("user", {
id: varchar("id", {
length: 255
}).primaryKey()
});
export const userSessionTable = mysqlTable("user_session", {
id: varchar("id", {
length: 255
}).primaryKey(),
userId: varchar("user_id", {
length: 255
}).notNull(),
expiresAt: datetime("expires_at").notNull()
});import {datetime, mysqlTable, varchar} from "drizzle-orm/mysql-core";
export const userTable = mysqlTable("user", {
id: varchar("id", {
length: 255
}).primaryKey()
});
export const userSessionTable = mysqlTable("user_session", {
id: varchar("id", {
length: 255
}).primaryKey(),
userId: varchar("user_id", {
length: 255
}).notNull(),
expiresAt: datetime("expires_at").notNull()
});After
drizzle-kit generate:mysqldrizzle-kit generate:mysqlIt generates:
CREATE TABLE `user_session` (
`id` varchar(255) NOT NULL,
`user_id` varchar(255) NOT NULL,
`expires_at` datetime NOT NULL,
CONSTRAINT `user_session_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `user` (
`id` varchar(255) NOT NULL,
CONSTRAINT `user_id` PRIMARY KEY(`id`)
);CREATE TABLE `user_session` (
`id` varchar(255) NOT NULL,
`user_id` varchar(255) NOT NULL,
`expires_at` datetime NOT NULL,
CONSTRAINT `user_session_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `user` (
`id` varchar(255) NOT NULL,
CONSTRAINT `user_id` PRIMARY KEY(`id`)
);Notice that it's generating only
CREATE TABLECREATE TABLEand not
CREATE TABLE IF NOT EXISTSCREATE TABLE IF NOT EXISTSIs it by design or am I missing something?