From eb9548b832d198b74b6480c6d59edce85b079642 Mon Sep 17 00:00:00 2001 From: Sean O'Connor Date: Fri, 26 Jun 2026 00:12:09 -0400 Subject: [PATCH] fix the shit --- drizzle/meta/0016_snapshot.json | 2664 +++++++++++++++++++++++++++++ package.json | 1 + scripts/verify-drizzle-journal.ts | 54 + src/app/auth/register/page.tsx | 48 +- src/lib/auth.ts | 3 + 5 files changed, 2757 insertions(+), 13 deletions(-) create mode 100644 drizzle/meta/0016_snapshot.json create mode 100644 scripts/verify-drizzle-journal.ts diff --git a/drizzle/meta/0016_snapshot.json b/drizzle/meta/0016_snapshot.json new file mode 100644 index 0000000..21398d8 --- /dev/null +++ b/drizzle/meta/0016_snapshot.json @@ -0,0 +1,2664 @@ +{ + "id": "6e79910c-7892-4fca-9aaf-6f6c210f3970", + "prevId": "4a78b572-415c-416f-a4c9-46fa08b5f939", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.beenvoice_account": { + "name": "beenvoice_account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "accountId": { + "name": "accountId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "providerId": { + "name": "providerId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "accessToken": { + "name": "accessToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refreshToken": { + "name": "refreshToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accessTokenExpiresAt": { + "name": "accessTokenExpiresAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refreshTokenExpiresAt": { + "name": "refreshTokenExpiresAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "idToken": { + "name": "idToken", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "account_userId_idx": { + "name": "account_userId_idx", + "columns": [ + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_account_userId_beenvoice_user_id_fk": { + "name": "beenvoice_account_userId_beenvoice_user_id_fk", + "tableFrom": "beenvoice_account", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_api_key": { + "name": "beenvoice_api_key", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "keyHash": { + "name": "keyHash", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "keyPrefix": { + "name": "keyPrefix", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "lastUsedAt": { + "name": "lastUsedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expiresAt": { + "name": "expiresAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "revokedAt": { + "name": "revokedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "api_key_hash_idx": { + "name": "api_key_hash_idx", + "columns": [ + { + "expression": "keyHash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "api_key_user_id_idx": { + "name": "api_key_user_id_idx", + "columns": [ + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "api_key_revoked_at_idx": { + "name": "api_key_revoked_at_idx", + "columns": [ + { + "expression": "revokedAt", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_api_key_userId_beenvoice_user_id_fk": { + "name": "beenvoice_api_key_userId_beenvoice_user_id_fk", + "tableFrom": "beenvoice_api_key", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "beenvoice_api_key_keyHash_unique": { + "name": "beenvoice_api_key_keyHash_unique", + "nullsNotDistinct": false, + "columns": [ + "keyHash" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_business": { + "name": "beenvoice_business", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "nickname": { + "name": "nickname", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "addressLine1": { + "name": "addressLine1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "addressLine2": { + "name": "addressLine2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "postalCode": { + "name": "postalCode", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "country": { + "name": "country", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "website": { + "name": "website", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "taxId": { + "name": "taxId", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "logoUrl": { + "name": "logoUrl", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "isDefault": { + "name": "isDefault", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "resendApiKey": { + "name": "resendApiKey", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "resendDomain": { + "name": "resendDomain", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "emailFromName": { + "name": "emailFromName", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "createdById": { + "name": "createdById", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "business_created_by_idx": { + "name": "business_created_by_idx", + "columns": [ + { + "expression": "createdById", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_name_idx": { + "name": "business_name_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_nickname_idx": { + "name": "business_nickname_idx", + "columns": [ + { + "expression": "nickname", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_email_idx": { + "name": "business_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "business_is_default_idx": { + "name": "business_is_default_idx", + "columns": [ + { + "expression": "isDefault", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_business_createdById_beenvoice_user_id_fk": { + "name": "beenvoice_business_createdById_beenvoice_user_id_fk", + "tableFrom": "beenvoice_business", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "createdById" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_client": { + "name": "beenvoice_client", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "addressLine1": { + "name": "addressLine1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "addressLine2": { + "name": "addressLine2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "postalCode": { + "name": "postalCode", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "country": { + "name": "country", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "defaultHourlyRate": { + "name": "defaultHourlyRate", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "currency": { + "name": "currency", + "type": "varchar(3)", + "primaryKey": false, + "notNull": true, + "default": "'USD'" + }, + "createdById": { + "name": "createdById", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "client_created_by_idx": { + "name": "client_created_by_idx", + "columns": [ + { + "expression": "createdById", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "client_name_idx": { + "name": "client_name_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "client_email_idx": { + "name": "client_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_client_createdById_beenvoice_user_id_fk": { + "name": "beenvoice_client_createdById_beenvoice_user_id_fk", + "tableFrom": "beenvoice_client", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "createdById" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_expense": { + "name": "beenvoice_expense", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "businessId": { + "name": "businessId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "clientId": { + "name": "clientId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "invoiceId": { + "name": "invoiceId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "date": { + "name": "date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(3)", + "primaryKey": false, + "notNull": true, + "default": "'USD'" + }, + "category": { + "name": "category", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "billable": { + "name": "billable", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reimbursable": { + "name": "reimbursable", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "taxDeductible": { + "name": "taxDeductible", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "notes": { + "name": "notes", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "createdById": { + "name": "createdById", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "expense_created_by_idx": { + "name": "expense_created_by_idx", + "columns": [ + { + "expression": "createdById", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "expense_client_id_idx": { + "name": "expense_client_id_idx", + "columns": [ + { + "expression": "clientId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "expense_invoice_id_idx": { + "name": "expense_invoice_id_idx", + "columns": [ + { + "expression": "invoiceId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "expense_date_idx": { + "name": "expense_date_idx", + "columns": [ + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "expense_billable_idx": { + "name": "expense_billable_idx", + "columns": [ + { + "expression": "billable", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_expense_businessId_beenvoice_business_id_fk": { + "name": "beenvoice_expense_businessId_beenvoice_business_id_fk", + "tableFrom": "beenvoice_expense", + "tableTo": "beenvoice_business", + "columnsFrom": [ + "businessId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "beenvoice_expense_clientId_beenvoice_client_id_fk": { + "name": "beenvoice_expense_clientId_beenvoice_client_id_fk", + "tableFrom": "beenvoice_expense", + "tableTo": "beenvoice_client", + "columnsFrom": [ + "clientId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "beenvoice_expense_invoiceId_beenvoice_invoice_id_fk": { + "name": "beenvoice_expense_invoiceId_beenvoice_invoice_id_fk", + "tableFrom": "beenvoice_expense", + "tableTo": "beenvoice_invoice", + "columnsFrom": [ + "invoiceId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "beenvoice_expense_createdById_beenvoice_user_id_fk": { + "name": "beenvoice_expense_createdById_beenvoice_user_id_fk", + "tableFrom": "beenvoice_expense", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "createdById" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_invoice_item": { + "name": "beenvoice_invoice_item", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "invoiceId": { + "name": "invoiceId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "hours": { + "name": "hours", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "rate": { + "name": "rate", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "invoice_item_invoice_id_idx": { + "name": "invoice_item_invoice_id_idx", + "columns": [ + { + "expression": "invoiceId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoice_item_date_idx": { + "name": "invoice_item_date_idx", + "columns": [ + { + "expression": "date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoice_item_position_idx": { + "name": "invoice_item_position_idx", + "columns": [ + { + "expression": "position", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_invoice_item_invoiceId_beenvoice_invoice_id_fk": { + "name": "beenvoice_invoice_item_invoiceId_beenvoice_invoice_id_fk", + "tableFrom": "beenvoice_invoice_item", + "tableTo": "beenvoice_invoice", + "columnsFrom": [ + "invoiceId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_invoice_payment": { + "name": "beenvoice_invoice_payment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "invoiceId": { + "name": "invoiceId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "varchar(3)", + "primaryKey": false, + "notNull": true, + "default": "'USD'" + }, + "date": { + "name": "date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "method": { + "name": "method", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'other'" + }, + "notes": { + "name": "notes", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "createdById": { + "name": "createdById", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "invoice_payment_invoice_id_idx": { + "name": "invoice_payment_invoice_id_idx", + "columns": [ + { + "expression": "invoiceId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoice_payment_created_by_idx": { + "name": "invoice_payment_created_by_idx", + "columns": [ + { + "expression": "createdById", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_invoice_payment_invoiceId_beenvoice_invoice_id_fk": { + "name": "beenvoice_invoice_payment_invoiceId_beenvoice_invoice_id_fk", + "tableFrom": "beenvoice_invoice_payment", + "tableTo": "beenvoice_invoice", + "columnsFrom": [ + "invoiceId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "beenvoice_invoice_payment_createdById_beenvoice_user_id_fk": { + "name": "beenvoice_invoice_payment_createdById_beenvoice_user_id_fk", + "tableFrom": "beenvoice_invoice_payment", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "createdById" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_invoice_template": { + "name": "beenvoice_invoice_template", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'notes'" + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "isDefault": { + "name": "isDefault", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "createdById": { + "name": "createdById", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "invoice_template_created_by_idx": { + "name": "invoice_template_created_by_idx", + "columns": [ + { + "expression": "createdById", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoice_template_type_idx": { + "name": "invoice_template_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_invoice_template_createdById_beenvoice_user_id_fk": { + "name": "beenvoice_invoice_template_createdById_beenvoice_user_id_fk", + "tableFrom": "beenvoice_invoice_template", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "createdById" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_invoice": { + "name": "beenvoice_invoice", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "invoiceNumber": { + "name": "invoiceNumber", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "invoicePrefix": { + "name": "invoicePrefix", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false, + "default": "'#'" + }, + "businessId": { + "name": "businessId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "clientId": { + "name": "clientId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "issueDate": { + "name": "issueDate", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "dueDate": { + "name": "dueDate", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "totalAmount": { + "name": "totalAmount", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "taxRate": { + "name": "taxRate", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "notes": { + "name": "notes", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "emailMessage": { + "name": "emailMessage", + "type": "varchar(2000)", + "primaryKey": false, + "notNull": false + }, + "currency": { + "name": "currency", + "type": "varchar(3)", + "primaryKey": false, + "notNull": true, + "default": "'USD'" + }, + "createdById": { + "name": "createdById", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "publicToken": { + "name": "publicToken", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "publicTokenExpiresAt": { + "name": "publicTokenExpiresAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "lastReminderSentAt": { + "name": "lastReminderSentAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "sendReminderAt": { + "name": "sendReminderAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "invoice_business_id_idx": { + "name": "invoice_business_id_idx", + "columns": [ + { + "expression": "businessId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoice_client_id_idx": { + "name": "invoice_client_id_idx", + "columns": [ + { + "expression": "clientId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoice_created_by_idx": { + "name": "invoice_created_by_idx", + "columns": [ + { + "expression": "createdById", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoice_number_idx": { + "name": "invoice_number_idx", + "columns": [ + { + "expression": "invoiceNumber", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoice_status_idx": { + "name": "invoice_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invoice_public_token_idx": { + "name": "invoice_public_token_idx", + "columns": [ + { + "expression": "publicToken", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_invoice_businessId_beenvoice_business_id_fk": { + "name": "beenvoice_invoice_businessId_beenvoice_business_id_fk", + "tableFrom": "beenvoice_invoice", + "tableTo": "beenvoice_business", + "columnsFrom": [ + "businessId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "beenvoice_invoice_clientId_beenvoice_client_id_fk": { + "name": "beenvoice_invoice_clientId_beenvoice_client_id_fk", + "tableFrom": "beenvoice_invoice", + "tableTo": "beenvoice_client", + "columnsFrom": [ + "clientId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "beenvoice_invoice_createdById_beenvoice_user_id_fk": { + "name": "beenvoice_invoice_createdById_beenvoice_user_id_fk", + "tableFrom": "beenvoice_invoice", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "createdById" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "beenvoice_invoice_publicToken_unique": { + "name": "beenvoice_invoice_publicToken_unique", + "nullsNotDistinct": false, + "columns": [ + "publicToken" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_platform_setting": { + "name": "beenvoice_platform_setting", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(50)", + "primaryKey": true, + "notNull": true, + "default": "'global'" + }, + "brandName": { + "name": "brandName", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true, + "default": "'beenvoice'" + }, + "brandTagline": { + "name": "brandTagline", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "default": "'Simple and efficient invoicing for freelancers and small businesses'" + }, + "brandLogoText": { + "name": "brandLogoText", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true, + "default": "'beenvoice'" + }, + "brandIcon": { + "name": "brandIcon", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'$'" + }, + "colorTheme": { + "name": "colorTheme", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'slate'" + }, + "customColor": { + "name": "customColor", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "theme": { + "name": "theme", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "interfaceTheme": { + "name": "interfaceTheme", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'beenvoice'" + }, + "bodyFontPreference": { + "name": "bodyFontPreference", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'brand'" + }, + "headingFontPreference": { + "name": "headingFontPreference", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'brand'" + }, + "radiusPreference": { + "name": "radiusPreference", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'xl'" + }, + "sidebarStyle": { + "name": "sidebarStyle", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'floating'" + }, + "pdfTemplate": { + "name": "pdfTemplate", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'classic'" + }, + "pdfAccentColor": { + "name": "pdfAccentColor", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'#111827'" + }, + "pdfFooterText": { + "name": "pdfFooterText", + "type": "varchar(120)", + "primaryKey": false, + "notNull": true, + "default": "'Professional Invoicing'" + }, + "pdfShowLogo": { + "name": "pdfShowLogo", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "pdfShowPageNumbers": { + "name": "pdfShowPageNumbers", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_recurring_invoice_item": { + "name": "beenvoice_recurring_invoice_item", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "recurringInvoiceId": { + "name": "recurringInvoiceId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "hours": { + "name": "hours", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "rate": { + "name": "rate", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "recurring_invoice_item_recurring_id_idx": { + "name": "recurring_invoice_item_recurring_id_idx", + "columns": [ + { + "expression": "recurringInvoiceId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_recurring_invoice_item_recurringInvoiceId_beenvoice_recurring_invoice_id_fk": { + "name": "beenvoice_recurring_invoice_item_recurringInvoiceId_beenvoice_recurring_invoice_id_fk", + "tableFrom": "beenvoice_recurring_invoice_item", + "tableTo": "beenvoice_recurring_invoice", + "columnsFrom": [ + "recurringInvoiceId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_recurring_invoice": { + "name": "beenvoice_recurring_invoice", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "clientId": { + "name": "clientId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "businessId": { + "name": "businessId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "schedule": { + "name": "schedule", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'monthly'" + }, + "status": { + "name": "status", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "invoicePrefix": { + "name": "invoicePrefix", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false, + "default": "'#'" + }, + "taxRate": { + "name": "taxRate", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "currency": { + "name": "currency", + "type": "varchar(3)", + "primaryKey": false, + "notNull": true, + "default": "'USD'" + }, + "notes": { + "name": "notes", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "emailMessage": { + "name": "emailMessage", + "type": "varchar(2000)", + "primaryKey": false, + "notNull": false + }, + "nextDueAt": { + "name": "nextDueAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "lastGeneratedAt": { + "name": "lastGeneratedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "createdById": { + "name": "createdById", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "recurring_invoice_created_by_idx": { + "name": "recurring_invoice_created_by_idx", + "columns": [ + { + "expression": "createdById", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recurring_invoice_client_id_idx": { + "name": "recurring_invoice_client_id_idx", + "columns": [ + { + "expression": "clientId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recurring_invoice_status_idx": { + "name": "recurring_invoice_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recurring_invoice_next_due_idx": { + "name": "recurring_invoice_next_due_idx", + "columns": [ + { + "expression": "nextDueAt", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_recurring_invoice_clientId_beenvoice_client_id_fk": { + "name": "beenvoice_recurring_invoice_clientId_beenvoice_client_id_fk", + "tableFrom": "beenvoice_recurring_invoice", + "tableTo": "beenvoice_client", + "columnsFrom": [ + "clientId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "beenvoice_recurring_invoice_businessId_beenvoice_business_id_fk": { + "name": "beenvoice_recurring_invoice_businessId_beenvoice_business_id_fk", + "tableFrom": "beenvoice_recurring_invoice", + "tableTo": "beenvoice_business", + "columnsFrom": [ + "businessId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "beenvoice_recurring_invoice_createdById_beenvoice_user_id_fk": { + "name": "beenvoice_recurring_invoice_createdById_beenvoice_user_id_fk", + "tableFrom": "beenvoice_recurring_invoice", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "createdById" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_session": { + "name": "beenvoice_session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "expiresAt": { + "name": "expiresAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ipAddress": { + "name": "ipAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "userAgent": { + "name": "userAgent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "session_userId_idx": { + "name": "session_userId_idx", + "columns": [ + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_session_userId_beenvoice_user_id_fk": { + "name": "beenvoice_session_userId_beenvoice_user_id_fk", + "tableFrom": "beenvoice_session", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "beenvoice_session_token_unique": { + "name": "beenvoice_session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_sso_provider": { + "name": "beenvoice_sso_provider", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "providerId": { + "name": "providerId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "redirectURI": { + "name": "redirectURI", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "oidcConfig": { + "name": "oidcConfig", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "samlConfig": { + "name": "samlConfig", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sso_provider_user_id_idx": { + "name": "sso_provider_user_id_idx", + "columns": [ + { + "expression": "userId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_sso_provider_userId_beenvoice_user_id_fk": { + "name": "beenvoice_sso_provider_userId_beenvoice_user_id_fk", + "tableFrom": "beenvoice_sso_provider", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "beenvoice_sso_provider_providerId_unique": { + "name": "beenvoice_sso_provider_providerId_unique", + "nullsNotDistinct": false, + "columns": [ + "providerId" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_time_entry": { + "name": "beenvoice_time_entry", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "clientId": { + "name": "clientId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "invoiceId": { + "name": "invoiceId", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "startedAt": { + "name": "startedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "endedAt": { + "name": "endedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "hours": { + "name": "hours", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "rate": { + "name": "rate", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "createdById": { + "name": "createdById", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "time_entry_created_by_idx": { + "name": "time_entry_created_by_idx", + "columns": [ + { + "expression": "createdById", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "time_entry_client_id_idx": { + "name": "time_entry_client_id_idx", + "columns": [ + { + "expression": "clientId", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "time_entry_started_at_idx": { + "name": "time_entry_started_at_idx", + "columns": [ + { + "expression": "startedAt", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "time_entry_ended_at_idx": { + "name": "time_entry_ended_at_idx", + "columns": [ + { + "expression": "endedAt", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "time_entry_one_running_per_user_idx": { + "name": "time_entry_one_running_per_user_idx", + "columns": [ + { + "expression": "createdById", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"beenvoice_time_entry\".\"endedAt\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "beenvoice_time_entry_clientId_beenvoice_client_id_fk": { + "name": "beenvoice_time_entry_clientId_beenvoice_client_id_fk", + "tableFrom": "beenvoice_time_entry", + "tableTo": "beenvoice_client", + "columnsFrom": [ + "clientId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "beenvoice_time_entry_invoiceId_beenvoice_invoice_id_fk": { + "name": "beenvoice_time_entry_invoiceId_beenvoice_invoice_id_fk", + "tableFrom": "beenvoice_time_entry", + "tableTo": "beenvoice_invoice", + "columnsFrom": [ + "invoiceId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "beenvoice_time_entry_createdById_beenvoice_user_id_fk": { + "name": "beenvoice_time_entry_createdById_beenvoice_user_id_fk", + "tableFrom": "beenvoice_time_entry", + "tableTo": "beenvoice_user", + "columnsFrom": [ + "createdById" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_user": { + "name": "beenvoice_user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "emailVerified": { + "name": "emailVerified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "resetToken": { + "name": "resetToken", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "resetTokenExpiry": { + "name": "resetTokenExpiry", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "prefersReducedMotion": { + "name": "prefersReducedMotion", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "animationSpeedMultiplier": { + "name": "animationSpeedMultiplier", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "colorTheme": { + "name": "colorTheme", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'slate'" + }, + "customColor": { + "name": "customColor", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "theme": { + "name": "theme", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "interfaceTheme": { + "name": "interfaceTheme", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'beenvoice'" + }, + "fontPreference": { + "name": "fontPreference", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'brand'" + }, + "bodyFontPreference": { + "name": "bodyFontPreference", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'brand'" + }, + "headingFontPreference": { + "name": "headingFontPreference", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'brand'" + }, + "radiusPreference": { + "name": "radiusPreference", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'xl'" + }, + "sidebarStyle": { + "name": "sidebarStyle", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'floating'" + }, + "role": { + "name": "role", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'user'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "beenvoice_user_email_unique": { + "name": "beenvoice_user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.beenvoice_verification_token": { + "name": "beenvoice_verification_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expiresAt": { + "name": "expiresAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "verification_token_identifier_idx": { + "name": "verification_token_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/package.json b/package.json index bed5c9f..3962c2f 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "check": "eslint . && tsc --noEmit", "db:generate": "drizzle-kit generate", "db:migrate": "bun src/server/db/migrate.ts", + "db:verify-journal": "bun scripts/verify-drizzle-journal.ts", "db:push": "drizzle-kit push", "db:studio": "drizzle-kit studio", "db:clone": "./scripts/clone-local.sh", diff --git a/scripts/verify-drizzle-journal.ts b/scripts/verify-drizzle-journal.ts new file mode 100644 index 0000000..327d423 --- /dev/null +++ b/scripts/verify-drizzle-journal.ts @@ -0,0 +1,54 @@ +/** + * Ensures every drizzle/*.sql migration file has a matching entry in meta/_journal.json. + * Run: bun scripts/verify-drizzle-journal.ts + */ +import { readdirSync, readFileSync } from "fs"; +import path from "path"; + +const drizzleDir = path.resolve(import.meta.dir, "../drizzle"); +const journalPath = path.join(drizzleDir, "meta/_journal.json"); + +const journal = JSON.parse(readFileSync(journalPath, "utf8")) as { + entries: Array<{ idx: number; tag: string }>; +}; + +const sqlTags = readdirSync(drizzleDir) + .filter((name) => /^\d+_.+\.sql$/.test(name)) + .map((name) => name.replace(/\.sql$/, "")) + .sort(); + +const journalTags = journal.entries.map((entry) => entry.tag).sort(); + +const missingFromJournal = sqlTags.filter((tag) => !journalTags.includes(tag)); +const missingSql = journalTags.filter((tag) => !sqlTags.includes(tag)); + +const idxSequence = journal.entries.map((entry) => entry.idx); +const expectedIdx = journal.entries.map((_, i) => i); +const badIdx = idxSequence.some((idx, i) => idx !== expectedIdx[i]); + +let failed = false; + +if (missingFromJournal.length > 0) { + console.error("[verify-drizzle-journal] SQL files missing from journal:"); + for (const tag of missingFromJournal) console.error(` - ${tag}`); + failed = true; +} + +if (missingSql.length > 0) { + console.error("[verify-drizzle-journal] Journal entries without SQL files:"); + for (const tag of missingSql) console.error(` - ${tag}`); + failed = true; +} + +if (badIdx) { + console.error("[verify-drizzle-journal] Journal idx values are not sequential from 0"); + failed = true; +} + +if (failed) { + process.exit(1); +} + +console.log( + `[verify-drizzle-journal] OK — ${sqlTags.length} migrations match journal entries`, +); diff --git a/src/app/auth/register/page.tsx b/src/app/auth/register/page.tsx index 76876e9..6fab12d 100644 --- a/src/app/auth/register/page.tsx +++ b/src/app/auth/register/page.tsx @@ -40,22 +40,44 @@ function RegisterForm() { setLoading(true); - const { error } = await authClient.signUp.email({ - email: trimmedEmail, - password, - name: `${trimmedFirstName} ${trimmedLastName}`, - }); + try { + const res = await fetch("/api/auth/register", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + firstName: trimmedFirstName, + lastName: trimmedLastName, + email: trimmedEmail, + password, + }), + }); - setLoading(false); + const data = (await res.json()) as { error?: string }; - if (error) { - toast.error(error.message ?? "Registration failed"); - return; + if (!res.ok) { + toast.error(data.error ?? "Registration failed"); + return; + } + + const { error: signInError } = await authClient.signIn.email({ + email: trimmedEmail, + password, + }); + + if (signInError) { + toast.success("Account created! Please sign in."); + router.push("/auth/signin"); + return; + } + + toast.success("Account created successfully!"); + router.push("/dashboard"); + router.refresh(); + } catch { + toast.error("Registration failed. Please try again."); + } finally { + setLoading(false); } - - toast.success("Account created successfully!"); - router.push("/dashboard"); - router.refresh(); } return ( diff --git a/src/lib/auth.ts b/src/lib/auth.ts index fb34f13..298090a 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -23,6 +23,9 @@ const authentikOrigin = export const auth = betterAuth({ baseURL: process.env.BETTER_AUTH_URL, secret: process.env.AUTH_SECRET, + experimental: { + joins: true, + }, database: drizzleAdapter(db, { provider: "pg", schema: {