Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit b84d308

Browse files
Humayun-23Naya Singhania
authored andcommitted
Requested changes are done
1 parent aeb2e92 commit b84d308

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

application/app/api/db/schema.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,23 @@ export const personas = pgTable("personas", {
2525
uid: uuid("uid").references(() => users.uid),
2626
});
2727

28+
export const groups = pgTable("groups", {
29+
id: uuid("id").primaryKey().defaultRandom(),
30+
name: text("name").notNull().unique(),
31+
});
32+
33+
export const groupMemberships = pgTable("group_memberships", {
34+
userId: uuid("user_id").references(() => users.uid).notNull(),
35+
groupId: uuid("group_id").references(() => groups.id).notNull(),
36+
}, (table: { userId: any; groupId: any; }) => ({
37+
pk: primaryKey(table.userId, table.groupId),
38+
}));
39+
2840
export type InsertUser = typeof users.$inferInsert;
2941
export type SelectUser = typeof users.$inferSelect;
3042

3143
export type InsertPersona = typeof personas.$inferInsert;
44+
function primaryKey(userId: any, groupId: any) {
45+
throw new Error("Function not implemented.");
46+
}
47+

application/supabase/migrations/0000_skinny_dark_beast.sql

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,7 @@ CREATE TABLE IF NOT EXISTS "users" (
1818
"name" text NOT NULL,
1919
"picture" text NOT NULL
2020
);
21-
--> statement-breakpoint
22-
CREATE TABLE IF NOT EXISTS "groups" (
23-
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
24-
"name" text NOT NULL UNIQUE
25-
);
26-
--> statement-breakpoint
27-
CREATE TABLE IF NOT EXISTS "group_memberships" (
28-
"user_id" uuid REFERENCES "users"("uid") ON DELETE CASCADE,
29-
"group_id" uuid REFERENCES "groups"("id") ON DELETE CASCADE,
30-
PRIMARY KEY ("user_id", "group_id")
31-
);
32-
--> statement-breakpoint
21+
3322
DO $$ BEGIN
3423
ALTER TABLE "personas" ADD CONSTRAINT "personas_uid_users_uid_fk" FOREIGN KEY ("uid") REFERENCES "public"."users"("uid") ON DELETE no action ON UPDATE no action;
3524
EXCEPTION

0 commit comments

Comments
 (0)