refactor(database): 🚚 Rename "Attachment" to "Media"

This commit is contained in:
Jesse Wierzbinski 2025-01-23 16:08:42 +01:00
parent bbd56b600d
commit 2f61cd8f0a
No known key found for this signature in database
21 changed files with 2429 additions and 101 deletions

View file

@ -0,0 +1,4 @@
ALTER TABLE "Attachments" RENAME TO "Medias";--> statement-breakpoint
ALTER TABLE "Medias" DROP CONSTRAINT "Attachments_noteId_Notes_id_fk";
--> statement-breakpoint
ALTER TABLE "Medias" ADD CONSTRAINT "Medias_noteId_Notes_id_fk" FOREIGN KEY ("noteId") REFERENCES "public"."Notes"("id") ON DELETE cascade ON UPDATE cascade;

File diff suppressed because it is too large Load diff

View file

@ -288,6 +288,13 @@
"when": 1735776034097,
"tag": "0040_good_nocturne",
"breakpoints": true
},
{
"idx": 41,
"version": "7",
"when": 1737644734501,
"tag": "0041_bright_doctor_spectrum",
"breakpoints": true
}
]
}

View file

@ -303,7 +303,7 @@ export const Tokens = pgTable("Tokens", {
}),
});
export const Attachments = pgTable("Attachments", {
export const Medias = pgTable("Medias", {
id: id(),
url: text("url").notNull(),
remoteUrl: text("remote_url"),
@ -799,9 +799,9 @@ export const UserToPinnedNotes = pgTable(
],
);
export const AttachmentsRelations = relations(Attachments, ({ one }) => ({
export const AttachmentsRelations = relations(Medias, ({ one }) => ({
notes: one(Notes, {
fields: [Attachments.noteId],
fields: [Medias.noteId],
references: [Notes.id],
}),
}));
@ -894,7 +894,7 @@ export const NotesRelations = relations(Notes, ({ many, one }) => ({
references: [Users.id],
relationName: "NoteToAuthor",
}),
attachments: many(Attachments),
attachments: many(Medias),
mentions: many(NoteToMentions),
reblog: one(Notes, {
fields: [Notes.reblogId],