Replies: 1 comment
-
this is the syntax that works for me: export const User = AppSchema.table(
'user',
{
id: varchar(),
name: varchar().notNull(),
email: varchar().notNull(),
createdAt: timestamp().defaultNow().notNull(),
updatedAt: timestamp().defaultNow().notNull(),
},
table => {
return [
primaryKey({ name: 'custom_name', columns: [table.id, table.email] }),
];
},
); it generates the following migration: CREATE SCHEMA "app";
--> statement-breakpoint
CREATE TABLE "app"."user" (
"id" varchar,
"name" varchar NOT NULL,
"email" varchar NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "custom_name" PRIMARY KEY("id","email")
);
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
I defined Composite Primary Key and generate magration file, but primary constraint are nowhere to be found.
Is this a bug?
If you have a different way of defining it, I would love to know.
package versions
[email protected]
[email protected]
[email protected]
schema.ts
drizzle/0000_migration.sql
drizzle.config.ts
Beta Was this translation helpful? Give feedback.
All reactions