David L. Bowman
David L. Bowman
DTDrizzle Team
Created by David L. Bowman on 11/1/2024 in #help
Setting up drizzle.config.ts for AWS
For the life of me, I cannot figure this out.
import { defineConfig } from "drizzle-kit"

export default defineConfig({
schema: "drizzle/schema.ts",
out: "@/drizzle/migrations",
dialect: "postgresql",
driver: "aws-data-api",
dbCredentials: {
database: process.env.AWS_DATABASE_NAME,
secretArn: process.env.AWS_DATABASE_SECRET_ARN,
resourceArn: process.env.AWS_DATABASE_RESOURCE_ARN,
},
verbose: true,
})
import { defineConfig } from "drizzle-kit"

export default defineConfig({
schema: "drizzle/schema.ts",
out: "@/drizzle/migrations",
dialect: "postgresql",
driver: "aws-data-api",
dbCredentials: {
database: process.env.AWS_DATABASE_NAME,
secretArn: process.env.AWS_DATABASE_SECRET_ARN,
resourceArn: process.env.AWS_DATABASE_RESOURCE_ARN,
},
verbose: true,
})
I'm 100% confident all my credentials are correct. I get this in console.
~/c0de/modernmd on feature/awsRdsPostgresql !2 ?4 ❯ bunx drizzle-kit migrate at 21:28:29
No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/dlb/c0de/modernmd/drizzle.config.ts'
TypeError: Cannot destructure property 'resourceArn' of 'connection' as it is undefined.
at drizzle (/home/dlb/c0de/modernmd/node_modules/src/aws-data-api/pg/driver.ts:171:10)
at preparePostgresDB (/home/dlb/c0de/modernmd/node_modules/drizzle-kit/bin.cjs:65238:22)
at async Object.handler (/home/dlb/c0de/modernmd/node_modules/drizzle-kit/bin.cjs:88458:39)
at async run (/home/dlb/c0de/modernmd/node_modules/drizzle-kit/bin.cjs:86944:7)
~/c0de/modernmd on feature/awsRdsPostgresql !2 ?4 ❯ bunx drizzle-kit migrate at 21:28:29
No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/dlb/c0de/modernmd/drizzle.config.ts'
TypeError: Cannot destructure property 'resourceArn' of 'connection' as it is undefined.
at drizzle (/home/dlb/c0de/modernmd/node_modules/src/aws-data-api/pg/driver.ts:171:10)
at preparePostgresDB (/home/dlb/c0de/modernmd/node_modules/drizzle-kit/bin.cjs:65238:22)
at async Object.handler (/home/dlb/c0de/modernmd/node_modules/drizzle-kit/bin.cjs:88458:39)
at async run (/home/dlb/c0de/modernmd/node_modules/drizzle-kit/bin.cjs:86944:7)
7 replies
DTDrizzle Team
Created by David L. Bowman on 10/31/2024 in #help
Help Setting up Driver w/ AWS RDS
No description
5 replies
DTDrizzle Team
Created by David L. Bowman on 8/29/2024 in #help
`id` type is `undefined` when using `serial("id").primaryKey()`
No description
7 replies
DTDrizzle Team
Created by David L. Bowman on 8/26/2024 in #help
Formatting date_of_birth as MM-DD-YYYY
What's the best way of doing this? date_of_birth: varchar("date_of_birth", { length: 10 }).notNull() That's what I have so far, but I need it to be MM-DD-YYYY. It needs to be this way because of the API I need to sync with.
import { pgTable, serial, timestamp, varchar } from "drizzle-orm/pg-core"
import { createInsertSchema } from "drizzle-zod"
import type { z } from "zod"

export const users = pgTable("users", {
id: serial("id").primaryKey(),
email: varchar("email", { length: 255 }).notNull(),
phone: varchar("phone", { length: 10 }).notNull(),
first_name: varchar("first_name", { length: 255 }).notNull(),
middle_name: varchar("middle_name", { length: 255 }),
last_name: varchar("last_name", { length: 255 }).notNull(),
gender: varchar("gender", {
enum: ["male", "female", "other"],
}),
gender_biological: varchar("gender_biological", {
enum: ["male", "female"],
}).notNull(),
date_of_birth: varchar("date_of_birth", { length: 10 }).notNull(),
})

export const insertUserSchema = createInsertSchema(users)
export type User = z.infer<typeof insertUserSchema>
import { pgTable, serial, timestamp, varchar } from "drizzle-orm/pg-core"
import { createInsertSchema } from "drizzle-zod"
import type { z } from "zod"

export const users = pgTable("users", {
id: serial("id").primaryKey(),
email: varchar("email", { length: 255 }).notNull(),
phone: varchar("phone", { length: 10 }).notNull(),
first_name: varchar("first_name", { length: 255 }).notNull(),
middle_name: varchar("middle_name", { length: 255 }),
last_name: varchar("last_name", { length: 255 }).notNull(),
gender: varchar("gender", {
enum: ["male", "female", "other"],
}),
gender_biological: varchar("gender_biological", {
enum: ["male", "female"],
}).notNull(),
date_of_birth: varchar("date_of_birth", { length: 10 }).notNull(),
})

export const insertUserSchema = createInsertSchema(users)
export type User = z.infer<typeof insertUserSchema>
1 replies
DTDrizzle Team
Created by David L. Bowman on 5/6/2024 in #help
Changing `id` type from serial to uuid, causing error.
I'm sorry, I'm new to Drizzle, but I've read through the documentation and discord and cannot find a solution to my problem. I'm using Next.js 14, Postgresql through Vercel. When I first started, I built a test UsersTable but now I want to change the id from a serial to a uuid. Everytime I try to generate:pg it works, but push:pg fails, giving the following error:
error: column "id" cannot be cast automatically to type uuid
code: '42804',
hint: 'You might need to specify "USING id::uuid".',
error: column "id" cannot be cast automatically to type uuid
code: '42804',
hint: 'You might need to specify "USING id::uuid".',
Could you please tell me how I'm supposed to update my table?
import { pgTable, uuid, varchar, timestamp } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm"

export const UsersTable = pgTable("users", {
id: uuid("id").defaultRandom(),
firstName: varchar("first_name", { length: 50 }).notNull(),
lastName: varchar("last_name", { length: 50 }).notNull(),
email: varchar("email", { length: 100 }).notNull().unique(),
password: varchar("password", { length: 100 }).notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull()
})
import { pgTable, uuid, varchar, timestamp } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm"

export const UsersTable = pgTable("users", {
id: uuid("id").defaultRandom(),
firstName: varchar("first_name", { length: 50 }).notNull(),
lastName: varchar("last_name", { length: 50 }).notNull(),
email: varchar("email", { length: 100 }).notNull().unique(),
password: varchar("password", { length: 100 }).notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull()
})
82 replies