Is it normal for drizzle to generate SQLs without "IF NOT EXISTS"?

Hello! New user here. 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:mysql
drizzle-kit generate:mysql
It 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 TABLE
CREATE TABLE
and not
CREATE TABLE IF NOT EXISTS
CREATE TABLE IF NOT EXISTS
Is it by design or am I missing something?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server