mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(api): ✨ Implement /api/v1/markers
This commit is contained in:
parent
88b3ec7b43
commit
bf0153627e
8 changed files with 4039 additions and 0 deletions
19
drizzle/0012_certain_thor_girl.sql
Normal file
19
drizzle/0012_certain_thor_girl.sql
Normal 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 $$;
|
||||
7
drizzle/0013_wandering_celestials.sql
Normal file
7
drizzle/0013_wandering_celestials.sql
Normal 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 $$;
|
||||
1829
drizzle/meta/0012_snapshot.json
Normal file
1829
drizzle/meta/0012_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
1848
drizzle/meta/0013_snapshot.json
Normal file
1848
drizzle/meta/0013_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue