Anthony M.
Anthony M.
DTDrizzle Team
Created by Anthony M. on 12/12/2024 in #help
Problem with ENUMs PostgreSQL
Hey all! I've been having issues with Drizzle migrate and would like some support in regards of how to fix the issue, regardless of what I do I keep getting the following: [⣻] applying migrations...error: type "activity_log_activity_enum" already exists
4 replies
DTDrizzle Team
Created by Anthony M. on 11/21/2024 in #help
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),
//
}))
6 replies