mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(database): ♻️ Move Note <-> Media relations to a many-to-many model instead of one-to-many
This commit is contained in:
parent
9c30dacda7
commit
3216fc339a
7 changed files with 2428 additions and 31 deletions
26
drizzle/migrations/0042_swift_the_phantom.sql
Normal file
26
drizzle/migrations/0042_swift_the_phantom.sql
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
CREATE TABLE "MediasToNote" (
|
||||
"mediaId" uuid NOT NULL,
|
||||
"noteId" uuid NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP CONSTRAINT "Medias_noteId_Notes_id_fk";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "Medias" ADD COLUMN "content" jsonb NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "Medias" ADD COLUMN "original_content" jsonb;--> statement-breakpoint
|
||||
ALTER TABLE "Medias" ADD COLUMN "thumbnail" jsonb;--> statement-breakpoint
|
||||
ALTER TABLE "MediasToNote" ADD CONSTRAINT "MediasToNote_mediaId_Medias_id_fk" FOREIGN KEY ("mediaId") REFERENCES "public"."Medias"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
|
||||
ALTER TABLE "MediasToNote" ADD CONSTRAINT "MediasToNote_noteId_Notes_id_fk" FOREIGN KEY ("noteId") REFERENCES "public"."Notes"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
|
||||
CREATE INDEX "MediasToNote_mediaId_index" ON "MediasToNote" USING btree ("mediaId");--> statement-breakpoint
|
||||
CREATE INDEX "MediasToNote_noteId_index" ON "MediasToNote" USING btree ("noteId");--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "url";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "remote_url";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "thumbnail_url";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "mime_type";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "description";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "sha256";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "fps";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "duration";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "width";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "height";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "size";--> statement-breakpoint
|
||||
ALTER TABLE "Medias" DROP COLUMN "noteId";
|
||||
2334
drizzle/migrations/meta/0042_snapshot.json
Normal file
2334
drizzle/migrations/meta/0042_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -295,6 +295,13 @@
|
|||
"when": 1737644734501,
|
||||
"tag": "0041_bright_doctor_spectrum",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 42,
|
||||
"version": "7",
|
||||
"when": 1737660317024,
|
||||
"tag": "0042_swift_the_phantom",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue