DT
Drizzle Team•16mo ago
OYΞD

Randomly stopped being able to generate migrations (MySQL)

Hey! Been trying things out the past day and everything was going great - until I deleted my migrations folder, attempted to re-generate migrations, and was met with 0 tables 🤣 I've killed-off all of my schema, except for one simple table, and ran generate:mysql with DEBUG;
> drizzle-kit "generate:mysql" "--schema" "orm/src/schema" "--out" "orm/migrations"

drizzle-kit: v0.17.1
drizzle-orm: v0.23.2

esbuild-register compiled /home/oyed/sites/teris/orm/src/schema/index.ts +0ms
esbuild-register const __esbuild_register_import_meta_url__ = require('url').pathToFileURL(__filename).href;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var schema_exports = {};
__export(schema_exports, {
guilds: () => guilds
});
module.exports = __toCommonJS(schema_exports);
var import_mysql_core = require("drizzle-orm/mysql-core");
const guilds = (0, import_mysql_core.mysqlTable)("guilds", {
id: (0, import_mysql_core.serial)("id").primaryKey(),
faction_id: (0, import_mysql_core.serial)("faction_id").notNull(),
user_id: (0, import_mysql_core.serial)("user_id").notNull(),
name: (0, import_mysql_core.varchar)("name", { length: 256 }).notNull(),
ticker: (0, import_mysql_core.varchar)("ticker", { length: 3 }).notNull(),
created_at: (0, import_mysql_core.timestamp)("created_at").defaultNow()
}, (table) => ({
factionIdIdx: (0, import_mysql_core.index)("faction_id_idx").on(table.faction_id),
userIdIdx: (0, import_mysql_core.uniqueIndex)("user_id_idx").on(table.user_id),
tickerIdx: (0, import_mysql_core.uniqueIndex)("ticker_idx").on(table.ticker)
}));
//# sourceMappingURL=[redacted so discord will let me post this in-line]
+1ms
0 tables


No schema changes, nothing to migrate 😴
> drizzle-kit "generate:mysql" "--schema" "orm/src/schema" "--out" "orm/migrations"

drizzle-kit: v0.17.1
drizzle-orm: v0.23.2

esbuild-register compiled /home/oyed/sites/teris/orm/src/schema/index.ts +0ms
esbuild-register const __esbuild_register_import_meta_url__ = require('url').pathToFileURL(__filename).href;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var schema_exports = {};
__export(schema_exports, {
guilds: () => guilds
});
module.exports = __toCommonJS(schema_exports);
var import_mysql_core = require("drizzle-orm/mysql-core");
const guilds = (0, import_mysql_core.mysqlTable)("guilds", {
id: (0, import_mysql_core.serial)("id").primaryKey(),
faction_id: (0, import_mysql_core.serial)("faction_id").notNull(),
user_id: (0, import_mysql_core.serial)("user_id").notNull(),
name: (0, import_mysql_core.varchar)("name", { length: 256 }).notNull(),
ticker: (0, import_mysql_core.varchar)("ticker", { length: 3 }).notNull(),
created_at: (0, import_mysql_core.timestamp)("created_at").defaultNow()
}, (table) => ({
factionIdIdx: (0, import_mysql_core.index)("faction_id_idx").on(table.faction_id),
userIdIdx: (0, import_mysql_core.uniqueIndex)("user_id_idx").on(table.user_id),
tickerIdx: (0, import_mysql_core.uniqueIndex)("ticker_idx").on(table.ticker)
}));
//# sourceMappingURL=[redacted so discord will let me post this in-line]
+1ms
0 tables


No schema changes, nothing to migrate 😴
So at the very least, the paths I'm giving seem to work fine, as it can transpile the schema + outputs a journal with zero entries under the migrations path
7 Replies
Andrii Sherman
Andrii Sherman•16mo ago
Could you send drizzle-kit version you are using?
OYΞD
OYΞD•16mo ago
v0.17.1
Andrii Sherman
Andrii Sherman•16mo ago
Oh sorry, it’s in message you’ve sent
alexblokh
alexblokh•16mo ago
@OYED hmm, I'm unable to reproduce, maybe we can hop on the call so you show me what you got we'll be able to trace the problem way faster
OYΞD
OYΞD•16mo ago
Sure thing - do you guys have a voice channel here or?
alexblokh
alexblokh•16mo ago
my headphones battery's dead, gimme 30 mins, I get to the office
OYΞD
OYΞD•16mo ago
Awesome, thanks 🙂 Seems @alexblokh found the issue - I was using drizzle-orm/expressions in a few different services in the monorepo, and installed drizzle-orm in to all of them to have access to that, which caused the issue After exporting the expressions from the same package that I store the schema & migrations in, removing the drizzle-orm dependency from every other package and (for good measure) re-generating the lockfile, it generates migrations perfectly fine! Thanks again @alexblokh 🙂
Want results from more Discord servers?
Add your server
More Posts