Liam
Liam
Explore posts from servers
DTDrizzle Team
Created by nightwatch128 on 11/10/2024 in #help
TypeError: client.migrate
Getting this aswell, did you find a solution?
3 replies
DTDrizzle Team
Created by Liam on 7/31/2024 in #help
There is not enough information to infer relation
5 replies
DTDrizzle Team
Created by Liam on 7/31/2024 in #help
There is not enough information to infer relation
The weird thing is that as far as I can tell this is a one-to-one relation, so much of the advice on other tables does not apply here
5 replies
DTDrizzle Team
Created by Liam on 7/8/2023 in #help
Drizzle-zod Include Relations
I did it like so if anyone needs it for future reference (cc @pudgereyem @shreddish )
const userValidator = createInsertSchema(users);

const userDataValidator = z.object({
data: createInsertSchema(data),
});

export const insertUserWithDataValidator = userValidator.merge(userDataValidator);
const userValidator = createInsertSchema(users);

const userDataValidator = z.object({
data: createInsertSchema(data),
});

export const insertUserWithDataValidator = userValidator.merge(userDataValidator);
You can also do it via extent, albeit with some wonky behaviours sometimes if you start adding in omits and what not
const userWithDataValidator = createInsertSchema(users).extend({
data: createInsertSchema(data)
});
const userWithDataValidator = createInsertSchema(users).extend({
data: createInsertSchema(data)
});
10 replies
DTDrizzle Team
Created by bun on 4/1/2024 in #help
dates in sqlite not being evaluated, causing "Invalid Date"
Hey OP, did you ever find a solution to this?
4 replies
DTDrizzle Team
Created by makaron pelnoziarnisty on 2/8/2024 in #help
Cannot read properties of undefined (reading 'columns')
beyond using the local server
5 replies
DTDrizzle Team
Created by makaron pelnoziarnisty on 2/8/2024 in #help
Cannot read properties of undefined (reading 'columns')
Hey did you ever wind up finding a fix for this?
5 replies
DTDrizzle Team
Created by Liam on 2/5/2024 in #help
Invalid Input Value for Enum
Update for anyone who finds this in the future, I went ahead and found the following article which I used to modify the migration. All seems to be working now! Article: https://www.munderwood.ca/index.php/2015/05/28/altering-postgresql-columns-from-one-enum-to-another/ New Migration:
DO $$ BEGIN
CREATE TYPE "discord_status" AS ENUM('pending', 'expired', 'accepted', 'rejected');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
CREATE TYPE "invite_status" AS ENUM('pending', 'accepted', 'declined');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "discord_verification" ALTER COLUMN "status" DROP DEFAULT;
ALTER TABLE "discord_verification" ALTER COLUMN "status" SET DATA TYPE discord_status USING "status"::text::discord_status;--> statement-breakpoint
ALTER TABLE "discord_verification" ALTER COLUMN "status" SET DEFAULT 'pending';
ALTER TABLE "invites" ALTER COLUMN "status" DROP DEFAULT;
ALTER TABLE "invites" ALTER COLUMN "status" SET DATA TYPE invite_status USING "status"::text::invite_status;
ALTER TABLE "invites" ALTER COLUMN "status" SET DEFAULT 'pending';
DO $$ BEGIN
CREATE TYPE "discord_status" AS ENUM('pending', 'expired', 'accepted', 'rejected');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
CREATE TYPE "invite_status" AS ENUM('pending', 'accepted', 'declined');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "discord_verification" ALTER COLUMN "status" DROP DEFAULT;
ALTER TABLE "discord_verification" ALTER COLUMN "status" SET DATA TYPE discord_status USING "status"::text::discord_status;--> statement-breakpoint
ALTER TABLE "discord_verification" ALTER COLUMN "status" SET DEFAULT 'pending';
ALTER TABLE "invites" ALTER COLUMN "status" DROP DEFAULT;
ALTER TABLE "invites" ALTER COLUMN "status" SET DATA TYPE invite_status USING "status"::text::invite_status;
ALTER TABLE "invites" ALTER COLUMN "status" SET DEFAULT 'pending';
5 replies
DTDrizzle Team
Created by Liam on 2/5/2024 in #help
Invalid Input Value for Enum
Hey @Angelelz! Apologies for the delay. I solved the first part, which is that I had 2 enums sharing the name status. I have now updated the name of it and the other enum that shared the name but am running into a issue applying this migration. I get the error: PostgresError: column "status" cannot be cast automatically to type discord_status Here is the migration:
DO $$ BEGIN
CREATE TYPE "discord_status" AS ENUM('pending', 'expired', 'accepted', 'rejected');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
CREATE TYPE "invite_status" AS ENUM('pending', 'accepted', 'declined');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "discord_verification" ALTER COLUMN "status" SET DATA TYPE discord_status;--> statement-breakpoint
ALTER TABLE "invites" ALTER COLUMN "status" SET DATA TYPE invite_status;
DO $$ BEGIN
CREATE TYPE "discord_status" AS ENUM('pending', 'expired', 'accepted', 'rejected');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
CREATE TYPE "invite_status" AS ENUM('pending', 'accepted', 'declined');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
ALTER TABLE "discord_verification" ALTER COLUMN "status" SET DATA TYPE discord_status;--> statement-breakpoint
ALTER TABLE "invites" ALTER COLUMN "status" SET DATA TYPE invite_status;
5 replies
DTDrizzle Team
Created by splashray on 6/6/2023 in #help
Invalid input value for enum
@splashray sorry to necro this but how did you solve it?
5 replies
DTDrizzle Team
Created by Liam on 7/29/2023 in #help
Cannot Access Primary Key on Table
The error:
Property 'id' does not exist on type 'MySqlTableWithColumns<{ name: "invites"; schema: undefined; columns: { inviteeID: MySqlVarChar<{ tableName: "invites"; enumValues: [string, ...string[]]; name: "invitee_id"; data: string; driverParam: string | number; hasDefault: false; notNull: true; }>; teamID: MySqlVarChar<...>; createdAt: MySqlTimestamp<...>; st...'.ts(2339)
Property 'id' does not exist on type 'MySqlTableWithColumns<{ name: "invites"; schema: undefined; columns: { inviteeID: MySqlVarChar<{ tableName: "invites"; enumValues: [string, ...string[]]; name: "invitee_id"; data: string; driverParam: string | number; hasDefault: false; notNull: true; }>; teamID: MySqlVarChar<...>; createdAt: MySqlTimestamp<...>; st...'.ts(2339)
4 replies
DTDrizzle Team
Created by Liam on 7/5/2023 in #help
Drizzle Count # of Records
Tried this, but count returns as a string for some reason?
const totalUserCount = await db.select({ count: sql<number>`count(*)` }).from(users);
const totalUserCount = await db.select({ count: sql<number>`count(*)` }).from(users);
7 replies
DTDrizzle Team
Created by Liam on 7/4/2023 in #help
Inserting with Relation
Ok, so would I just do the inserts sharing the same foreign keys?
4 replies