From d37ad87a183eb4cbf0caee58c2fa75565baf0a37 Mon Sep 17 00:00:00 2001 From: BlankParticle Date: Sat, 31 Aug 2024 22:32:01 +0530 Subject: [PATCH] chore: remove unused db stuff --- apps/platform/utils/auth/passkeyUtils.ts | 9 - .../src/server/trpc/routers/accountRouter.ts | 2 - .../migrations/0001_flimsy_mercury.sql | 4 + .../migrations/meta/0001_snapshot.json | 4648 +++++++++++++++++ .../database/migrations/meta/_journal.json | 7 + packages/database/schema.ts | 45 +- 6 files changed, 4661 insertions(+), 54 deletions(-) create mode 100644 packages/database/migrations/0001_flimsy_mercury.sql create mode 100644 packages/database/migrations/meta/0001_snapshot.json diff --git a/apps/platform/utils/auth/passkeyUtils.ts b/apps/platform/utils/auth/passkeyUtils.ts index 7cbb1bc1..20d2d473 100644 --- a/apps/platform/utils/auth/passkeyUtils.ts +++ b/apps/platform/utils/auth/passkeyUtils.ts @@ -44,9 +44,6 @@ export async function createAuthenticator( await passkeyDb.insert(authenticators).values({ publicId: passkeyPublicId, accountId: authenticator.accountId, - // TODO: remove once table has been migrated - // Just keeping for data parity - accountCredentialId: authenticator.accountId, nickname: nickname, credentialID: b64ID, credentialPublicKey: b64PK, @@ -93,8 +90,6 @@ export async function getAuthenticator(credentialId: string) { id: true, publicId: true, accountId: true, - // TODO: remove once table has been migrated - accountCredentialId: true, nickname: true, credentialID: true, credentialPublicKey: true, @@ -128,8 +123,6 @@ export async function listAuthenticatorsByAccountCredentialId( id: true, publicId: true, accountId: true, - // TODO: remove once table has been migrated - accountCredentialId: true, nickname: true, credentialID: true, credentialPublicKey: true, @@ -155,8 +148,6 @@ export async function listAuthenticatorsByAccountId(accountId: number) { id: true, publicId: true, nickname: true, - // TODO: remove once table has been migrated - accountCredentialId: true, accountId: true, credentialID: true, credentialPublicKey: true, diff --git a/ee/apps/command/src/server/trpc/routers/accountRouter.ts b/ee/apps/command/src/server/trpc/routers/accountRouter.ts index 465e187f..bd72ab53 100644 --- a/ee/apps/command/src/server/trpc/routers/accountRouter.ts +++ b/ee/apps/command/src/server/trpc/routers/accountRouter.ts @@ -26,7 +26,6 @@ export const accountRouter = router({ username: true, createdAt: true, metadata: true, - preAccount: true, recoveryCode: true, lastLoginAt: true } @@ -116,7 +115,6 @@ export const accountRouter = router({ username: true, createdAt: true, metadata: true, - preAccount: true, recoveryCode: true, lastLoginAt: true }, diff --git a/packages/database/migrations/0001_flimsy_mercury.sql b/packages/database/migrations/0001_flimsy_mercury.sql new file mode 100644 index 00000000..76217732 --- /dev/null +++ b/packages/database/migrations/0001_flimsy_mercury.sql @@ -0,0 +1,4 @@ +DROP TABLE `account_credentials`;--> statement-breakpoint +DROP INDEX `provider_account_id_idx` ON `authenticators`;--> statement-breakpoint +ALTER TABLE `accounts` DROP COLUMN `pre_account`;--> statement-breakpoint +ALTER TABLE `authenticators` DROP COLUMN `account_credential_id`; \ No newline at end of file diff --git a/packages/database/migrations/meta/0001_snapshot.json b/packages/database/migrations/meta/0001_snapshot.json new file mode 100644 index 00000000..479967cf --- /dev/null +++ b/packages/database/migrations/meta/0001_snapshot.json @@ -0,0 +1,4648 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "23669ddd-d0b3-4c57-8b61-8b878aedc330", + "prevId": "f101f2f5-343a-4e48-b975-7b937ee164f5", + "tables": { + "accounts": { + "name": "accounts", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "public_id": { + "name": "public_id", + "type": "char(28)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "username": { + "name": "username", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_login_at": { + "name": "last_login_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password_hash": { + "name": "password_hash", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "recovery_email_hash": { + "name": "recovery_email_hash", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "recovery_email_verified_at": { + "name": "recovery_email_verified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "two_factor_secret": { + "name": "two_factor_secret", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "two_factor_enabled": { + "name": "two_factor_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "recovery_code": { + "name": "recovery_code", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "username_idx": { + "name": "username_idx", + "columns": [ + "username" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "accounts_id": { + "name": "accounts_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "authenticators": { + "name": "authenticators", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "nickname": { + "name": "nickname", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_id": { + "name": "credential_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_public_key": { + "name": "credential_public_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "counter": { + "name": "counter", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_device_type": { + "name": "credential_device_type", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_backed_up": { + "name": "credential_backed_up", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "transports": { + "name": "transports", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "credential_id_idx": { + "name": "credential_id_idx", + "columns": [ + "credential_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "authenticators_id": { + "name": "authenticators_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "contact_global_reputations": { + "name": "contact_global_reputations", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "email_address": { + "name": "email_address", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "spam": { + "name": "spam", + "type": "tinyint", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "cold": { + "name": "cold", + "type": "tinyint", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "newsletter": { + "name": "newsletter", + "type": "tinyint", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "marketing": { + "name": "marketing", + "type": "tinyint", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "product": { + "name": "product", + "type": "tinyint", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "message_count": { + "name": "message_count", + "type": "mediumint", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email_address_idx": { + "name": "email_address_idx", + "columns": [ + "email_address" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "contact_global_reputations_id": { + "name": "contact_global_reputations_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "contacts": { + "name": "contacts", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(28)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "avatar_timestamp": { + "name": "avatar_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reputation_id": { + "name": "reputation_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "set_name": { + "name": "set_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email_username": { + "name": "email_username", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_domain": { + "name": "email_domain", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "signature": { + "name": "signature", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "signature_html": { + "name": "signature_html", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "enum('person','product','newsletter','marketing','unknown')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "screener_status": { + "name": "screener_status", + "type": "enum('pending','approve','reject')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "email_idx": { + "name": "email_idx", + "columns": [ + "email_username", + "email_domain" + ], + "isUnique": false + }, + "email_org_unique_idx": { + "name": "email_org_unique_idx", + "columns": [ + "email_username", + "email_domain", + "org_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "contacts_id": { + "name": "contacts_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_attachments": { + "name": "convo_attachments", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_id": { + "name": "convo_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_entry_id": { + "name": "convo_entry_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fileName": { + "name": "fileName", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "int unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "inline": { + "name": "inline", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "public": { + "name": "public", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "convo_participant_id": { + "name": "convo_participant_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "convo_id_idx": { + "name": "convo_id_idx", + "columns": [ + "convo_id" + ], + "isUnique": false + }, + "convo_entry_id_idx": { + "name": "convo_entry_id_idx", + "columns": [ + "convo_entry_id" + ], + "isUnique": false + }, + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_attachments_id": { + "name": "convo_attachments_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_entries": { + "name": "convo_entries", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "enum('message','comment','draft')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_id": { + "name": "convo_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_id": { + "name": "subject_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "author": { + "name": "author", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reply_to_id": { + "name": "reply_to_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body_plain_text": { + "name": "body_plain_text", + "type": "longtext", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body_cleaned_html": { + "name": "body_cleaned_html", + "type": "longtext", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "('{}')" + }, + "email_message_id": { + "name": "email_message_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "generated": { + "as": "JSON_UNQUOTE(metadata-> '$.email.messageId')", + "type": "stored" + } + }, + "visibility": { + "name": "visibility", + "type": "enum('private','internal_participants','org','all_participants')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "convo_id_idx": { + "name": "convo_id_idx", + "columns": [ + "convo_id" + ], + "isUnique": false + }, + "subject_id_idx": { + "name": "subject_id_idx", + "columns": [ + "subject_id" + ], + "isUnique": false + }, + "author_idx": { + "name": "author_idx", + "columns": [ + "author" + ], + "isUnique": false + }, + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "type_idx": { + "name": "type_idx", + "columns": [ + "type" + ], + "isUnique": false + }, + "reply_to_id_idx": { + "name": "reply_to_id_idx", + "columns": [ + "reply_to_id" + ], + "isUnique": false + }, + "created_at_idx": { + "name": "created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + }, + "email_message_id_idx": { + "name": "email_message_id_idx", + "columns": [ + "email_message_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_entries_id": { + "name": "convo_entries_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_entry_private_visibility_participants": { + "name": "convo_entry_private_visibility_participants", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entry_id": { + "name": "entry_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_member_id": { + "name": "convo_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "entry_id_idx": { + "name": "entry_id_idx", + "columns": [ + "entry_id" + ], + "isUnique": false + }, + "convo_member_id_idx": { + "name": "convo_member_id_idx", + "columns": [ + "convo_member_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_entry_private_visibility_participants_id": { + "name": "convo_entry_private_visibility_participants_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_entry_raw_html_emails": { + "name": "convo_entry_raw_html_emails", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entry_id": { + "name": "entry_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "html": { + "name": "html", + "type": "mediumtext", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "wipe_date": { + "name": "wipe_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "keep": { + "name": "keep", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "wiped": { + "name": "wiped", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "entry_id_idx": { + "name": "entry_id_idx", + "columns": [ + "entry_id" + ], + "isUnique": false + }, + "wipe_date_idx": { + "name": "wipe_date_idx", + "columns": [ + "wipe_date" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_entry_raw_html_emails_id": { + "name": "convo_entry_raw_html_emails_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_entry_replies": { + "name": "convo_entry_replies", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_message_source_id": { + "name": "convo_message_source_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_message_reply_id": { + "name": "convo_message_reply_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "entry_source_id_idx": { + "name": "entry_source_id_idx", + "columns": [ + "convo_message_source_id" + ], + "isUnique": false + }, + "entry_reply_id_idx": { + "name": "entry_reply_id_idx", + "columns": [ + "convo_message_reply_id" + ], + "isUnique": false + }, + "created_at_idx": { + "name": "created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_entry_replies_id": { + "name": "convo_entry_replies_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_entry_seen_timestamps": { + "name": "convo_entry_seen_timestamps", + "columns": { + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_entry_id": { + "name": "convo_entry_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "participant_id": { + "name": "participant_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "seen_at": { + "name": "seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "convo_entry_id_idx": { + "name": "convo_entry_id_idx", + "columns": [ + "convo_entry_id" + ], + "isUnique": false + }, + "participant_id_idx": { + "name": "participant_id_idx", + "columns": [ + "participant_id" + ], + "isUnique": false + }, + "seen_at_idx": { + "name": "seen_at_idx", + "columns": [ + "seen_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "id": { + "name": "id", + "columns": [ + "convo_entry_id", + "participant_id", + "org_member_id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_participant_team_members": { + "name": "convo_participant_team_members", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_participant_id": { + "name": "convo_participant_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "convo_participant_id_idx": { + "name": "convo_participant_id_idx", + "columns": [ + "convo_participant_id" + ], + "isUnique": false + }, + "team_id_idx": { + "name": "team_id_idx", + "columns": [ + "team_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_participant_team_members_id": { + "name": "convo_participant_team_members_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_participants": { + "name": "convo_participants", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "contact_id": { + "name": "contact_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "convo_id": { + "name": "convo_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "enum('assigned','contributor','commenter','watcher','teamMember','guest')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'contributor'" + }, + "email_identity_id": { + "name": "email_identity_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notifications": { + "name": "notifications", + "type": "enum('active','muted','off')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "last_read_at": { + "name": "last_read_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "org_member_id_idx": { + "name": "org_member_id_idx", + "columns": [ + "org_member_id" + ], + "isUnique": false + }, + "convo_id_idx": { + "name": "convo_id_idx", + "columns": [ + "convo_id" + ], + "isUnique": false + }, + "org_member_to_convo_idx": { + "name": "org_member_to_convo_idx", + "columns": [ + "convo_id", + "org_member_id" + ], + "isUnique": false + }, + "team_to_convo_idx": { + "name": "team_to_convo_idx", + "columns": [ + "convo_id", + "team_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_participants_id": { + "name": "convo_participants_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_seen_timestamps": { + "name": "convo_seen_timestamps", + "columns": { + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_id": { + "name": "convo_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "participant_id": { + "name": "participant_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "seen_at": { + "name": "seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "convo_id_idx": { + "name": "convo_id_idx", + "columns": [ + "convo_id" + ], + "isUnique": false + }, + "seen_at_idx": { + "name": "seen_at_idx", + "columns": [ + "seen_at" + ], + "isUnique": false + }, + "participant_id_idx": { + "name": "participant_id_idx", + "columns": [ + "participant_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "id": { + "name": "id", + "columns": [ + "convo_id", + "participant_id", + "org_member_id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_subjects": { + "name": "convo_subjects", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_id": { + "name": "convo_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject": { + "name": "subject", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "convo_id_idx": { + "name": "convo_id_idx", + "columns": [ + "convo_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_subjects_id": { + "name": "convo_subjects_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_tags": { + "name": "convo_tags", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_id": { + "name": "convo_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "space_id": { + "name": "space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_to_space_id": { + "name": "convo_to_space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tag_id": { + "name": "tag_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_by_org_member_id": { + "name": "added_by_org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "convo_id_idx": { + "name": "convo_id_idx", + "columns": [ + "convo_id" + ], + "isUnique": false + }, + "space_id_idx": { + "name": "space_id_idx", + "columns": [ + "space_id" + ], + "isUnique": false + }, + "convo_to_spaces_id_idx": { + "name": "convo_to_spaces_id_idx", + "columns": [ + "convo_to_space_id" + ], + "isUnique": false + }, + "tag_idx": { + "name": "tag_idx", + "columns": [ + "tag_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_tags_id": { + "name": "convo_tags_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_to_spaces": { + "name": "convo_to_spaces", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_id": { + "name": "convo_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "space_id": { + "name": "space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "convo_id_idx": { + "name": "convo_id_idx", + "columns": [ + "convo_id" + ], + "isUnique": false + }, + "space_id_idx": { + "name": "space_id_idx", + "columns": [ + "space_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_to_spaces_id": { + "name": "convo_to_spaces_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convo_workflows": { + "name": "convo_workflows", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_id": { + "name": "convo_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "space_id": { + "name": "space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "convo_to_space_id": { + "name": "convo_to_space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workflow_id": { + "name": "workflow_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "by_org_member_id": { + "name": "by_org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "convo_id_idx": { + "name": "convo_id_idx", + "columns": [ + "convo_id" + ], + "isUnique": false + }, + "space_id_idx": { + "name": "space_id_idx", + "columns": [ + "space_id" + ], + "isUnique": false + }, + "convo_to_spaces_id_idx": { + "name": "convo_to_spaces_id_idx", + "columns": [ + "convo_to_space_id" + ], + "isUnique": false + }, + "workflow_idx": { + "name": "workflow_idx", + "columns": [ + "workflow_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convo_workflows_id": { + "name": "convo_workflows_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "convos": { + "name": "convos", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(28)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_updated_at": { + "name": "last_updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "created_at_idx": { + "name": "created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "convos_id": { + "name": "convos_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "domains": { + "name": "domains", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "public_id": { + "name": "public_id", + "type": "char(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "catch_all_address": { + "name": "catch_all_address", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "postal_host": { + "name": "postal_host", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "domain": { + "name": "domain", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "forwarding_address": { + "name": "forwarding_address", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "postal_id": { + "name": "postal_id", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "domain_status": { + "name": "domain_status", + "type": "enum('unverified','pending','active','disabled')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'unverified'" + }, + "sending_mode": { + "name": "sending_mode", + "type": "enum('native','external','disabled')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "receiving_mode": { + "name": "receiving_mode", + "type": "enum('native','forwarding','disabled')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dkim_key": { + "name": "dkim_key", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dkim_value": { + "name": "dkim_value", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "verification_token": { + "name": "verification_token", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mx_dns_valid": { + "name": "mx_dns_valid", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "dkim_dns_valid": { + "name": "dkim_dns_valid", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "spf_dns_valid": { + "name": "spf_dns_valid", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "return_path_dns_valid": { + "name": "return_path_dns_valid", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "last_dns_check_at": { + "name": "last_dns_check_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disabled_at": { + "name": "disabled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "domain_name_idx": { + "name": "domain_name_idx", + "columns": [ + "domain" + ], + "isUnique": false + }, + "domain_org_idx": { + "name": "domain_org_idx", + "columns": [ + "domain", + "org_id" + ], + "isUnique": true + }, + "postal_id_idx": { + "name": "postal_id_idx", + "columns": [ + "postal_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "domains_id": { + "name": "domains_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "email_identities": { + "name": "email_identities", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "username": { + "name": "username", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "domain_name": { + "name": "domain_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "domain_id": { + "name": "domain_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "routing_rule_id": { + "name": "routing_rule_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "send_name": { + "name": "send_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_catch_all": { + "name": "is_catch_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "personal_email_identity_id": { + "name": "personal_email_identity_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "external_credentials_id": { + "name": "external_credentials_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "forwarding_address": { + "name": "forwarding_address", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "domain_id_idx": { + "name": "domain_id_idx", + "columns": [ + "domain_name" + ], + "isUnique": false + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "email_idx": { + "name": "email_idx", + "columns": [ + "username", + "domain_name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "email_identities_id": { + "name": "email_identities_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "email_identities_authorized_org_members": { + "name": "email_identities_authorized_org_members", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "identity_id": { + "name": "identity_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "space_id": { + "name": "space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "added_by": { + "name": "added_by", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "identity_id_idx": { + "name": "identity_id_idx", + "columns": [ + "identity_id" + ], + "isUnique": false + }, + "space_id_idx": { + "name": "space_id_idx", + "columns": [ + "space_id" + ], + "isUnique": false + }, + "org_member_to_identity_idx": { + "name": "org_member_to_identity_idx", + "columns": [ + "identity_id", + "org_member_id" + ], + "isUnique": true + }, + "team_to_identity_idx": { + "name": "team_to_identity_idx", + "columns": [ + "identity_id", + "team_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "email_identities_authorized_org_members_id": { + "name": "email_identities_authorized_org_members_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "email_identities_personal": { + "name": "email_identities_personal", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_identity_id": { + "name": "email_identity_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "account_id_idx": { + "name": "account_id_idx", + "columns": [ + "account_id" + ], + "isUnique": false + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "email_identity_id_idx": { + "name": "email_identity_id_idx", + "columns": [ + "email_identity_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "email_identities_personal_id": { + "name": "email_identities_personal_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "email_identity_external": { + "name": "email_identity_external", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "nickname": { + "name": "nickname", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "username": { + "name": "username", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "hostname": { + "name": "hostname", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth_method": { + "name": "auth_method", + "type": "enum('plain','login')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "encryption": { + "name": "encryption", + "type": "enum('ssl','tls','starttls','none')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'none'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "email_identity_external_id": { + "name": "email_identity_external_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "email_routing_rule_assignees": { + "name": "email_routing_rule_assignees", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "rule_destination_id": { + "name": "rule_destination_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "rule_destination_id_idx": { + "name": "rule_destination_id_idx", + "columns": [ + "rule_destination_id" + ], + "isUnique": false + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "org_member_id_idx": { + "name": "org_member_id_idx", + "columns": [ + "org_member_id" + ], + "isUnique": false + }, + "team_id_idx": { + "name": "team_id_idx", + "columns": [ + "team_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "email_routing_rule_assignees_id": { + "name": "email_routing_rule_assignees_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "email_routing_rules": { + "name": "email_routing_rules", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "email_routing_rules_id": { + "name": "email_routing_rules_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "email_routing_rules_destinations": { + "name": "email_routing_rules_destinations", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "rule_id": { + "name": "rule_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "space_id": { + "name": "space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "rule_id_idx": { + "name": "rule_id_idx", + "columns": [ + "rule_id" + ], + "isUnique": false + }, + "space_id_idx": { + "name": "space_id_idx", + "columns": [ + "space_id" + ], + "isUnique": false + }, + "team_id_idx": { + "name": "team_id_idx", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "org_member_id_idx": { + "name": "org_member_id_idx", + "columns": [ + "org_member_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "email_routing_rules_destinations_id": { + "name": "email_routing_rules_destinations_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "org_billing": { + "name": "org_billing", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "plan": { + "name": "plan", + "type": "enum('starter','pro')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'starter'" + }, + "period": { + "name": "period", + "type": "enum('monthly','yearly')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'monthly'" + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "stripe_customer_id_idx": { + "name": "stripe_customer_id_idx", + "columns": [ + "stripe_customer_id" + ], + "isUnique": true + }, + "stripe_subscription_id_idx": { + "name": "stripe_subscription_id_idx", + "columns": [ + "stripe_subscription_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "org_billing_id": { + "name": "org_billing_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "org_invitations": { + "name": "org_invitations", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "invited_by_org_member_id": { + "name": "invited_by_org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "enum('member','admin')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invited_org_member_profile_id": { + "name": "invited_org_member_profile_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invite_token": { + "name": "invite_token", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invited_at": { + "name": "invited_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "org_member_id_idx": { + "name": "org_member_id_idx", + "columns": [ + "org_member_id" + ], + "isUnique": true + }, + "org_email_unique_idx": { + "name": "org_email_unique_idx", + "columns": [ + "org_id", + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "org_invitations_id": { + "name": "org_invitations_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "org_member_profiles": { + "name": "org_member_profiles", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "avatar_timestamp": { + "name": "avatar_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "first_name": { + "name": "first_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_name": { + "name": "last_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "handle": { + "name": "handle", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "blurb": { + "name": "blurb", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "account_id_idx": { + "name": "account_id_idx", + "columns": [ + "account_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "org_member_profiles_id": { + "name": "org_member_profiles_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "org_members": { + "name": "org_members", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invited_by_org_member_id": { + "name": "invited_by_org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "enum('invited','active','removed')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "enum('member','admin')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "personal_space_id": { + "name": "personal_space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "org_member_profile_id": { + "name": "org_member_profile_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "default_email_identity_id": { + "name": "default_email_identity_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "account_id_idx": { + "name": "account_id_idx", + "columns": [ + "account_id" + ], + "isUnique": false + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "org_account_idx": { + "name": "org_account_idx", + "columns": [ + "org_id", + "account_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "org_members_id": { + "name": "org_members_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "org_modules": { + "name": "org_modules", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "module": { + "name": "module", + "type": "enum('strip signatures','anonymous analytics')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "last_modified_by_org_member": { + "name": "last_modified_by_org_member", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_modified_at": { + "name": "last_modified_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "org_module_idx": { + "name": "org_module_idx", + "columns": [ + "org_id", + "module" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "org_modules_id": { + "name": "org_modules_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "org_postal_configs": { + "name": "org_postal_configs", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "host": { + "name": "host", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ip_pools": { + "name": "ip_pools", + "type": "json", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "default_ip_pool": { + "name": "default_ip_pool", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "org_postal_configs_id": { + "name": "org_postal_configs_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "orgs": { + "name": "orgs", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "public_id": { + "name": "public_id", + "type": "char(28)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "avatar_timestamp": { + "name": "avatar_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "shortcode": { + "name": "shortcode", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_id": { + "name": "owner_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "('{}')" + }, + "migrated_to_spaces": { + "name": "migrated_to_spaces", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "shortcode_idx": { + "name": "shortcode_idx", + "columns": [ + "shortcode" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "orgs_id": { + "name": "orgs_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "pending_attachments": { + "name": "pending_attachments", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_public_id": { + "name": "org_public_id", + "type": "char(28)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "filename": { + "name": "filename", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "pending_attachments_id": { + "name": "pending_attachments_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "postal_servers": { + "name": "postal_servers", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "enum('email','transactional','marketing')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "api_key": { + "name": "api_key", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "smtp_key": { + "name": "smtp_key", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "root_forwarding_address": { + "name": "root_forwarding_address", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "postal_servers_id": { + "name": "postal_servers_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "sessions": { + "name": "sessions", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "account_public_id": { + "name": "account_public_id", + "type": "char(28)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_token": { + "name": "session_token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "device": { + "name": "device", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "os": { + "name": "os", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "account_id_idx": { + "name": "account_id_idx", + "columns": [ + "account_id" + ], + "isUnique": false + }, + "session_token_idx": { + "name": "session_token_idx", + "columns": [ + "session_token" + ], + "isUnique": true + }, + "expires_at_idx": { + "name": "expires_at_idx", + "columns": [ + "expires_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "sessions_id": { + "name": "sessions_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "space_members": { + "name": "space_members", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "space_id": { + "name": "space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "enum('member','admin')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'member'" + }, + "notifications": { + "name": "notifications", + "type": "enum('active','muted','off')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "added_by_org_member_id": { + "name": "added_by_org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "can_create": { + "name": "can_create", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_read": { + "name": "can_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_comment": { + "name": "can_comment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_reply": { + "name": "can_reply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_delete": { + "name": "can_delete", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_change_workflow": { + "name": "can_change_workflow", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_set_workflow_to_closed": { + "name": "can_set_workflow_to_closed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_add_tags": { + "name": "can_add_tags", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_move_to_another_space": { + "name": "can_move_to_another_space", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_add_to_another_space": { + "name": "can_add_to_another_space", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_merge": { + "name": "can_merge", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "can_add_participants": { + "name": "can_add_participants", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + } + }, + "indexes": { + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "space_id_idx": { + "name": "space_id_idx", + "columns": [ + "space_id" + ], + "isUnique": false + }, + "org_member_id_idx": { + "name": "org_member_id_idx", + "columns": [ + "org_member_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "space_members_id": { + "name": "space_members_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "space_tags": { + "name": "space_tags", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "space_id": { + "name": "space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "enum('bronze','gold','brown','orange','tomato','red','ruby','crimson','pink','plum','purple','violet','iris','indigo','blue','cyan','teal','jade','green','grass')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "icon": { + "name": "icon", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tag-simple'" + }, + "created_by_org_member_id": { + "name": "created_by_org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "space_id_idx": { + "name": "space_id_idx", + "columns": [ + "space_id" + ], + "isUnique": false + }, + "created_by_org_member_id_idx": { + "name": "created_by_org_member_id_idx", + "columns": [ + "created_by_org_member_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "space_tags_id": { + "name": "space_tags_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "space_workflows": { + "name": "space_workflows", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "space_id": { + "name": "space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "enum('open','active','closed')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "order": { + "name": "order", + "type": "tinyint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "enum('bronze','gold','brown','orange','tomato','red','ruby','crimson','pink','plum','purple','violet','iris','indigo','blue','cyan','teal','jade','green','grass')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "icon": { + "name": "icon", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'check'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_by_org_member_id": { + "name": "created_by_org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + }, + "space_id_idx": { + "name": "space_id_idx", + "columns": [ + "space_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "space_workflows_id": { + "name": "space_workflows_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "spaces": { + "name": "spaces", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "parent_space_id": { + "name": "parent_space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(28)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "shortcode": { + "name": "shortcode", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "enum('open','private')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "personal_space": { + "name": "personal_space", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "convo_prefix": { + "name": "convo_prefix", + "type": "varchar(8)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "inherit_parent_permissions": { + "name": "inherit_parent_permissions", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "name": { + "name": "name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "icon": { + "name": "icon", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'squares-four'" + }, + "color": { + "name": "color", + "type": "enum('bronze','gold','brown','orange','tomato','red','ruby','crimson','pink','plum','purple','violet','iris','indigo','blue','cyan','teal','jade','green','grass')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "avatar_timestamp": { + "name": "avatar_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by_org_member_id": { + "name": "created_by_org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "shortcode_idx": { + "name": "shortcode_idx", + "columns": [ + "shortcode" + ], + "isUnique": false + }, + "shortcode_org_unique_idx": { + "name": "shortcode_org_unique_idx", + "columns": [ + "shortcode", + "org_id" + ], + "isUnique": true + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "spaces_id": { + "name": "spaces_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "team_members": { + "name": "team_members", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(29)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_id": { + "name": "org_member_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "org_member_profile_id": { + "name": "org_member_profile_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "added_by": { + "name": "added_by", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "enum('member','admin')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'member'" + }, + "notifications": { + "name": "notifications", + "type": "enum('active','muted','off')", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "team_id_idx": { + "name": "team_id_idx", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "org_member_id_idx": { + "name": "org_member_id_idx", + "columns": [ + "org_member_id" + ], + "isUnique": false + }, + "org_member_to_team_idx": { + "name": "org_member_to_team_idx", + "columns": [ + "team_id", + "org_member_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "team_members_id": { + "name": "team_members_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "teams": { + "name": "teams", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "org_id": { + "name": "org_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "char(28)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "avatar_timestamp": { + "name": "avatar_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "enum('bronze','gold','brown','orange','tomato','red','ruby','crimson','pink','plum','purple','violet','iris','indigo','blue','cyan','teal','jade','green','grass')", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "default_email_identity_id": { + "name": "default_email_identity_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "default_space_id": { + "name": "default_space_id", + "type": "bigint unsigned", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "public_id_idx": { + "name": "public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "org_id_idx": { + "name": "org_id_idx", + "columns": [ + "org_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "teams_id": { + "name": "teams_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {} + } + }, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} \ No newline at end of file diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.json index b4017e6d..d1d4bb0a 100644 --- a/packages/database/migrations/meta/_journal.json +++ b/packages/database/migrations/meta/_journal.json @@ -8,6 +8,13 @@ "when": 1724678051930, "tag": "0000_cultured_cable", "breakpoints": true + }, + { + "idx": 1, + "version": "5", + "when": 1725123674507, + "tag": "0001_flimsy_mercury", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/database/schema.ts b/packages/database/schema.ts index 30661973..cbe43a1f 100644 --- a/packages/database/schema.ts +++ b/packages/database/schema.ts @@ -67,8 +67,7 @@ export const accounts = mysqlTable( recoveryEmailVerifiedAt: timestamp('recovery_email_verified_at'), twoFactorSecret: varchar('two_factor_secret', { length: 255 }), twoFactorEnabled: boolean('two_factor_enabled').notNull().default(false), - recoveryCode: varchar('recovery_code', { length: 256 }), - preAccount: boolean('pre_account').notNull().default(true) + recoveryCode: varchar('recovery_code', { length: 256 }) }, (table) => ({ publicIdIndex: uniqueIndex('public_id_idx').on(table.publicId), @@ -76,46 +75,14 @@ export const accounts = mysqlTable( }) ); -export const accountsRelations = relations(accounts, ({ one, many }) => ({ +export const accountsRelations = relations(accounts, ({ many }) => ({ authenticators: many(authenticators), - accountCredential: one(accountCredentials, { - fields: [accounts.id], - references: [accountCredentials.accountId] - }), sessions: many(sessions), orgMemberships: many(orgMembers), orgMemberProfiles: many(orgMemberProfiles), personalEmailIdentities: many(emailIdentitiesPersonal) })); -//* Auth tables -export const accountCredentials = mysqlTable( - 'account_credentials', - // eslint-disable-next-line @u22n/custom/table-needs-org-id - { - id: serial('id').primaryKey(), - accountId: foreignKey('account_id').notNull(), - passwordHash: varchar('password_hash', { length: 255 }), - twoFactorSecret: varchar('two_factor_secret', { length: 255 }), - twoFactorEnabled: boolean('two_factor_enabled').notNull().default(false), - recoveryCode: varchar('recovery_code', { length: 256 }) - }, - (accountAuth) => ({ - accountIdIndex: index('account_id_idx').on(accountAuth.accountId) - }) -); - -export const accountAuthRelationships = relations( - accountCredentials, - ({ one, many }) => ({ - account: one(accounts, { - fields: [accountCredentials.accountId], - references: [accounts.id] - }), - authenticators: many(authenticators) - }) -); - // transports type comes from @simplewebauthn/types AuthenticatorTransportFuture export const authenticators = mysqlTable( 'authenticators', @@ -123,7 +90,6 @@ export const authenticators = mysqlTable( { id: serial('id').primaryKey(), publicId: publicId('accountPasskey', 'public_id').notNull(), - accountCredentialId: foreignKey('account_credential_id').notNull(), accountId: foreignKey('account_id').notNull(), nickname: varchar('nickname', { length: 64 }).notNull(), credentialID: varchar('credential_id', { length: 255 }).notNull(), //Uint8Array @@ -151,9 +117,6 @@ export const authenticators = mysqlTable( }, (table) => ({ publicIdIndex: uniqueIndex('public_id_idx').on(table.publicId), - accountCredentialIdIndex: index('provider_account_id_idx').on( - table.accountCredentialId - ), credentialIDIndex: uniqueIndex('credential_id_idx').on(table.credentialID) }) ); @@ -164,10 +127,6 @@ export const authenticatorRelationships = relations( account: one(accounts, { fields: [authenticators.accountId], references: [accounts.id] - }), - accountCredentials: one(accountCredentials, { - fields: [authenticators.accountCredentialId], - references: [accountCredentials.id] }) }) );