'tonyyprints'
Explore posts from serversDTDrizzle Team
•Created by 'tonyyprints' on 6/12/2024 in #help
Migrations taking the first snapshot
This is the error I'm getting.
Error: Table 'Blocked' already exists
at PromiseConnection.query (C:\Users\ghait\WebstormProjects\oppfy\node_modules\mysql2\promise.js:94:22)
at MySql2PreparedQuery.execute (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql2\session.ts:85:18)
at MySql2Session.execute (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql-core\session.ts:81:5)
at MySql2Transaction.execute (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql-core\db.ts:456:23)
at <anonymous> (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql-core\dialect.ts:62:16)
at MySql2Session.transaction (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql2\session.ts:247:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at MySqlDialect.migrate (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql-core\dialect.ts:55:3)
at migrate (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql2\migrator.ts:10:2)
at <anonymous> (c:\Users\ghait\WebstormProjects\oppfy\packages\db\migrate.ts:8:1) {
code: 'ER_TABLE_EXISTS_ERROR',
errno: 1050,
sql: 'CREATE TABLE `Blocked` (\n' +
'\t`id` serial AUTO_INCREMENT NOT NULL,\n' +
'\t`userId` varchar(255) NOT NULL,\n' +
'\t`blockedUserId` varchar(255) NOT NULL,\n' +
'\t`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n' +
'\tCONSTRAINT `Blocked_id` PRIMARY KEY(`id`)\n' +
');\n',
sqlState: '42S01',
sqlMessage: "Table 'Blocked' already exists"
}
Error: Table 'Blocked' already exists
at PromiseConnection.query (C:\Users\ghait\WebstormProjects\oppfy\node_modules\mysql2\promise.js:94:22)
at MySql2PreparedQuery.execute (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql2\session.ts:85:18)
at MySql2Session.execute (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql-core\session.ts:81:5)
at MySql2Transaction.execute (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql-core\db.ts:456:23)
at <anonymous> (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql-core\dialect.ts:62:16)
at MySql2Session.transaction (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql2\session.ts:247:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at MySqlDialect.migrate (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql-core\dialect.ts:55:3)
at migrate (C:\Users\ghait\WebstormProjects\oppfy\node_modules\src\mysql2\migrator.ts:10:2)
at <anonymous> (c:\Users\ghait\WebstormProjects\oppfy\packages\db\migrate.ts:8:1) {
code: 'ER_TABLE_EXISTS_ERROR',
errno: 1050,
sql: 'CREATE TABLE `Blocked` (\n' +
'\t`id` serial AUTO_INCREMENT NOT NULL,\n' +
'\t`userId` varchar(255) NOT NULL,\n' +
'\t`blockedUserId` varchar(255) NOT NULL,\n' +
'\t`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n' +
'\tCONSTRAINT `Blocked_id` PRIMARY KEY(`id`)\n' +
');\n',
sqlState: '42S01',
sqlMessage: "Table 'Blocked' already exists"
}
2 replies
DTDrizzle Team
•Created by michaelhedgpeth on 4/25/2024 in #help
Not clear what happens during migrate
any chance you found an answer elsewhere?
4 replies
DTDrizzle Team
•Created by 'tonyyprints' on 3/24/2024 in #help
bigint is not a number
ohhhhh that makes so much sense. Thank you. Just replaced all instances to number and it works 🙏
7 replies
DTDrizzle Team
•Created by 'tonyyprints' on 3/24/2024 in #help
bigint is not a number
happy to:
export const user = mySqlTable("User", {
id: varchar("id", {length: 255}).primaryKey(),
// email: varchar("email", { length: 255 }).unique().notNull(),
name: varchar("name", { length: 255 }),
dateOfBirth: date("dateOfBirth"),
profileId: bigint("profileId", {mode: "bigint", unsigned: true}).references(() => profile.id),
notificationSetting: bigint("notificationSetting", {mode: "bigint", unsigned: true}).references(
() => notificationSetting.id,
),
createdAt: timestamp("createdAt")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt").onUpdateNow(),
});
export const userRelations = relations(user, ({ one }) => ({
profile: one(profile, {
fields: [user.profileId],
references: [profile.id],
}),
notificationSetting: one(notificationSetting, {
fields: [user.notificationSetting],
references: [notificationSetting.id],
}),
}));
export const user = mySqlTable("User", {
id: varchar("id", {length: 255}).primaryKey(),
// email: varchar("email", { length: 255 }).unique().notNull(),
name: varchar("name", { length: 255 }),
dateOfBirth: date("dateOfBirth"),
profileId: bigint("profileId", {mode: "bigint", unsigned: true}).references(() => profile.id),
notificationSetting: bigint("notificationSetting", {mode: "bigint", unsigned: true}).references(
() => notificationSetting.id,
),
createdAt: timestamp("createdAt")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt").onUpdateNow(),
});
export const userRelations = relations(user, ({ one }) => ({
profile: one(profile, {
fields: [user.profileId],
references: [profile.id],
}),
notificationSetting: one(notificationSetting, {
fields: [user.notificationSetting],
references: [notificationSetting.id],
}),
}));
7 replies
DTDrizzle Team
•Created by 'tonyyprints' on 3/24/2024 in #help
bigint is not a number
This is where profile comes from. profileId should be the serial index of the row
const profile = await ctx.db.query.user.findFirst({
where: eq(schema.user.id, input.metadata.id),
columns: {
profileId: true,
},
});
if (!profile?.profileId) {
// For now, assume a profile is always created in the auth flow
throw new TRPCError({message: "User profile not found", code: "NOT_FOUND"});
}
const profile = await ctx.db.query.user.findFirst({
where: eq(schema.user.id, input.metadata.id),
columns: {
profileId: true,
},
});
if (!profile?.profileId) {
// For now, assume a profile is always created in the auth flow
throw new TRPCError({message: "User profile not found", code: "NOT_FOUND"});
}
7 replies