“If does not exist” for migration schemes and add a column to an existing table

Hello, I'm new to Drizzle, and for a project with postgres and NextJS, I'd like, during a migration, to specify that schemas must not be recreated. db/schemas.ts:
import { pgSchema } from "drizzle-orm/pg-core";

export const myschema = pgSchema("schema_name");
import { pgSchema } from "drizzle-orm/pg-core";

export const myschema = pgSchema("schema_name");
db/myschema_schema/users.ts:
import { myschema } from "@/db/schemas/schemas";

export const users = myschema.table("users", {
import { myschema } from "@/db/schemas/schemas";

export const users = myschema.table("users", {
I'd also like to know how to update an existing table (just to add columns, just in case). Thanks in advance for your answers!
2 Replies
Virdrox
VirdroxOP2mo ago
🆙
Luxaritas
Luxaritas2mo ago
I think the better approach would instead be a way to mark a migration as already applied. You're liable to run into issues if you expect to be able to run migrations that have already been [partially] applied You can do this now by manually modifying the migrations table, but this is probably worth a feature request. I'm actually surprised I don't see a way to do this already (or an existing feature request) given I can't see it being that uncommon to introspect and then contiuing to manage the schema with drizzle-kit
Want results from more Discord servers?
Add your server