Mohammed Anas
Mohammed Anas
Explore posts from servers
DTDrizzle Team
Created by Mohammed Anas on 9/28/2023 in #help
Drizzle kit schema migration with mysql ; Rerunning the entire schema
I use mysql2 as my database and when i run my migrate script "migrate": "drizzle-kit push:mysql --config drizzle.config.ts" this works fine but when i rerun my migrate script i get this error
Error: Duplicate key name 'company_id'
at PromiseConnection.query (/home/anasmohammed361/vs/fund-master/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/home/anasmohammed361/vs/fund-master/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53292:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ER_DUP_KEYNAME',
errno: 1061,
sql: 'CREATE INDEX `company_id` ON `company` (`id`);',
sqlState: '42000',
sqlMessage: "Duplicate key name 'company_id'"
Error: Duplicate key name 'company_id'
at PromiseConnection.query (/home/anasmohammed361/vs/fund-master/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:35481:26)
at Command.<anonymous> (/home/anasmohammed361/vs/fund-master/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53292:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ER_DUP_KEYNAME',
errno: 1061,
sql: 'CREATE INDEX `company_id` ON `company` (`id`);',
sqlState: '42000',
sqlMessage: "Duplicate key name 'company_id'"
3 replies
DTDrizzle Team
Created by Mohammed Anas on 8/18/2023 in #help
How do i insert a Enum value into a table
Basic Setup
export const userRoles = pgEnum('role', ['admin', 'maintainer']);
export const users = pgTable("userAuth", {
id: text("id").notNull().primaryKey(),
name: text("name"),
email: text("email").notNull().unique(),
emailVerified: timestamp("emailVerified"),
image: text("image"),
role:userRoles('role').default('maintainer').notNull()
});

export const userRoles = pgEnum('role', ['admin', 'maintainer']);
export const users = pgTable("userAuth", {
id: text("id").notNull().primaryKey(),
name: text("name"),
email: text("email").notNull().unique(),
emailVerified: timestamp("emailVerified"),
image: text("image"),
role:userRoles('role').default('maintainer').notNull()
});

await db.insert(users).values({
email:"a@a",
role:userRoles.enumValues[0],
id:"123"
})
await db.insert(users).values({
email:"a@a",
role:userRoles.enumValues[0],
id:"123"
})
I get this error
BadRequestException: ERROR: column "role" is of type role but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 125; SQLState: 42804
BadRequestException: ERROR: column "role" is of type role but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 125; SQLState: 42804
14 replies
DTDrizzle Team
Created by Mohammed Anas on 8/10/2023 in #help
Aws Rds with drizzle
My Schema on Aws Rds is not updating , once i update my schema and generate the schema , i am not getting any errors but still the migrations seems to fail , when i try to insert into that table BadRequestException: ERROR: relation "fuc" does not exist Position: 13; SQLState: 42P01 I get this
22 replies
DTDrizzle Team
Created by Mohammed Anas on 8/9/2023 in #help
Error with drizzle-kit generate:pg
Transforming const to the configured target environment ("es5") is not supported yet
7 replies