Programmatically create database tables from schema

Is there a way to tell drizzle to just create all of the tables from my schema? I don't need the full drizzle kit migrations setup because I'm using SQLite for a read-only data store so whenever the schema changes the database is going to be fully recreated anyway. If I need to make my script create the tables, how could I go about generating the table creation queries from the drizzle schema?
Solution:
this seems to work ```ts import { generateSQLiteDrizzleJson, generateSQLiteMigration } from "drizzle-kit/api"; const migration = await generateSQLiteMigration(...
Jump to solution
1 Reply
Solution
psm
psm3mo ago
this seems to work
import { generateSQLiteDrizzleJson, generateSQLiteMigration } from "drizzle-kit/api";

const migration = await generateSQLiteMigration(
await generateSQLiteDrizzleJson({}),
await generateSQLiteDrizzleJson(schema, undefined, "snake_case")
);
for (const query of migration) {
db.run(query);
}
import { generateSQLiteDrizzleJson, generateSQLiteMigration } from "drizzle-kit/api";

const migration = await generateSQLiteMigration(
await generateSQLiteDrizzleJson({}),
await generateSQLiteDrizzleJson(schema, undefined, "snake_case")
);
for (const query of migration) {
db.run(query);
}

Did you find this page helpful?