From 1a0a27bee1a8db102d4648147de7b76e568c951b Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Thu, 21 Aug 2025 01:21:32 +0200 Subject: [PATCH] refactor(database): :truck: Rename Application to Client everywhere --- cli/user/token.ts | 4 +- drizzle.config.ts | 10 +- .../api/routes/api/auth/login/index.test.ts | 6 +- packages/api/routes/api/auth/login/index.ts | 4 +- packages/api/routes/api/v1/apps/index.ts | 4 +- .../api/v1/apps/verify_credentials/index.ts | 4 +- packages/api/routes/api/v1/sso/index.ts | 6 +- packages/api/routes/api/v1/statuses/index.ts | 2 +- packages/api/routes/oauth.test.ts | 6 +- packages/api/routes/oauth/revoke.test.ts | 4 +- .../api/routes/oauth/sso/[issuer]/callback.ts | 18 +- .../api/routes/oauth/sso/[issuer]/index.ts | 6 +- packages/api/routes/oauth/token.test.ts | 4 +- packages/api/routes/oauth/token.ts | 4 +- packages/kit/api.ts | 4 +- packages/kit/db/application.ts | 48 +- packages/kit/db/index.ts | 2 +- packages/kit/db/note.ts | 12 +- packages/kit/db/token.ts | 4 +- .../0052_complete_hellfire_club.sql | 15 + .../tables/migrations/meta/0052_snapshot.json | 2439 +++++++++++++++++ .../kit/tables/migrations/meta/_journal.json | 7 + packages/kit/tables/schema.ts | 14 +- packages/tests/index.ts | 8 +- types/api.ts | 4 +- 25 files changed, 2549 insertions(+), 90 deletions(-) create mode 100644 packages/kit/tables/migrations/0052_complete_hellfire_club.sql create mode 100644 packages/kit/tables/migrations/meta/0052_snapshot.json diff --git a/cli/user/token.ts b/cli/user/token.ts index d65f364c..6e1109e0 100644 --- a/cli/user/token.ts +++ b/cli/user/token.ts @@ -1,4 +1,4 @@ -import { Application, Token } from "@versia-server/kit/db"; +import { Client, Token } from "@versia-server/kit/db"; import { randomUUIDv7 } from "bun"; import chalk from "chalk"; // @ts-expect-error - Root import is required or the Clec type definitions won't work @@ -22,7 +22,7 @@ export const generateTokenCommand = defineCommand( throw new Error(`User ${chalk.gray(username)} not found.`); } - const application = await Application.insert({ + const application = await Client.insert({ id: user.id + Buffer.from( diff --git a/drizzle.config.ts b/drizzle.config.ts index faa519fe..7aaaacaf 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -1,4 +1,4 @@ -//import { config } from "@versia-server/config"; +import { config } from "@versia-server/config"; import type { Config } from "drizzle-kit"; /** @@ -10,16 +10,16 @@ export default { out: "./packages/kit/tables/migrations", schema: "./packages/kit/tables/schema.ts", dbCredentials: { - host: "localhost", + /* host: "localhost", port: 40000, user: "lysand", password: "lysand", - database: "lysand", - /* host: config.postgres.host, + database: "lysand", */ + host: config.postgres.host, port: config.postgres.port, user: config.postgres.username, password: config.postgres.password, - database: config.postgres.database, */ + database: config.postgres.database, }, // Print all statements verbose: true, diff --git a/packages/api/routes/api/auth/login/index.test.ts b/packages/api/routes/api/auth/login/index.test.ts index 5dc4c705..dc0f08c0 100644 --- a/packages/api/routes/api/auth/login/index.test.ts +++ b/packages/api/routes/api/auth/login/index.test.ts @@ -1,15 +1,15 @@ import { afterAll, describe, expect, test } from "bun:test"; import { config } from "@versia-server/config"; -import { Application } from "@versia-server/kit/db"; +import { Client } from "@versia-server/kit/db"; import { fakeRequest, getTestUsers } from "@versia-server/tests"; import { randomString } from "@/math"; const { users, deleteUsers, passwords } = await getTestUsers(1); // Create application -const application = await Application.insert({ +const application = await Client.insert({ id: randomString(32, "hex"), - name: "Test Application", + name: "Test Client", secret: "test", redirectUris: ["https://example.com"], scopes: ["read", "write"], diff --git a/packages/api/routes/api/auth/login/index.ts b/packages/api/routes/api/auth/login/index.ts index 5d74a943..f953fc0d 100644 --- a/packages/api/routes/api/auth/login/index.ts +++ b/packages/api/routes/api/auth/login/index.ts @@ -1,7 +1,7 @@ import { config } from "@versia-server/config"; import { ApiError } from "@versia-server/kit"; import { apiRoute, handleZodError } from "@versia-server/kit/api"; -import { Application, User } from "@versia-server/kit/db"; +import { Client, User } from "@versia-server/kit/db"; import { Users } from "@versia-server/kit/tables"; import { password as bunPassword } from "bun"; import { eq, or } from "drizzle-orm"; @@ -156,7 +156,7 @@ export default apiRoute((app) => config.authentication.key, ); - const application = await Application.fromClientId(client_id); + const application = await Client.fromClientId(client_id); if (!application) { throw new ApiError(400, "Invalid application"); diff --git a/packages/api/routes/api/v1/apps/index.ts b/packages/api/routes/api/v1/apps/index.ts index 818a93b1..b8f6fb29 100644 --- a/packages/api/routes/api/v1/apps/index.ts +++ b/packages/api/routes/api/v1/apps/index.ts @@ -4,7 +4,7 @@ import { } from "@versia/client/schemas"; import { ApiError } from "@versia-server/kit"; import { apiRoute, handleZodError, jsonOrForm } from "@versia-server/kit/api"; -import { Application } from "@versia-server/kit/db"; +import { Client } from "@versia-server/kit/db"; import { describeRoute, resolver, validator } from "hono-openapi"; import { z } from "zod/v4"; import { randomString } from "@/math"; @@ -62,7 +62,7 @@ export default apiRoute((app) => const { client_name, redirect_uris, scopes, website } = context.req.valid("json"); - const app = await Application.insert({ + const app = await Client.insert({ id: randomString(32, "base64url"), name: client_name, redirectUris: Array.isArray(redirect_uris) diff --git a/packages/api/routes/api/v1/apps/verify_credentials/index.ts b/packages/api/routes/api/v1/apps/verify_credentials/index.ts index 9f42f8dd..336f94ad 100644 --- a/packages/api/routes/api/v1/apps/verify_credentials/index.ts +++ b/packages/api/routes/api/v1/apps/verify_credentials/index.ts @@ -4,7 +4,7 @@ import { } from "@versia/client/schemas"; import { ApiError } from "@versia-server/kit"; import { apiRoute, auth } from "@versia-server/kit/api"; -import { Application } from "@versia-server/kit/db"; +import { Client } from "@versia-server/kit/db"; import { describeRoute, resolver } from "hono-openapi"; export default apiRoute((app) => @@ -38,7 +38,7 @@ export default apiRoute((app) => async (context) => { const { token } = context.get("auth"); - const application = await Application.getFromToken( + const application = await Client.getFromToken( token.data.accessToken, ); diff --git a/packages/api/routes/api/v1/sso/index.ts b/packages/api/routes/api/v1/sso/index.ts index c1fb1af3..0f88bfe4 100644 --- a/packages/api/routes/api/v1/sso/index.ts +++ b/packages/api/routes/api/v1/sso/index.ts @@ -2,7 +2,7 @@ import { RolePermission } from "@versia/client/schemas"; import { config } from "@versia-server/config"; import { ApiError } from "@versia-server/kit"; import { apiRoute, auth, handleZodError } from "@versia-server/kit/api"; -import { Application, db } from "@versia-server/kit/db"; +import { Client, db } from "@versia-server/kit/db"; import { OpenIdLoginFlows } from "@versia-server/kit/tables"; import { randomUUIDv7 } from "bun"; import { describeRoute, resolver, validator } from "hono-openapi"; @@ -123,7 +123,7 @@ export default apiRoute((app) => { issuerId, ); - const application = await Application.insert({ + const application = await Client.insert({ id: user.id + Buffer.from( @@ -144,7 +144,7 @@ export default apiRoute((app) => { codeVerifier, state: parameters.state, issuerId, - applicationId: application.id, + clientId: application.id, }) .returning() )[0]; diff --git a/packages/api/routes/api/v1/statuses/index.ts b/packages/api/routes/api/v1/statuses/index.ts index 7b2a52ca..cbd97496 100644 --- a/packages/api/routes/api/v1/statuses/index.ts +++ b/packages/api/routes/api/v1/statuses/index.ts @@ -249,7 +249,7 @@ export default apiRoute((app) => spoilerText: sanitizedSpoilerText, replyId: in_reply_to_id ?? undefined, quotingId: quote_id ?? undefined, - applicationId: application?.id, + clientId: application?.id, contentSource: status, contentType: content_type, }); diff --git a/packages/api/routes/oauth.test.ts b/packages/api/routes/oauth.test.ts index 153647a2..66f79e4e 100644 --- a/packages/api/routes/oauth.test.ts +++ b/packages/api/routes/oauth.test.ts @@ -13,10 +13,10 @@ afterAll(async () => { }); describe("Login flow", () => { - test("should create an application", async () => { + test("should create a client", async () => { const client = await generateClient(users[0]); - const { ok, data } = await client.createApp("Test Application", { + const { ok, data } = await client.createApp("Test Client", { redirect_uris: "https://example.com", website: "https://example.com", scopes: ["read", "write"], @@ -24,7 +24,7 @@ describe("Login flow", () => { expect(ok).toBe(true); expect(data).toEqual({ - name: "Test Application", + name: "Test Client", website: "https://example.com", client_id: expect.any(String), client_secret: expect.any(String), diff --git a/packages/api/routes/oauth/revoke.test.ts b/packages/api/routes/oauth/revoke.test.ts index e7d19afb..836c514b 100644 --- a/packages/api/routes/oauth/revoke.test.ts +++ b/packages/api/routes/oauth/revoke.test.ts @@ -1,11 +1,11 @@ import { afterAll, describe, expect, test } from "bun:test"; -import { Application, Token } from "@versia-server/kit/db"; +import { Client, Token } from "@versia-server/kit/db"; import { fakeRequest, getTestUsers } from "@versia-server/tests"; import { randomUUIDv7 } from "bun"; const { deleteUsers, users } = await getTestUsers(1); -const application = await Application.insert({ +const application = await Client.insert({ id: randomUUIDv7(), redirectUris: ["https://example.com/callback"], scopes: ["openid", "profile", "email"], diff --git a/packages/api/routes/oauth/sso/[issuer]/callback.ts b/packages/api/routes/oauth/sso/[issuer]/callback.ts index 7cf1757e..c3a23e50 100644 --- a/packages/api/routes/oauth/sso/[issuer]/callback.ts +++ b/packages/api/routes/oauth/sso/[issuer]/callback.ts @@ -69,7 +69,7 @@ export default apiRoute((app) => { const flow = await db.query.OpenIdLoginFlows.findFirst({ where: (flow): SQL | undefined => eq(flow.id, flowId), with: { - application: true, + client: true, }, }); @@ -129,11 +129,11 @@ export default apiRoute((app) => { // If linking account if (link && user_id) { // Check if userId is equal to application.clientId - if (!flow.application?.id.startsWith(user_id)) { + if (!flow.client?.id.startsWith(user_id)) { return redirectWithMessage( { oidc_account_linking_error: "Account linking error", - oidc_account_linking_error_message: `User ID does not match application client ID (${user_id} != ${flow.application?.id})`, + oidc_account_linking_error_message: `User ID does not match application client ID (${user_id} != ${flow.client?.id})`, }, config.frontend.routes.home, ); @@ -262,14 +262,14 @@ export default apiRoute((app) => { }); } - if (!flow.application) { + if (!flow.client) { throw new ApiError(500, "Application not found"); } const code = randomString(32, "hex"); await db.insert(AuthorizationCodes).values({ - clientId: flow.application.id, + clientId: flow.client.id, code, expiresAt: new Date(Date.now() + 60 * 1000).toISOString(), // 1 minute redirectUri: flow.clientRedirectUri ?? undefined, @@ -281,7 +281,7 @@ export default apiRoute((app) => { { sub: user.id, iss: new URL(context.get("config").http.base_url).origin, - aud: flow.application.id, + aud: flow.client.id, exp: Math.floor(Date.now() / 1000) + 60 * 60, iat: Math.floor(Date.now() / 1000), nbf: Math.floor(Date.now() / 1000), @@ -303,9 +303,9 @@ export default apiRoute((app) => { { redirect_uri: flow.clientRedirectUri ?? undefined, code, - client_id: flow.application.id, - application: flow.application.name, - website: flow.application.website ?? "", + client_id: flow.client.id, + application: flow.client.name, + website: flow.client.website ?? "", scope: flow.clientScopes?.join(" "), state: flow.clientState ?? undefined, }, diff --git a/packages/api/routes/oauth/sso/[issuer]/index.ts b/packages/api/routes/oauth/sso/[issuer]/index.ts index 4b4bf9df..79eb7ec5 100644 --- a/packages/api/routes/oauth/sso/[issuer]/index.ts +++ b/packages/api/routes/oauth/sso/[issuer]/index.ts @@ -1,7 +1,7 @@ import { config } from "@versia-server/config"; import { ApiError } from "@versia-server/kit"; import { apiRoute, handleZodError } from "@versia-server/kit/api"; -import { Application, db } from "@versia-server/kit/db"; +import { Client, db } from "@versia-server/kit/db"; import { OpenIdLoginFlows } from "@versia-server/kit/tables"; import { randomUUIDv7 } from "bun"; import { describeRoute, validator } from "hono-openapi"; @@ -54,7 +54,7 @@ export default apiRoute((app) => { throw new ApiError(422, "Unknown or invalid issuer"); } - const application = await Application.fromClientId(client_id); + const application = await Client.fromClientId(client_id); if (!application) { throw new ApiError(422, "Unknown or invalid client_id"); @@ -98,7 +98,7 @@ export default apiRoute((app) => { clientState: state, clientRedirectUri: redirect_uri, clientScopes: scopes, - applicationId: application.id, + clientId: application.id, issuerId, }) .returning() diff --git a/packages/api/routes/oauth/token.test.ts b/packages/api/routes/oauth/token.test.ts index ebba81ff..d0dd74c1 100644 --- a/packages/api/routes/oauth/token.test.ts +++ b/packages/api/routes/oauth/token.test.ts @@ -1,5 +1,5 @@ import { afterAll, describe, expect, test } from "bun:test"; -import { Application, db } from "@versia-server/kit/db"; +import { Client, db } from "@versia-server/kit/db"; import { fakeRequest, getTestUsers } from "@versia-server/tests"; import { randomUUIDv7 } from "bun"; import { eq } from "drizzle-orm"; @@ -8,7 +8,7 @@ import { AuthorizationCodes } from "~/packages/kit/tables/schema"; const { deleteUsers, users } = await getTestUsers(1); -const application = await Application.insert({ +const application = await Client.insert({ id: randomUUIDv7(), redirectUris: ["https://example.com/callback"], scopes: ["openid", "profile", "email"], diff --git a/packages/api/routes/oauth/token.ts b/packages/api/routes/oauth/token.ts index f6d0d0e8..de7a4ca3 100644 --- a/packages/api/routes/oauth/token.ts +++ b/packages/api/routes/oauth/token.ts @@ -1,6 +1,6 @@ import { Token as TokenSchema } from "@versia/client/schemas"; import { apiRoute, handleZodError, jsonOrForm } from "@versia-server/kit/api"; -import { Application, db, Token } from "@versia-server/kit/db"; +import { Client, db, Token } from "@versia-server/kit/db"; import { AuthorizationCodes } from "@versia-server/kit/tables"; import { randomUUIDv7 } from "bun"; import { and, eq } from "drizzle-orm"; @@ -77,7 +77,7 @@ export default apiRoute((app) => { } // Verify the client_secret - const client = await Application.fromClientId(client_id); + const client = await Client.fromClientId(client_id); if (!client || client.data.secret !== client_secret) { return context.json( diff --git a/packages/kit/api.ts b/packages/kit/api.ts index 876b6f80..72baff53 100644 --- a/packages/kit/api.ts +++ b/packages/kit/api.ts @@ -14,7 +14,7 @@ import { type ZodAny, ZodError, z } from "zod/v4"; import { fromZodError } from "zod-validation-error"; import type { AuthData, HonoEnv } from "~/types/api"; import { ApiError } from "./api-error.ts"; -import { Application } from "./db/application.ts"; +import { Client } from "./db/application.ts"; import { Emoji } from "./db/emoji.ts"; import { Note } from "./db/note.ts"; import { Token } from "./db/token.ts"; @@ -170,7 +170,7 @@ export const auth = (options: { const auth: AuthData = { token, application: token?.data.client - ? new Application(token?.data.client) + ? new Client(token?.data.client) : null, user: (await token?.getUser()) ?? null, }; diff --git a/packages/kit/db/application.ts b/packages/kit/db/application.ts index 84920d41..b23697af 100644 --- a/packages/kit/db/application.ts +++ b/packages/kit/db/application.ts @@ -16,37 +16,37 @@ import { Clients } from "../tables/schema.ts"; import { BaseInterface } from "./base.ts"; import { Token } from "./token.ts"; -type ApplicationType = InferSelectModel; +type ClientType = InferSelectModel; -export class Application extends BaseInterface { - public static $type: ApplicationType; +export class Client extends BaseInterface { + public static $type: ClientType; public async reload(): Promise { - const reloaded = await Application.fromId(this.data.id); + const reloaded = await Client.fromId(this.data.id); if (!reloaded) { - throw new Error("Failed to reload application"); + throw new Error("Failed to reload client"); } this.data = reloaded.data; } - public static async fromId(id: string | null): Promise { + public static async fromId(id: string | null): Promise { if (!id) { return null; } - return await Application.fromSql(eq(Clients.id, id)); + return await Client.fromSql(eq(Clients.id, id)); } - public static async fromIds(ids: string[]): Promise { - return await Application.manyFromSql(inArray(Clients.id, ids)); + public static async fromIds(ids: string[]): Promise { + return await Client.manyFromSql(inArray(Clients.id, ids)); } public static async fromSql( sql: SQL | undefined, orderBy: SQL | undefined = desc(Clients.id), - ): Promise { + ): Promise { const found = await db.query.Clients.findFirst({ where: sql, orderBy, @@ -55,7 +55,7 @@ export class Application extends BaseInterface { if (!found) { return null; } - return new Application(found); + return new Client(found); } public static async manyFromSql( @@ -64,7 +64,7 @@ export class Application extends BaseInterface { limit?: number, offset?: number, extra?: Parameters[0], - ): Promise { + ): Promise { const found = await db.query.Clients.findMany({ where: sql, orderBy, @@ -73,30 +73,28 @@ export class Application extends BaseInterface { with: extra?.with, }); - return found.map((s) => new Application(s)); + return found.map((s) => new Client(s)); } - public static async getFromToken( - token: string, - ): Promise { + public static async getFromToken(token: string): Promise { const result = await Token.fromAccessToken(token); - return result?.data.client ? new Application(result.data.client) : null; + return result?.data.client ? new Client(result.data.client) : null; } - public static fromClientId(clientId: string): Promise { - return Application.fromSql(eq(Clients.id, clientId)); + public static fromClientId(clientId: string): Promise { + return Client.fromSql(eq(Clients.id, clientId)); } public async update( - newApplication: Partial, - ): Promise { + newApplication: Partial, + ): Promise { await db .update(Clients) .set(newApplication) .where(eq(Clients.id, this.id)); - const updated = await Application.fromId(this.data.id); + const updated = await Client.fromId(this.data.id); if (!updated) { throw new Error("Failed to update application"); @@ -106,7 +104,7 @@ export class Application extends BaseInterface { return updated.data; } - public save(): Promise { + public save(): Promise { return this.update(this.data); } @@ -120,10 +118,10 @@ export class Application extends BaseInterface { public static async insert( data: InferInsertModel, - ): Promise { + ): Promise { const inserted = (await db.insert(Clients).values(data).returning())[0]; - const application = await Application.fromId(inserted.id); + const application = await Client.fromId(inserted.id); if (!application) { throw new Error("Failed to insert application"); diff --git a/packages/kit/db/index.ts b/packages/kit/db/index.ts index 67f52bcf..827d8199 100644 --- a/packages/kit/db/index.ts +++ b/packages/kit/db/index.ts @@ -1,5 +1,5 @@ export { db, setupDatabase } from "../tables/db.ts"; -export { Application } from "./application.ts"; +export { Client } from "./application.ts"; export { Emoji } from "./emoji.ts"; export { Instance } from "./instance.ts"; export { Like } from "./like.ts"; diff --git a/packages/kit/db/note.ts b/packages/kit/db/note.ts index 73589953..68dc0880 100644 --- a/packages/kit/db/note.ts +++ b/packages/kit/db/note.ts @@ -36,7 +36,7 @@ import { Notifications, Users, } from "../tables/schema.ts"; -import { Application } from "./application.ts"; +import { Client } from "./application.ts"; import { BaseInterface } from "./base.ts"; import { Emoji } from "./emoji.ts"; import { Instance } from "./instance.ts"; @@ -129,7 +129,7 @@ const findManyNotes = async ( }, }, likes: true, - application: true, + client: true, mentions: { with: { user: { @@ -238,7 +238,7 @@ type NoteTypeWithRelations = NoteType & { emojis: (typeof Emoji.$type)[]; reply: NoteType | null; quote: NoteType | null; - application: typeof Application.$type | null; + client: typeof Client.$type | null; pinned: boolean; reblogged: boolean; muted: boolean; @@ -514,7 +514,7 @@ export class Note extends BaseInterface { visibility, sensitive: false, updatedAt: new Date().toISOString(), - applicationId: null, + clientId: null, uri: uri?.href, }); @@ -1162,8 +1162,8 @@ export class Note extends BaseInterface { in_reply_to_account_id: data.reply?.authorId || null, account: this.author.toApi(userFetching?.id === data.authorId), created_at: new Date(data.createdAt).toISOString(), - application: data.application - ? new Application(data.application).toApi() + application: data.client + ? new Client(data.client).toApi() : undefined, card: null, content: replacedContent, diff --git a/packages/kit/db/token.ts b/packages/kit/db/token.ts index 7fd4620d..a0ec9900 100644 --- a/packages/kit/db/token.ts +++ b/packages/kit/db/token.ts @@ -10,12 +10,12 @@ import { import type { z } from "zod/v4"; import { db } from "../tables/db.ts"; import { Tokens } from "../tables/schema.ts"; -import type { Application } from "./application.ts"; +import type { Client } from "./application.ts"; import { BaseInterface } from "./base.ts"; import { User } from "./user.ts"; type TokenType = InferSelectModel & { - client: typeof Application.$type; + client: typeof Client.$type; }; export class Token extends BaseInterface { diff --git a/packages/kit/tables/migrations/0052_complete_hellfire_club.sql b/packages/kit/tables/migrations/0052_complete_hellfire_club.sql new file mode 100644 index 00000000..eb5a69cc --- /dev/null +++ b/packages/kit/tables/migrations/0052_complete_hellfire_club.sql @@ -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; \ No newline at end of file diff --git a/packages/kit/tables/migrations/meta/0052_snapshot.json b/packages/kit/tables/migrations/meta/0052_snapshot.json new file mode 100644 index 00000000..70868abc --- /dev/null +++ b/packages/kit/tables/migrations/meta/0052_snapshot.json @@ -0,0 +1,2439 @@ +{ + "id": "a8476829-ca99-441b-9291-24259d57c2ac", + "prevId": "62ba1f05-306f-4b31-a4c0-935d6946634e", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.AuthorizationCodes": { + "name": "AuthorizationCodes", + "schema": "", + "columns": { + "code": { + "name": "code", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "redirect_uri": { + "name": "redirect_uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "code_challenge": { + "name": "code_challenge", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code_challenge_method": { + "name": "code_challenge_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "clientId": { + "name": "clientId", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "AuthorizationCodes_userId_Users_id_fk": { + "name": "AuthorizationCodes_userId_Users_id_fk", + "tableFrom": "AuthorizationCodes", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "AuthorizationCodes_clientId_Clients_client_id_fk": { + "name": "AuthorizationCodes_clientId_Clients_client_id_fk", + "tableFrom": "AuthorizationCodes", + "tableTo": "Clients", + "columnsFrom": ["clientId"], + "columnsTo": ["client_id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Challenges": { + "name": "Challenges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "challenge": { + "name": "challenge", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "NOW() + INTERVAL '5 minutes'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Clients": { + "name": "Clients", + "schema": "", + "columns": { + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "redirect_uris": { + "name": "redirect_uris", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "scopes": { + "name": "scopes", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "website": { + "name": "website", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.EmojiToNote": { + "name": "EmojiToNote", + "schema": "", + "columns": { + "emojiId": { + "name": "emojiId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "noteId": { + "name": "noteId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "EmojiToNote_emojiId_noteId_index": { + "name": "EmojiToNote_emojiId_noteId_index", + "columns": [ + { + "expression": "emojiId", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "noteId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EmojiToNote_noteId_index": { + "name": "EmojiToNote_noteId_index", + "columns": [ + { + "expression": "noteId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "EmojiToNote_emojiId_Emojis_id_fk": { + "name": "EmojiToNote_emojiId_Emojis_id_fk", + "tableFrom": "EmojiToNote", + "tableTo": "Emojis", + "columnsFrom": ["emojiId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "EmojiToNote_noteId_Notes_id_fk": { + "name": "EmojiToNote_noteId_Notes_id_fk", + "tableFrom": "EmojiToNote", + "tableTo": "Notes", + "columnsFrom": ["noteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.EmojiToUser": { + "name": "EmojiToUser", + "schema": "", + "columns": { + "emojiId": { + "name": "emojiId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "EmojiToUser_emojiId_userId_index": { + "name": "EmojiToUser_emojiId_userId_index", + "columns": [ + { + "expression": "emojiId", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EmojiToUser_userId_index": { + "name": "EmojiToUser_userId_index", + "columns": [ + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "EmojiToUser_emojiId_Emojis_id_fk": { + "name": "EmojiToUser_emojiId_Emojis_id_fk", + "tableFrom": "EmojiToUser", + "tableTo": "Emojis", + "columnsFrom": ["emojiId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "EmojiToUser_userId_Users_id_fk": { + "name": "EmojiToUser_userId_Users_id_fk", + "tableFrom": "EmojiToUser", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Emojis": { + "name": "Emojis", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "shortcode": { + "name": "shortcode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mediaId": { + "name": "mediaId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "visible_in_picker": { + "name": "visible_in_picker", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "instanceId": { + "name": "instanceId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "ownerId": { + "name": "ownerId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Emojis_mediaId_Medias_id_fk": { + "name": "Emojis_mediaId_Medias_id_fk", + "tableFrom": "Emojis", + "tableTo": "Medias", + "columnsFrom": ["mediaId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Emojis_instanceId_Instances_id_fk": { + "name": "Emojis_instanceId_Instances_id_fk", + "tableFrom": "Emojis", + "tableTo": "Instances", + "columnsFrom": ["instanceId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Emojis_ownerId_Users_id_fk": { + "name": "Emojis_ownerId_Users_id_fk", + "tableFrom": "Emojis", + "tableTo": "Users", + "columnsFrom": ["ownerId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.FilterKeywords": { + "name": "FilterKeywords", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "filterId": { + "name": "filterId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "whole_word": { + "name": "whole_word", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "FilterKeywords_filterId_Filters_id_fk": { + "name": "FilterKeywords_filterId_Filters_id_fk", + "tableFrom": "FilterKeywords", + "tableTo": "Filters", + "columnsFrom": ["filterId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Filters": { + "name": "Filters", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "context": { + "name": "context", + "type": "text[]", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filter_action": { + "name": "filter_action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "Filters_userId_Users_id_fk": { + "name": "Filters_userId_Users_id_fk", + "tableFrom": "Filters", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Flags": { + "name": "Flags", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "flag_type": { + "name": "flag_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'other'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "noteId": { + "name": "noteId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Flags_noteId_Notes_id_fk": { + "name": "Flags_noteId_Notes_id_fk", + "tableFrom": "Flags", + "tableTo": "Notes", + "columnsFrom": ["noteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Flags_userId_Users_id_fk": { + "name": "Flags_userId_Users_id_fk", + "tableFrom": "Flags", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Instances": { + "name": "Instances", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "disable_automoderation": { + "name": "disable_automoderation", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "protocol": { + "name": "protocol", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'versia'" + }, + "inbox": { + "name": "inbox", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_key": { + "name": "public_key", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "extensions": { + "name": "extensions", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Likes": { + "name": "Likes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "likerId": { + "name": "likerId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "likedId": { + "name": "likedId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "Likes_likerId_Users_id_fk": { + "name": "Likes_likerId_Users_id_fk", + "tableFrom": "Likes", + "tableTo": "Users", + "columnsFrom": ["likerId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Likes_likedId_Notes_id_fk": { + "name": "Likes_likedId_Notes_id_fk", + "tableFrom": "Likes", + "tableTo": "Notes", + "columnsFrom": ["likedId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Likes_uri_unique": { + "name": "Likes_uri_unique", + "nullsNotDistinct": false, + "columns": ["uri"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Markers": { + "name": "Markers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "noteId": { + "name": "noteId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notificationId": { + "name": "notificationId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "timeline": { + "name": "timeline", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "Markers_noteId_Notes_id_fk": { + "name": "Markers_noteId_Notes_id_fk", + "tableFrom": "Markers", + "tableTo": "Notes", + "columnsFrom": ["noteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Markers_notificationId_Notifications_id_fk": { + "name": "Markers_notificationId_Notifications_id_fk", + "tableFrom": "Markers", + "tableTo": "Notifications", + "columnsFrom": ["notificationId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Markers_userId_Users_id_fk": { + "name": "Markers_userId_Users_id_fk", + "tableFrom": "Markers", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Medias": { + "name": "Medias", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "original_content": { + "name": "original_content", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "thumbnail": { + "name": "thumbnail", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "blurhash": { + "name": "blurhash", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.MediasToNote": { + "name": "MediasToNote", + "schema": "", + "columns": { + "mediaId": { + "name": "mediaId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "noteId": { + "name": "noteId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "MediasToNote_mediaId_index": { + "name": "MediasToNote_mediaId_index", + "columns": [ + { + "expression": "mediaId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "MediasToNote_noteId_index": { + "name": "MediasToNote_noteId_index", + "columns": [ + { + "expression": "noteId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "MediasToNote_mediaId_Medias_id_fk": { + "name": "MediasToNote_mediaId_Medias_id_fk", + "tableFrom": "MediasToNote", + "tableTo": "Medias", + "columnsFrom": ["mediaId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "MediasToNote_noteId_Notes_id_fk": { + "name": "MediasToNote_noteId_Notes_id_fk", + "tableFrom": "MediasToNote", + "tableTo": "Notes", + "columnsFrom": ["noteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ModNotes": { + "name": "ModNotes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "noteId": { + "name": "noteId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "modId": { + "name": "modId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "ModNotes_noteId_Notes_id_fk": { + "name": "ModNotes_noteId_Notes_id_fk", + "tableFrom": "ModNotes", + "tableTo": "Notes", + "columnsFrom": ["noteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModNotes_userId_Users_id_fk": { + "name": "ModNotes_userId_Users_id_fk", + "tableFrom": "ModNotes", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModNotes_modId_Users_id_fk": { + "name": "ModNotes_modId_Users_id_fk", + "tableFrom": "ModNotes", + "tableTo": "Users", + "columnsFrom": ["modId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ModTags": { + "name": "ModTags", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "noteId": { + "name": "noteId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "modId": { + "name": "modId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "ModTags_noteId_Notes_id_fk": { + "name": "ModTags_noteId_Notes_id_fk", + "tableFrom": "ModTags", + "tableTo": "Notes", + "columnsFrom": ["noteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModTags_userId_Users_id_fk": { + "name": "ModTags_userId_Users_id_fk", + "tableFrom": "ModTags", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModTags_modId_Users_id_fk": { + "name": "ModTags_modId_Users_id_fk", + "tableFrom": "ModTags", + "tableTo": "Users", + "columnsFrom": ["modId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.NoteToMentions": { + "name": "NoteToMentions", + "schema": "", + "columns": { + "noteId": { + "name": "noteId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "NoteToMentions_noteId_userId_index": { + "name": "NoteToMentions_noteId_userId_index", + "columns": [ + { + "expression": "noteId", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "NoteToMentions_userId_index": { + "name": "NoteToMentions_userId_index", + "columns": [ + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "NoteToMentions_noteId_Notes_id_fk": { + "name": "NoteToMentions_noteId_Notes_id_fk", + "tableFrom": "NoteToMentions", + "tableTo": "Notes", + "columnsFrom": ["noteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "NoteToMentions_userId_Users_id_fk": { + "name": "NoteToMentions_userId_Users_id_fk", + "tableFrom": "NoteToMentions", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Notes": { + "name": "Notes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "authorId": { + "name": "authorId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reblogId": { + "name": "reblogId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text/plain'" + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reblog_count": { + "name": "reblog_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "like_count": { + "name": "like_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "reply_count": { + "name": "reply_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "replyId": { + "name": "replyId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quoteId": { + "name": "quoteId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sensitive": { + "name": "sensitive", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "spoiler_text": { + "name": "spoiler_text", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "clientId": { + "name": "clientId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content_source": { + "name": "content_source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + } + }, + "indexes": {}, + "foreignKeys": { + "Notes_authorId_Users_id_fk": { + "name": "Notes_authorId_Users_id_fk", + "tableFrom": "Notes", + "tableTo": "Users", + "columnsFrom": ["authorId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notes_reblogId_Notes_id_fk": { + "name": "Notes_reblogId_Notes_id_fk", + "tableFrom": "Notes", + "tableTo": "Notes", + "columnsFrom": ["reblogId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notes_replyId_Notes_id_fk": { + "name": "Notes_replyId_Notes_id_fk", + "tableFrom": "Notes", + "tableTo": "Notes", + "columnsFrom": ["replyId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notes_quoteId_Notes_id_fk": { + "name": "Notes_quoteId_Notes_id_fk", + "tableFrom": "Notes", + "tableTo": "Notes", + "columnsFrom": ["quoteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notes_clientId_Clients_client_id_fk": { + "name": "Notes_clientId_Clients_client_id_fk", + "tableFrom": "Notes", + "tableTo": "Clients", + "columnsFrom": ["clientId"], + "columnsTo": ["client_id"], + "onDelete": "set null", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Notes_uri_unique": { + "name": "Notes_uri_unique", + "nullsNotDistinct": false, + "columns": ["uri"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Notifications": { + "name": "Notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "notifiedId": { + "name": "notifiedId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "accountId": { + "name": "accountId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "noteId": { + "name": "noteId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dismissed": { + "name": "dismissed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "Notifications_notifiedId_Users_id_fk": { + "name": "Notifications_notifiedId_Users_id_fk", + "tableFrom": "Notifications", + "tableTo": "Users", + "columnsFrom": ["notifiedId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notifications_accountId_Users_id_fk": { + "name": "Notifications_accountId_Users_id_fk", + "tableFrom": "Notifications", + "tableTo": "Users", + "columnsFrom": ["accountId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notifications_noteId_Notes_id_fk": { + "name": "Notifications_noteId_Notes_id_fk", + "tableFrom": "Notifications", + "tableTo": "Notes", + "columnsFrom": ["noteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.OpenIdAccounts": { + "name": "OpenIdAccounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "server_id": { + "name": "server_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issuer_id": { + "name": "issuer_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "OpenIdAccounts_userId_Users_id_fk": { + "name": "OpenIdAccounts_userId_Users_id_fk", + "tableFrom": "OpenIdAccounts", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.OpenIdLoginFlows": { + "name": "OpenIdLoginFlows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "code_verifier": { + "name": "code_verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_state": { + "name": "client_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_redirect_uri": { + "name": "client_redirect_uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_scopes": { + "name": "client_scopes", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "clientId": { + "name": "clientId", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "issuer_id": { + "name": "issuer_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "OpenIdLoginFlows_clientId_Clients_client_id_fk": { + "name": "OpenIdLoginFlows_clientId_Clients_client_id_fk", + "tableFrom": "OpenIdLoginFlows", + "tableTo": "Clients", + "columnsFrom": ["clientId"], + "columnsTo": ["client_id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.PushSubscriptions": { + "name": "PushSubscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth_secret": { + "name": "auth_secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "alerts": { + "name": "alerts", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "policy": { + "name": "policy", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "tokenId": { + "name": "tokenId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "PushSubscriptions_tokenId_Tokens_id_fk": { + "name": "PushSubscriptions_tokenId_Tokens_id_fk", + "tableFrom": "PushSubscriptions", + "tableTo": "Tokens", + "columnsFrom": ["tokenId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "PushSubscriptions_tokenId_unique": { + "name": "PushSubscriptions_tokenId_unique", + "nullsNotDistinct": false, + "columns": ["tokenId"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Reaction": { + "name": "Reaction", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "emojiId": { + "name": "emojiId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "emoji_text": { + "name": "emoji_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "noteId": { + "name": "noteId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "authorId": { + "name": "authorId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "Reaction_emojiId_Emojis_id_fk": { + "name": "Reaction_emojiId_Emojis_id_fk", + "tableFrom": "Reaction", + "tableTo": "Emojis", + "columnsFrom": ["emojiId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Reaction_noteId_Notes_id_fk": { + "name": "Reaction_noteId_Notes_id_fk", + "tableFrom": "Reaction", + "tableTo": "Notes", + "columnsFrom": ["noteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Reaction_authorId_Users_id_fk": { + "name": "Reaction_authorId_Users_id_fk", + "tableFrom": "Reaction", + "tableTo": "Users", + "columnsFrom": ["authorId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Reaction_uri_unique": { + "name": "Reaction_uri_unique", + "nullsNotDistinct": false, + "columns": ["uri"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Relationships": { + "name": "Relationships", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "ownerId": { + "name": "ownerId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subjectId": { + "name": "subjectId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "following": { + "name": "following", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "showing_reblogs": { + "name": "showing_reblogs", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "notifying": { + "name": "notifying", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "blocking": { + "name": "blocking", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "muting": { + "name": "muting", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "muting_notifications": { + "name": "muting_notifications", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "requested": { + "name": "requested", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "domain_blocking": { + "name": "domain_blocking", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "endorsed": { + "name": "endorsed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "languages": { + "name": "languages", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "Relationships_ownerId_Users_id_fk": { + "name": "Relationships_ownerId_Users_id_fk", + "tableFrom": "Relationships", + "tableTo": "Users", + "columnsFrom": ["ownerId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Relationships_subjectId_Users_id_fk": { + "name": "Relationships_subjectId_Users_id_fk", + "tableFrom": "Relationships", + "tableTo": "Users", + "columnsFrom": ["subjectId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.RoleToUsers": { + "name": "RoleToUsers", + "schema": "", + "columns": { + "roleId": { + "name": "roleId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "RoleToUsers_roleId_Roles_id_fk": { + "name": "RoleToUsers_roleId_Roles_id_fk", + "tableFrom": "RoleToUsers", + "tableTo": "Roles", + "columnsFrom": ["roleId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "RoleToUsers_userId_Users_id_fk": { + "name": "RoleToUsers_userId_Users_id_fk", + "tableFrom": "RoleToUsers", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Roles": { + "name": "Roles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "permissions": { + "name": "permissions", + "type": "text[]", + "primaryKey": false, + "notNull": true + }, + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "visible": { + "name": "visible", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Tokens": { + "name": "Tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "ARRAY[]::text[]" + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "clientId": { + "name": "clientId", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "Tokens_userId_Users_id_fk": { + "name": "Tokens_userId_Users_id_fk", + "tableFrom": "Tokens", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Tokens_clientId_Clients_client_id_fk": { + "name": "Tokens_clientId_Clients_client_id_fk", + "tableFrom": "Tokens", + "tableTo": "Clients", + "columnsFrom": ["clientId"], + "columnsTo": ["client_id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.UserToPinnedNotes": { + "name": "UserToPinnedNotes", + "schema": "", + "columns": { + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "noteId": { + "name": "noteId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "UserToPinnedNotes_userId_noteId_index": { + "name": "UserToPinnedNotes_userId_noteId_index", + "columns": [ + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "noteId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "UserToPinnedNotes_noteId_index": { + "name": "UserToPinnedNotes_noteId_index", + "columns": [ + { + "expression": "noteId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "UserToPinnedNotes_userId_Users_id_fk": { + "name": "UserToPinnedNotes_userId_Users_id_fk", + "tableFrom": "UserToPinnedNotes", + "tableTo": "Users", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "UserToPinnedNotes_noteId_Notes_id_fk": { + "name": "UserToPinnedNotes_noteId_Notes_id_fk", + "tableFrom": "UserToPinnedNotes", + "tableTo": "Notes", + "columnsFrom": ["noteId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.Users": { + "name": "Users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "is_admin": { + "name": "is_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "email_verification_token": { + "name": "email_verification_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password_reset_token": { + "name": "password_reset_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fields": { + "name": "fields", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "endpoints": { + "name": "endpoints", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "avatarId": { + "name": "avatarId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "headerId": { + "name": "headerId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "follower_count": { + "name": "follower_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "following_count": { + "name": "following_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status_count": { + "name": "status_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "is_bot": { + "name": "is_bot", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_locked": { + "name": "is_locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_discoverable": { + "name": "is_discoverable", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_hiding_collections": { + "name": "is_hiding_collections", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_indexable": { + "name": "is_indexable", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sanctions": { + "name": "sanctions", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "private_key": { + "name": "private_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "instanceId": { + "name": "instanceId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "disable_automoderation": { + "name": "disable_automoderation", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "Users_uri_index": { + "name": "Users_uri_index", + "columns": [ + { + "expression": "uri", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "Users_username_index": { + "name": "Users_username_index", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "Users_email_index": { + "name": "Users_email_index", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "Users_avatarId_Medias_id_fk": { + "name": "Users_avatarId_Medias_id_fk", + "tableFrom": "Users", + "tableTo": "Medias", + "columnsFrom": ["avatarId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "cascade" + }, + "Users_headerId_Medias_id_fk": { + "name": "Users_headerId_Medias_id_fk", + "tableFrom": "Users", + "tableTo": "Medias", + "columnsFrom": ["headerId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "cascade" + }, + "Users_instanceId_Instances_id_fk": { + "name": "Users_instanceId_Instances_id_fk", + "tableFrom": "Users", + "tableTo": "Instances", + "columnsFrom": ["instanceId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "Users_uri_unique": { + "name": "Users_uri_unique", + "nullsNotDistinct": false, + "columns": ["uri"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/packages/kit/tables/migrations/meta/_journal.json b/packages/kit/tables/migrations/meta/_journal.json index 180cdd3f..4e7ec191 100644 --- a/packages/kit/tables/migrations/meta/_journal.json +++ b/packages/kit/tables/migrations/meta/_journal.json @@ -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 } ] } diff --git a/packages/kit/tables/schema.ts b/packages/kit/tables/schema.ts index 5d243179..e917f625 100644 --- a/packages/kit/tables/schema.ts +++ b/packages/kit/tables/schema.ts @@ -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], }), }), diff --git a/packages/tests/index.ts b/packages/tests/index.ts index c64cefa4..ef8253dd 100644 --- a/packages/tests/index.ts +++ b/packages/tests/index.ts @@ -2,7 +2,7 @@ import { mock } from "bun:test"; import { Client as VersiaClient } from "@versia/client"; import { config } from "@versia-server/config"; import { - Application, + Client, db, Note, setupDatabase, @@ -50,7 +50,7 @@ export const generateClient = async ( dbToken: Token; } > => { - const application = await Application.insert({ + const application = await Client.insert({ id: randomUUIDv7(), name: "Versia", redirectUris: [], @@ -111,7 +111,7 @@ export const getTestUsers = async ( const users: User[] = []; const passwords: string[] = []; - const application = await Application.insert({ + const application = await Client.insert({ id: randomUUIDv7(), name: "Versia", redirectUris: [], @@ -182,7 +182,7 @@ export const getTestStatuses = async ( sensitive: false, updatedAt: new Date().toISOString(), visibility: "public", - applicationId: null, + clientId: null, ...partial, }); diff --git a/types/api.ts b/types/api.ts index ce9736c2..f708cb48 100644 --- a/types/api.ts +++ b/types/api.ts @@ -1,6 +1,6 @@ import type * as VersiaEntities from "@versia/sdk/entities"; import type { ConfigSchema } from "@versia-server/config"; -import type { Application, Token, User } from "@versia-server/kit/db"; +import type { Client, Token, User } from "@versia-server/kit/db"; import type { SocketAddress } from "bun"; import type { Hono } from "hono"; import type { RouterRoute } from "hono/types"; @@ -11,7 +11,7 @@ export type HttpVerb = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS"; export interface AuthData { user: User | null; token: Token | null; - application: Application | null; + application: Client | null; } export type HonoEnv = {