feat(api): Implement /api/v1/markers

This commit is contained in:
Jesse Wierzbinski 2024-04-16 21:04:03 -10:00
parent 88b3ec7b43
commit bf0153627e
No known key found for this signature in database
8 changed files with 4039 additions and 0 deletions

View file

@ -0,0 +1,19 @@
CREATE TABLE IF NOT EXISTS "Markers" (
"id" uuid PRIMARY KEY DEFAULT uuid_generate_v7() NOT NULL,
"noteId" uuid,
"userId" uuid,
"timeline" text NOT NULL,
"created_at" timestamp(3) DEFAULT now() NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "Markers" ADD CONSTRAINT "Markers_noteId_Notes_id_fk" FOREIGN KEY ("noteId") REFERENCES "Notes"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "Markers" ADD CONSTRAINT "Markers_userId_Users_id_fk" FOREIGN KEY ("userId") REFERENCES "Users"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

View file

@ -0,0 +1,7 @@
ALTER TABLE "Markers" ALTER COLUMN "userId" SET NOT NULL;--> statement-breakpoint
ALTER TABLE "Markers" ADD COLUMN "notificationId" uuid;--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "Markers" ADD CONSTRAINT "Markers_notificationId_Notifications_id_fk" FOREIGN KEY ("notificationId") REFERENCES "Notifications"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -85,6 +85,20 @@
"when": 1713333611707,
"tag": "0011_special_the_fury",
"breakpoints": true
},
{
"idx": 12,
"version": "5",
"when": 1713336108114,
"tag": "0012_certain_thor_girl",
"breakpoints": true
},
{
"idx": 13,
"version": "5",
"when": 1713336611301,
"tag": "0013_wandering_celestials",
"breakpoints": true
}
]
}

View file

@ -26,6 +26,28 @@ export const Emojis = pgTable("Emojis", {
}),
});
export const Markers = pgTable("Markers", {
id: uuid("id").default(sql`uuid_generate_v7()`).primaryKey().notNull(),
noteId: uuid("noteId").references(() => Notes.id, {
onDelete: "cascade",
onUpdate: "cascade",
}),
notificationId: uuid("notificationId").references(() => Notifications.id, {
onDelete: "cascade",
onUpdate: "cascade",
}),
userId: uuid("userId")
.references(() => Users.id, {
onDelete: "cascade",
onUpdate: "cascade",
})
.notNull(),
timeline: text("timeline").notNull().$type<"home" | "notifications">(),
createdAt: timestamp("created_at", { precision: 3, mode: "string" })
.defaultNow()
.notNull(),
});
export const Likes = pgTable("Likes", {
id: uuid("id").default(sql`uuid_generate_v7()`).primaryKey().notNull(),
likerId: uuid("likerId")