MySQL support

Hey 👋 I'm trying to use drizle kit migrate which is causing me a lot of issues I'd appreciate some support over this. (PART OF) SCHEMA:
export const user = mysqlTable('user', {
id: serial('id').primaryKey(),
discordId: varchar('discord_id', { length: 32 }).notNull(),
//
created: timestamp('created').default(sql`now()`).notNull(),
updated: timestamp('updated').default(sql`now()`).notNull()
}, (user) => ({
discordIdIndex: uniqueIndex('user_discord_id_idx').on(user.discordId),
seedIndex: index('user_seed_idx').on(user.seed),
cherryIndex: index('user_cherry_idx').on(user.cherry),
rubyIndex: index('user_ruby_idx').on(user.ruby),
createdIndex: index('user_created_idx').on(user.created),
updatedIndex: index('user_updated_idx').on(user.updated)
}))

export const userRelations = relations(user, ({ one, many }) => ({
level: one(userLevel),
//
inviteLog: many(userInviteLog, { relationName: 'inviteLogs' }),
}))

export const userInviteLog = mysqlTable('user_invite_log', {
id: serial('id').primaryKey(),
inviterId: varchar('inviter_id', { length: 32 }).references(() => user.discordId, { onDelete: 'cascade' }).notNull(),
inviteeId: varchar('invitee_id', { length: 32 }).references(() => user.discordId, { onDelete: 'cascade' }).notNull(),
joinedAt: timestamp('joined_at').default(sql`now()`).notNull(),
leftAt: timestamp('left_at'),
kickedAt: timestamp('kicked_at'),
bannedAt: timestamp('banned_at')
}, (userInviteLog) => ({
inviterIdIndex: index('user_invite_log_inviter_id_idx').on(userInviteLog.inviterId),
inviteeIdIndex: index('user_invite_log_invitee_id_idx').on(userInviteLog.inviteeId),
//
}))
export const user = mysqlTable('user', {
id: serial('id').primaryKey(),
discordId: varchar('discord_id', { length: 32 }).notNull(),
//
created: timestamp('created').default(sql`now()`).notNull(),
updated: timestamp('updated').default(sql`now()`).notNull()
}, (user) => ({
discordIdIndex: uniqueIndex('user_discord_id_idx').on(user.discordId),
seedIndex: index('user_seed_idx').on(user.seed),
cherryIndex: index('user_cherry_idx').on(user.cherry),
rubyIndex: index('user_ruby_idx').on(user.ruby),
createdIndex: index('user_created_idx').on(user.created),
updatedIndex: index('user_updated_idx').on(user.updated)
}))

export const userRelations = relations(user, ({ one, many }) => ({
level: one(userLevel),
//
inviteLog: many(userInviteLog, { relationName: 'inviteLogs' }),
}))

export const userInviteLog = mysqlTable('user_invite_log', {
id: serial('id').primaryKey(),
inviterId: varchar('inviter_id', { length: 32 }).references(() => user.discordId, { onDelete: 'cascade' }).notNull(),
inviteeId: varchar('invitee_id', { length: 32 }).references(() => user.discordId, { onDelete: 'cascade' }).notNull(),
joinedAt: timestamp('joined_at').default(sql`now()`).notNull(),
leftAt: timestamp('left_at'),
kickedAt: timestamp('kicked_at'),
bannedAt: timestamp('banned_at')
}, (userInviteLog) => ({
inviterIdIndex: index('user_invite_log_inviter_id_idx').on(userInviteLog.inviterId),
inviteeIdIndex: index('user_invite_log_invitee_id_idx').on(userInviteLog.inviteeId),
//
}))
3 Replies
Anthony M.
Anthony M.OP•3w ago
Angelelz
Angelelz•3w ago
I'm not sure we have official support for MariaDB I guess you can use mysql but at your own risk Seem like theres a problem with the enum, maybe MariaDb doesn't support or has a different syntax
Anthony M.
Anthony M.OP•3w ago
unrelated to enum, it was serial that was causing the issue, I fixed it by simply modifying the sql before migrating from serial to bigint UNSIGNED
Want results from more Discord servers?
Add your server