-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bun support with --bun
#199
Comments
can confirm facing this issue too, with plain './schema.ts' as input EDIT: Found a workaround to this by using module.export instead of esm exports |
spent too many hours on this before i search for this issue. |
I found another way to fix it. It's kind of working, but we can use First, go to And, change // bin.js:12048
prepareFromExports = (exports) => {
const tables = [];
const enums = [];
const schemas = [];
for(let e in exports) {
const t = exports[e];
if ((0, import_pg_core.isPgEnum)(t)) {
enums.push(t);
continue;
}
if ((0, import_drizzle_orm4.is)(t, import_pg_core.PgTable)) {
tables.push(t);
}
if ((0, import_drizzle_orm4.is)(t, import_pg_core.PgSchema)) {
schemas.push(t);
}
}
return { tables, enums, schemas };
}; Lastly, follow this comment to apply the change. The problem is that Bun's const schema = require('./db/schema.ts')
const exports = Object.values(schema) // [] and somehow for ... in can iterate the object even in Bun. |
it's works. |
@malvinpratama Unfortunately, drizzle kit is not an open source that we can't make a contrubution right away. But we can mention drizzle team to let them know about it. |
Looking forward to this fix! I only need to install node on my docker image so I can run drizzle-kit, everything else is already running with bun. |
@Angelelz Is there any way we could merge the fix proposed by @SnowMarble? |
For those having the same issue with sqlite, you can patch by changing // node_modules/drizzle-kit/bin.cjs: 12840
prepareFromSqliteImports = async (imports) => {
const tables = [];
const enums = [];
const { unregister } = await safeRegister();
for (let i = 0; i < imports.length; i++) {
const it = imports[i];
// const i0 = require(`${it}`); <-- does not work with --bun flag
const i0 = await import(`${it}`); // <-- this works with --bun
const i0values = Object.values(i0);
i0values.forEach((t) => {
if ((0, import_drizzle_orm6.is)(t, import_sqlite_core.SQLiteTable)) {
tables.push(t);
}
});
} Also, from instructions above:
bun i --yarn && bunx patch-package drizzle-kit
Thanks @SnowMarble for the fix! |
this problem still persists. |
I am trying to execute drizzle-kit commands using bun (instead of passing it off to
node
by way of the default shebang).For example:
or via
package.json
:When I do this, the command executes, but it cannot see my schema files. If I generated previously with node (ie, via the default shebang), and then with bun, it would generate a migration that drops all tables.
Output of the above command is always as if no schema files were present.
Drizzle Kit Config
Could it be because I am globbing the schema? Or, am I missing something?
Versions:
The text was updated successfully, but these errors were encountered: