hey there! is there any chance to get migrations from code instead of cli?

Hello, I'm currently using Drizzle ORM and I am wondering if there is a way to generate migrations from code instead of using the CLI. Here is a code snippet demonstrating what I'm trying to achieve:
import { db, } from './index';
import { generateDrizzleJson, generateMigration } from "drizzle-kit/payload";
import { products } from "./schema";
import { getTableConfig } from "drizzle-orm/pg-core";

const prev = generateDrizzleJson(db._.fullSchema)
const cur = generateDrizzleJson(getTableConfig(products), prev.id)
const migrations = await generateMigration(prev, cur)
console.log({
prev,
cur,
migrations,
})
import { db, } from './index';
import { generateDrizzleJson, generateMigration } from "drizzle-kit/payload";
import { products } from "./schema";
import { getTableConfig } from "drizzle-orm/pg-core";

const prev = generateDrizzleJson(db._.fullSchema)
const cur = generateDrizzleJson(getTableConfig(products), prev.id)
const migrations = await generateMigration(prev, cur)
console.log({
prev,
cur,
migrations,
})
In this example, I am trying to generate the migrations programmatically. Specifically, I am using the generateDrizzleJson and generateMigration functions to create the migration JSON objects and then log them to the console. Is there any official support or recommended way to handle migrations directly from the code like this? Or is the CLI the only supported method at the moment? Any guidance or examples would be greatly appreciated. Thank you!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server