refactor(database): 🚚 Rename Application to Client everywhere

This commit is contained in:
Jesse Wierzbinski 2025-08-21 01:21:32 +02:00
parent 6f97903f3b
commit 1a0a27bee1
No known key found for this signature in database
25 changed files with 2549 additions and 90 deletions

View file

@ -0,0 +1,15 @@
ALTER TABLE "Applications" RENAME TO "Clients";--> statement-breakpoint
ALTER TABLE "Notes" RENAME COLUMN "applicationId" TO "clientId";--> statement-breakpoint
ALTER TABLE "OpenIdLoginFlows" RENAME COLUMN "applicationId" TO "clientId";--> statement-breakpoint
ALTER TABLE "AuthorizationCodes" DROP CONSTRAINT "AuthorizationCodes_clientId_Applications_client_id_fk";
--> statement-breakpoint
ALTER TABLE "Notes" DROP CONSTRAINT "Notes_applicationId_Applications_client_id_fk";
--> statement-breakpoint
ALTER TABLE "OpenIdLoginFlows" DROP CONSTRAINT "OpenIdLoginFlows_applicationId_Applications_client_id_fk";
--> statement-breakpoint
ALTER TABLE "Tokens" DROP CONSTRAINT "Tokens_clientId_Applications_client_id_fk";
--> statement-breakpoint
ALTER TABLE "AuthorizationCodes" ADD CONSTRAINT "AuthorizationCodes_clientId_Clients_client_id_fk" FOREIGN KEY ("clientId") REFERENCES "public"."Clients"("client_id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "Notes" ADD CONSTRAINT "Notes_clientId_Clients_client_id_fk" FOREIGN KEY ("clientId") REFERENCES "public"."Clients"("client_id") ON DELETE set null ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "OpenIdLoginFlows" ADD CONSTRAINT "OpenIdLoginFlows_clientId_Clients_client_id_fk" FOREIGN KEY ("clientId") REFERENCES "public"."Clients"("client_id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "Tokens" ADD CONSTRAINT "Tokens_clientId_Clients_client_id_fk" FOREIGN KEY ("clientId") REFERENCES "public"."Clients"("client_id") ON DELETE cascade ON UPDATE cascade;

File diff suppressed because it is too large Load diff

View file

@ -365,6 +365,13 @@
"when": 1755729662013,
"tag": "0051_stiff_morbius",
"breakpoints": true
},
{
"idx": 52,
"version": "7",
"when": 1755732000165,
"tag": "0052_complete_hellfire_club",
"breakpoints": true
}
]
}

View file

@ -309,7 +309,7 @@ export const RelationshipsRelations = relations(Relationships, ({ one }) => ({
}),
}));
export const Clients = pgTable("Applications", {
export const Clients = pgTable("Clients", {
id: text("client_id").primaryKey(),
secret: text("secret").notNull(),
redirectUris: text("redirect_uris")
@ -494,7 +494,7 @@ export const Notes = pgTable("Notes", {
}),
sensitive: boolean("sensitive").notNull().default(false),
spoilerText: text("spoiler_text").default("").notNull(),
applicationId: text("applicationId").references(() => Clients.id, {
clientId: text("clientId").references(() => Clients.id, {
onDelete: "set null",
onUpdate: "cascade",
}),
@ -528,8 +528,8 @@ export const NotesRelations = relations(Notes, ({ many, one }) => ({
references: [Notes.id],
relationName: "NoteToQuotes",
}),
application: one(Clients, {
fields: [Notes.applicationId],
client: one(Clients, {
fields: [Notes.clientId],
references: [Clients.id],
}),
quotes: many(Notes, {
@ -703,7 +703,7 @@ export const OpenIdLoginFlows = pgTable("OpenIdLoginFlows", {
clientState: text("client_state"),
clientRedirectUri: text("client_redirect_uri"),
clientScopes: text("client_scopes").array(),
applicationId: text("applicationId").references(() => Clients.id, {
clientId: text("clientId").references(() => Clients.id, {
onDelete: "cascade",
onUpdate: "cascade",
}),
@ -713,8 +713,8 @@ export const OpenIdLoginFlows = pgTable("OpenIdLoginFlows", {
export const OpenIdLoginFlowsRelations = relations(
OpenIdLoginFlows,
({ one }) => ({
application: one(Clients, {
fields: [OpenIdLoginFlows.applicationId],
client: one(Clients, {
fields: [OpenIdLoginFlows.clientId],
references: [Clients.id],
}),
}),