From 6056a6622c0d3f8799068e72bc707ca98d11e458 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Thu, 11 Dec 2025 04:03:57 +0100 Subject: [PATCH] refactor(database): :recycle: Use dates instead of strings in database --- cli/user/delete.ts | 4 +- .../routes/api/v1/accounts/[id]/index.test.ts | 2 +- .../accounts/verify_credentials/index.test.ts | 4 +- packages/api/routes/api/v1/markers/index.ts | 12 +- .../api/routes/api/v2/filters/[id]/index.ts | 8 +- packages/api/routes/api/v2/filters/index.ts | 8 +- packages/api/routes/oauth/revoke.test.ts | 4 +- .../api/routes/oauth/sso/[issuer]/callback.ts | 2 +- packages/api/routes/oauth/token.test.ts | 2 +- packages/api/routes/oauth/token.ts | 5 +- packages/api/routes/well-known/versia.ts | 4 +- packages/kit/api.ts | 2 +- packages/kit/db/like.ts | 2 +- packages/kit/db/note.ts | 12 +- packages/kit/db/notification.ts | 2 +- packages/kit/db/reaction.ts | 2 +- packages/kit/db/token.ts | 4 +- packages/kit/db/user.ts | 10 +- .../migrations/0053_lively_hellfire_club.sql | 45 + .../tables/migrations/meta/0053_snapshot.json | 2439 +++++++++++++++++ .../kit/tables/migrations/meta/_journal.json | 7 + packages/kit/tables/schema.ts | 23 +- packages/tests/index.ts | 2 +- utils/challenges.ts | 6 +- utils/rss.ts | 4 +- 25 files changed, 2548 insertions(+), 67 deletions(-) create mode 100644 packages/kit/tables/migrations/0053_lively_hellfire_club.sql create mode 100644 packages/kit/tables/migrations/meta/0053_snapshot.json diff --git a/cli/user/delete.ts b/cli/user/delete.ts index 2b1a4f97..b4b4b596 100644 --- a/cli/user/delete.ts +++ b/cli/user/delete.ts @@ -31,7 +31,9 @@ export const deleteUserCommand = defineCommand({ console.info(`About to delete user ${chalk.gray(user.data.username)}!`); console.info(`Username: ${chalk.blue(user.data.username)}`); console.info(`Display Name: ${chalk.blue(user.data.displayName)}`); - console.info(`Created At: ${chalk.blue(user.data.createdAt)}`); + console.info( + `Created At: ${chalk.blue(user.data.createdAt.toISOString())}`, + ); console.info( `Instance: ${chalk.blue(user.data.instance?.baseUrl || "Local")}`, ); diff --git a/packages/api/routes/api/v1/accounts/[id]/index.test.ts b/packages/api/routes/api/v1/accounts/[id]/index.test.ts index b4539209..816729b3 100644 --- a/packages/api/routes/api/v1/accounts/[id]/index.test.ts +++ b/packages/api/routes/api/v1/accounts/[id]/index.test.ts @@ -44,7 +44,7 @@ describe("/api/v1/accounts/:id", () => { avatar: expect.any(String), header: expect.any(String), locked: users[0].data.isLocked, - created_at: new Date(users[0].data.createdAt).toISOString(), + created_at: users[0].data.createdAt.toISOString(), followers_count: 0, following_count: 0, statuses_count: 5, diff --git a/packages/api/routes/api/v1/accounts/verify_credentials/index.test.ts b/packages/api/routes/api/v1/accounts/verify_credentials/index.test.ts index 3af99a9d..2b96390b 100644 --- a/packages/api/routes/api/v1/accounts/verify_credentials/index.test.ts +++ b/packages/api/routes/api/v1/accounts/verify_credentials/index.test.ts @@ -48,9 +48,7 @@ describe("/api/v1/accounts/verify_credentials", () => { expect(data.moved).toBeNull(); expect(data.suspended).toBe(false); expect(data.limited).toBe(false); - expect(data.created_at).toBe( - new Date(users[0].data.createdAt).toISOString(), - ); + expect(data.created_at).toBe(users[0].data.createdAt.toISOString()); expect(data.last_status_at).toBeNull(); expect(data.statuses_count).toBe(0); expect(data.followers_count).toBe(0); diff --git a/packages/api/routes/api/v1/markers/index.ts b/packages/api/routes/api/v1/markers/index.ts index 1a3a94c3..ef4c0b5d 100644 --- a/packages/api/routes/api/v1/markers/index.ts +++ b/packages/api/routes/api/v1/markers/index.ts @@ -98,7 +98,7 @@ export default apiRoute((app) => { markers.home = { last_read_id: found.noteId, version: totalCount, - updated_at: new Date(found.createdAt).toISOString(), + updated_at: found.createdAt.toISOString(), }; } } @@ -124,7 +124,7 @@ export default apiRoute((app) => { markers.notifications = { last_read_id: found.notificationId, version: totalCount, - updated_at: new Date(found.createdAt).toISOString(), + updated_at: found.createdAt.toISOString(), }; } } @@ -212,9 +212,7 @@ export default apiRoute((app) => { markers.home = { last_read_id: homeId, version: totalCount, - updated_at: new Date( - insertedMarker.createdAt, - ).toISOString(), + updated_at: insertedMarker.createdAt.toISOString(), }; } @@ -242,9 +240,7 @@ export default apiRoute((app) => { markers.notifications = { last_read_id: notificationsId, version: totalCount, - updated_at: new Date( - insertedMarker.createdAt, - ).toISOString(), + updated_at: insertedMarker.createdAt.toISOString(), }; } diff --git a/packages/api/routes/api/v2/filters/[id]/index.ts b/packages/api/routes/api/v2/filters/[id]/index.ts index f7d3eb25..125ed096 100644 --- a/packages/api/routes/api/v2/filters/[id]/index.ts +++ b/packages/api/routes/api/v2/filters/[id]/index.ts @@ -184,9 +184,7 @@ export default apiRoute((app) => { title, context: ctx ?? [], filterAction: filter_action, - expireAt: new Date( - Date.now() + (expires_in ?? 0), - ).toISOString(), + expireAt: new Date(Date.now() + (expires_in ?? 0)), }) .where(and(eq(Filters.userId, user.id), eq(Filters.id, id))); @@ -244,9 +242,7 @@ export default apiRoute((app) => { id: updatedFilter.id, title: updatedFilter.title, context: updatedFilter.context, - expires_at: updatedFilter.expireAt - ? new Date(updatedFilter.expireAt).toISOString() - : null, + expires_at: updatedFilter.expireAt?.toISOString() || null, filter_action: updatedFilter.filterAction, keywords: updatedFilter.keywords.map((keyword) => ({ id: keyword.id, diff --git a/packages/api/routes/api/v2/filters/index.ts b/packages/api/routes/api/v2/filters/index.ts index c560562b..f272af65 100644 --- a/packages/api/routes/api/v2/filters/index.ts +++ b/packages/api/routes/api/v2/filters/index.ts @@ -59,9 +59,7 @@ export default apiRoute((app) => { id: filter.id, title: filter.title, context: filter.context, - expires_at: filter.expireAt - ? new Date(Date.now() + filter.expireAt).toISOString() - : null, + expires_at: filter.expireAt?.toISOString() || null, filter_action: filter.filterAction, keywords: filter.keywords.map((keyword) => ({ id: keyword.id, @@ -147,9 +145,7 @@ export default apiRoute((app) => { title, context: ctx, filterAction: filter_action, - expireAt: new Date( - Date.now() + (expires_in ?? 0), - ).toISOString(), + expireAt: new Date(Date.now() + (expires_in ?? 0)), userId: user.id, }) .returning() diff --git a/packages/api/routes/oauth/revoke.test.ts b/packages/api/routes/oauth/revoke.test.ts index 836c514b..040e6bd8 100644 --- a/packages/api/routes/oauth/revoke.test.ts +++ b/packages/api/routes/oauth/revoke.test.ts @@ -17,8 +17,8 @@ const token = await Token.insert({ id: randomUUIDv7(), clientId: application.id, accessToken: "test-access-token", - expiresAt: new Date(Date.now() + 3600 * 1000).toISOString(), - createdAt: new Date().toISOString(), + expiresAt: new Date(Date.now() + 3600 * 1000), + createdAt: new Date(), scopes: application.data.scopes, userId: users[0].id, }); diff --git a/packages/api/routes/oauth/sso/[issuer]/callback.ts b/packages/api/routes/oauth/sso/[issuer]/callback.ts index 83581a67..a45cc7f4 100644 --- a/packages/api/routes/oauth/sso/[issuer]/callback.ts +++ b/packages/api/routes/oauth/sso/[issuer]/callback.ts @@ -278,7 +278,7 @@ export default apiRoute((app) => { await db.insert(AuthorizationCodes).values({ clientId: flow.client.id, code, - expiresAt: new Date(Date.now() + 10 * 60 * 1000).toISOString(), // 10 minutes + expiresAt: new Date(Date.now() + 10 * 60 * 1000), // 10 minutes redirectUri: flow.clientRedirectUri ?? undefined, userId: user.id, scopes: flow.clientScopes ?? [], diff --git a/packages/api/routes/oauth/token.test.ts b/packages/api/routes/oauth/token.test.ts index 4091ffa9..e3d5ad62 100644 --- a/packages/api/routes/oauth/token.test.ts +++ b/packages/api/routes/oauth/token.test.ts @@ -24,7 +24,7 @@ const authorizationCode = ( code: randomString(10), redirectUri: application.data.redirectUris[0], userId: users[0].id, - expiresAt: new Date(Date.now() + 300 * 1000).toISOString(), + expiresAt: new Date(Date.now() + 300 * 1000), }) .returning() )[0]; diff --git a/packages/api/routes/oauth/token.ts b/packages/api/routes/oauth/token.ts index 65b0be8f..5efd2a13 100644 --- a/packages/api/routes/oauth/token.ts +++ b/packages/api/routes/oauth/token.ts @@ -101,7 +101,7 @@ export default apiRoute((app) => { if ( !authorizationCode || - new Date(authorizationCode.expiresAt).getTime() < Date.now() + authorizationCode.expiresAt.getTime() < Date.now() ) { return context.json( { @@ -131,8 +131,7 @@ export default apiRoute((app) => { ...token.toApi(), expires_in: token.data.expiresAt ? Math.floor( - (new Date(token.data.expiresAt).getTime() - - Date.now()) / + (token.data.expiresAt.getTime() - Date.now()) / 1000, ) : null, diff --git a/packages/api/routes/well-known/versia.ts b/packages/api/routes/well-known/versia.ts index 85598640..ea221c96 100644 --- a/packages/api/routes/well-known/versia.ts +++ b/packages/api/routes/well-known/versia.ts @@ -73,9 +73,7 @@ export default apiRoute((app) => "/inbox", config.http.base_url, ).toString(), - created_at: new Date( - firstUser?.data.createdAt ?? 0, - ).toISOString(), + created_at: firstUser?.data.createdAt.toISOString(), extensions: { "pub.versia:instance_messaging": { endpoint: new URL( diff --git a/packages/kit/api.ts b/packages/kit/api.ts index 08ba7c5e..89e2b2cb 100644 --- a/packages/kit/api.ts +++ b/packages/kit/api.ts @@ -137,7 +137,7 @@ export const checkRouteNeedsChallenge = async ( // Expire the challenge await db .update(Challenges) - .set({ expiresAt: new Date().toISOString() }) + .set({ expiresAt: new Date() }) .where(eq(Challenges.id, challenge_id)); }; diff --git a/packages/kit/db/like.ts b/packages/kit/db/like.ts index 041bfd04..647415a0 100644 --- a/packages/kit/db/like.ts +++ b/packages/kit/db/like.ts @@ -153,7 +153,7 @@ export class Like extends BaseInterface { this.data.liker.uri ? new URL(this.data.liker.uri) : null, ).href, type: "pub.versia:likes/Like", - created_at: new Date(this.data.createdAt).toISOString(), + created_at: this.data.createdAt.toISOString(), liked: this.data.liked.uri ? new URL(this.data.liked.uri).href : new URL(`/notes/${this.data.liked.id}`, config.http.base_url) diff --git a/packages/kit/db/note.ts b/packages/kit/db/note.ts index 130d853a..24b344ab 100644 --- a/packages/kit/db/note.ts +++ b/packages/kit/db/note.ts @@ -513,7 +513,7 @@ export class Note extends BaseInterface { reblogId: this.id, visibility, sensitive: false, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), clientId: null, uri: uri?.href, }); @@ -979,7 +979,7 @@ export class Note extends BaseInterface { authorId: author.id, visibility: "public", uri, - createdAt: new Date(created_at).toISOString(), + createdAt: new Date(created_at), })); const attachments = await Promise.all( @@ -1150,7 +1150,7 @@ export class Note extends BaseInterface { in_reply_to_id: data.replyId || null, in_reply_to_account_id: data.reply?.authorId || null, account: this.author.toApi(userFetching?.id === data.authorId), - created_at: new Date(data.createdAt).toISOString(), + created_at: data.createdAt.toISOString(), application: data.client ? new Client(data.client).toApi() : undefined, @@ -1200,9 +1200,7 @@ export class Note extends BaseInterface { (n) => n?.toApi(userFetching), )) ?? null) : null, - edited_at: data.updatedAt - ? new Date(data.updatedAt).toISOString() - : null, + edited_at: data.updatedAt.toISOString(), reactions, text: data.contentSource, }; @@ -1246,7 +1244,7 @@ export class Note extends BaseInterface { const status = this.data; return new VersiaEntities.Note({ type: "Note", - created_at: new Date(status.createdAt).toISOString(), + created_at: status.createdAt.toISOString(), id: status.id, author: this.author.uri.href, uri: this.getUri().href, diff --git a/packages/kit/db/notification.ts b/packages/kit/db/notification.ts index 2d954212..3d3cc588 100644 --- a/packages/kit/db/notification.ts +++ b/packages/kit/db/notification.ts @@ -186,7 +186,7 @@ export class Notification extends BaseInterface< return { account: account.toApi(), - created_at: new Date(this.data.createdAt).toISOString(), + created_at: this.data.createdAt.toISOString(), id: this.data.id, type: this.data.type, status: this.data.status diff --git a/packages/kit/db/reaction.ts b/packages/kit/db/reaction.ts index 1f55373e..d193371c 100644 --- a/packages/kit/db/reaction.ts +++ b/packages/kit/db/reaction.ts @@ -217,7 +217,7 @@ export class Reaction extends BaseInterface { this.data.authorId, this.data.author.uri ? new URL(this.data.author.uri) : null, ).href, - created_at: new Date(this.data.createdAt).toISOString(), + created_at: this.data.createdAt.toISOString(), id: this.id, object: this.data.note.uri ? new URL(this.data.note.uri).href diff --git a/packages/kit/db/token.ts b/packages/kit/db/token.ts index db1d01d8..2363e1cd 100644 --- a/packages/kit/db/token.ts +++ b/packages/kit/db/token.ts @@ -160,9 +160,7 @@ export class Token extends BaseInterface { access_token: this.data.accessToken, token_type: "Bearer", scope: this.data.scopes.join(" "), - created_at: Math.floor( - new Date(this.data.createdAt).getTime() / 1000, - ), + created_at: Math.floor(this.data.createdAt.getTime() / 1000), }; } } diff --git a/packages/kit/db/user.ts b/packages/kit/db/user.ts index 747a7fe3..7d5ef546 100644 --- a/packages/kit/db/user.ts +++ b/packages/kit/db/user.ts @@ -475,7 +475,7 @@ export class User extends BaseInterface { isNull(Users.instanceId), gte( Notes.createdAt, - new Date(Date.now() - milliseconds).toISOString(), + new Date(Date.now() - milliseconds), ), ), ) @@ -803,7 +803,7 @@ export class User extends BaseInterface { } await user.update({ - createdAt: new Date(created_at).toISOString(), + createdAt: new Date(created_at), endpoints: { inbox, outbox: collections.outbox, @@ -940,7 +940,7 @@ export class User extends BaseInterface { publicKey: keys.public_key, fields: [], privateKey: keys.private_key, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), source: { language: "en", note: "", @@ -1116,7 +1116,7 @@ export class User extends BaseInterface { avatar: this.getAvatarUrl().proxied, header: this.getHeaderUrl()?.proxied ?? "", locked: user.isLocked, - created_at: new Date(user.createdAt).toISOString(), + created_at: user.createdAt.toISOString(), followers_count: user.isHidingCollections && !isOwnAccount ? 0 @@ -1177,7 +1177,7 @@ export class User extends BaseInterface { remote: false, }, }, - created_at: new Date(user.createdAt).toISOString(), + created_at: user.createdAt.toISOString(), collections: { featured: new URL( `/users/${user.id}/featured`, diff --git a/packages/kit/tables/migrations/0053_lively_hellfire_club.sql b/packages/kit/tables/migrations/0053_lively_hellfire_club.sql new file mode 100644 index 00000000..8dd08ebe --- /dev/null +++ b/packages/kit/tables/migrations/0053_lively_hellfire_club.sql @@ -0,0 +1,45 @@ +ALTER TABLE "AuthorizationCodes" ALTER COLUMN "expires_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "AuthorizationCodes" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "AuthorizationCodes" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Challenges" ALTER COLUMN "expires_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Challenges" ALTER COLUMN "expires_at" SET DEFAULT NOW() + INTERVAL '5 minutes';--> statement-breakpoint +ALTER TABLE "Challenges" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Challenges" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Filters" ALTER COLUMN "expires_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Filters" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Filters" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Flags" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Flags" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Likes" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Likes" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Markers" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Markers" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "ModNotes" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "ModNotes" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "ModTags" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "ModTags" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Notes" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Notes" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Notes" ALTER COLUMN "updated_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Notes" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Notifications" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Notifications" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "PushSubscriptions" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "PushSubscriptions" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "PushSubscriptions" ALTER COLUMN "updated_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "PushSubscriptions" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Reaction" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Reaction" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Reaction" ALTER COLUMN "updated_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Reaction" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Relationships" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Relationships" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Relationships" ALTER COLUMN "updated_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Relationships" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Tokens" ALTER COLUMN "expires_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Tokens" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Tokens" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Users" ALTER COLUMN "created_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Users" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint +ALTER TABLE "Users" ALTER COLUMN "updated_at" SET DATA TYPE timestamp (3) with time zone;--> statement-breakpoint +ALTER TABLE "Users" ALTER COLUMN "updated_at" SET DEFAULT now(); \ No newline at end of file diff --git a/packages/kit/tables/migrations/meta/0053_snapshot.json b/packages/kit/tables/migrations/meta/0053_snapshot.json new file mode 100644 index 00000000..cfebe30d --- /dev/null +++ b/packages/kit/tables/migrations/meta/0053_snapshot.json @@ -0,0 +1,2439 @@ +{ + "id": "5e2c1ea7-3a9a-4241-9f66-73ad8081371a", + "prevId": "a8476829-ca99-441b-9291-24259d57c2ac", + "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) with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp (3) with time zone", + "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) with time zone", + "primaryKey": false, + "notNull": true, + "default": "NOW() + INTERVAL '5 minutes'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp (3) with time zone", + "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) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (3) with time zone", + "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) with time zone", + "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) with time zone", + "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) with time zone", + "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) with time zone", + "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) with time zone", + "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) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3) with time zone", + "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) with time zone", + "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) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3) with time zone", + "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) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3) with time zone", + "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) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3) with time zone", + "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) with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp (3) with time zone", + "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) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3) with time zone", + "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 4e7ec191..c59d2e59 100644 --- a/packages/kit/tables/migrations/meta/_journal.json +++ b/packages/kit/tables/migrations/meta/_journal.json @@ -372,6 +372,13 @@ "when": 1755732000165, "tag": "0052_complete_hellfire_club", "breakpoints": true + }, + { + "idx": 53, + "version": "7", + "when": 1765422160004, + "tag": "0053_lively_hellfire_club", + "breakpoints": true } ] } diff --git a/packages/kit/tables/schema.ts b/packages/kit/tables/schema.ts index eec2e522..f379c579 100644 --- a/packages/kit/tables/schema.ts +++ b/packages/kit/tables/schema.ts @@ -28,13 +28,12 @@ import { import type { z } from "zod"; const createdAt = () => - // TODO: Change mode to Date - timestamp("created_at", { precision: 3, mode: "string" }) + timestamp("created_at", { precision: 3, mode: "date", withTimezone: true }) .defaultNow() .notNull(); const updatedAt = () => - timestamp("updated_at", { precision: 3, mode: "string" }) + timestamp("updated_at", { precision: 3, mode: "date", withTimezone: true }) .defaultNow() .notNull(); @@ -47,7 +46,8 @@ export const Challenges = pgTable("Challenges", { challenge: jsonb("challenge").notNull().$type(), expiresAt: timestamp("expires_at", { precision: 3, - mode: "string", + mode: "date", + withTimezone: true, }) .default( // 5 minutes @@ -191,7 +191,11 @@ export const Filters = pgTable("Filters", { >(), title: text("title").notNull(), filterAction: text("filter_action").notNull().$type<"warn" | "hide">(), - expireAt: timestamp("expires_at", { precision: 3, mode: "string" }), + expireAt: timestamp("expires_at", { + precision: 3, + mode: "date", + withTimezone: true, + }), createdAt: createdAt(), }); @@ -330,7 +334,11 @@ export const Tokens = pgTable("Tokens", { id: id(), scopes: text("scopes").array().notNull().default(sql`ARRAY[]::text[]`), accessToken: text("access_token").notNull(), - expiresAt: timestamp("expires_at", { precision: 3, mode: "string" }), + expiresAt: timestamp("expires_at", { + precision: 3, + mode: "date", + withTimezone: true, + }), createdAt: createdAt(), userId: uuid("userId") .references(() => Users.id, { @@ -363,7 +371,8 @@ export const AuthorizationCodes = pgTable("AuthorizationCodes", { redirectUri: text("redirect_uri"), expiresAt: timestamp("expires_at", { precision: 3, - mode: "string", + mode: "date", + withTimezone: true, }).notNull(), createdAt: createdAt(), codeChallenge: text("code_challenge"), diff --git a/packages/tests/index.ts b/packages/tests/index.ts index ef8253dd..4f337802 100644 --- a/packages/tests/index.ts +++ b/packages/tests/index.ts @@ -180,7 +180,7 @@ export const getTestStatuses = async ( content: `${i} ${randomString(32, "hex")}`, authorId: user.id, sensitive: false, - updatedAt: new Date().toISOString(), + updatedAt: new Date(), visibility: "public", clientId: null, ...partial, diff --git a/utils/challenges.ts b/utils/challenges.ts index 01422ba3..9ee94a4c 100644 --- a/utils/challenges.ts +++ b/utils/challenges.ts @@ -10,8 +10,8 @@ export const generateChallenge = async ( ): Promise<{ id: string; challenge: Challenge; - expiresAt: string; - createdAt: string; + expiresAt: Date; + createdAt: Date; }> => { if (!config.validation.challenges) { throw new Error("Challenges are not enabled"); @@ -39,7 +39,7 @@ export const generateChallenge = async ( .values({ id: uuid, challenge, - expiresAt: expirationDate.toISOString(), + expiresAt: expirationDate, }) .returning() )[0]; diff --git a/utils/rss.ts b/utils/rss.ts index 1633dd57..8ee540a1 100644 --- a/utils/rss.ts +++ b/utils/rss.ts @@ -58,12 +58,12 @@ export const getFeed = async (user: User, page = 0): Promise => { config.http.base_url, ).href, content: note.data.content, - date: new Date(note.data.createdAt), + date: note.data.createdAt, id: new URL( `/@${user.data.username}/${note.id}`, config.http.base_url, ).href, - published: new Date(note.data.createdAt), + published: note.data.createdAt, title: "", image: image ? {