From 577c2217fdcf6fde2d110bb7107be9965812bb27 Mon Sep 17 00:00:00 2001 From: Kemboi Elvis Date: Tue, 19 May 2026 00:27:53 +0300 Subject: [PATCH] feat: updated the db migrations --- ...sql => 0000_outgoing_christian_walker.sql} | 138 +- db/migrations/0001_gifted_secret_warriors.sql | 19 - db/migrations/0002_soft_flamingo.sql | 29 - db/migrations/meta/0000_snapshot.json | 374 +- db/migrations/meta/0001_snapshot.json | 7342 ----------------- db/migrations/meta/0002_snapshot.json | 54 - db/migrations/meta/_journal.json | 20 +- 7 files changed, 396 insertions(+), 7580 deletions(-) rename db/migrations/{0000_flawless_jack_murdock.sql => 0000_outgoing_christian_walker.sql} (89%) delete mode 100644 db/migrations/0001_gifted_secret_warriors.sql delete mode 100644 db/migrations/0002_soft_flamingo.sql delete mode 100644 db/migrations/meta/0001_snapshot.json delete mode 100644 db/migrations/meta/0002_snapshot.json diff --git a/db/migrations/0000_flawless_jack_murdock.sql b/db/migrations/0000_outgoing_christian_walker.sql similarity index 89% rename from db/migrations/0000_flawless_jack_murdock.sql rename to db/migrations/0000_outgoing_christian_walker.sql index 17183b1..5c4eb08 100644 --- a/db/migrations/0000_flawless_jack_murdock.sql +++ b/db/migrations/0000_outgoing_christian_walker.sql @@ -411,6 +411,20 @@ CREATE TABLE "expense_categories" ( "deletedAt" timestamp ); --> statement-breakpoint +CREATE TABLE "expense_items" ( + "id" serial PRIMARY KEY NOT NULL, + "expenseId" bigint NOT NULL, + "itemName" varchar(255) NOT NULL, + "quantity" numeric(10, 3) DEFAULT '1.000' NOT NULL, + "unitPrice" numeric(15, 2) NOT NULL, + "totalPrice" numeric(15, 2) NOT NULL, + "categoryId" bigint NOT NULL, + "notes" text, + "createdAt" timestamp DEFAULT now() NOT NULL, + "updatedAt" timestamp DEFAULT now() NOT NULL, + "deletedAt" timestamp +); +--> statement-breakpoint CREATE TABLE "expenses" ( "id" serial PRIMARY KEY NOT NULL, "locationId" bigint NOT NULL, @@ -1012,8 +1026,27 @@ CREATE TABLE "webhooks" ( "deletedAt" timestamp ); --> statement-breakpoint +ALTER TABLE "accounts" ADD CONSTRAINT "accounts_parentAccountId_accounts_id_fk" FOREIGN KEY ("parentAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "alerts_config" ADD CONSTRAINT "alerts_config_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "alerts_log" ADD CONSTRAINT "alerts_log_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "bill_payments" ADD CONSTRAINT "bill_payments_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "businesses" ADD CONSTRAINT "businesses_accountRefId_customer_accounts_id_fk" FOREIGN KEY ("accountRefId") REFERENCES "public"."customer_accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "daily_mpesa_ledger" ADD CONSTRAINT "daily_mpesa_ledger_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "expense_categories" ADD CONSTRAINT "expense_categories_defaultAccountId_accounts_id_fk" FOREIGN KEY ("defaultAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "expenses" ADD CONSTRAINT "expenses_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "items" ADD CONSTRAINT "items_incomeAccountId_accounts_id_fk" FOREIGN KEY ("incomeAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "items" ADD CONSTRAINT "items_expenseAccountId_accounts_id_fk" FOREIGN KEY ("expenseAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "items" ADD CONSTRAINT "items_assetAccountId_accounts_id_fk" FOREIGN KEY ("assetAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "journal_lines" ADD CONSTRAINT "journal_lines_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "ledger_entries" ADD CONSTRAINT "ledger_entries_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "location_payment_methods" ADD CONSTRAINT "location_payment_methods_linkedAccountId_accounts_id_fk" FOREIGN KEY ("linkedAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "locations" ADD CONSTRAINT "locations_defaultMpesaAccountId_accounts_id_fk" FOREIGN KEY ("defaultMpesaAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "locations" ADD CONSTRAINT "locations_defaultCashAccountId_accounts_id_fk" FOREIGN KEY ("defaultCashAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mpesa_transactions" ADD CONSTRAINT "mpesa_transactions_sourceAccountId_accounts_id_fk" FOREIGN KEY ("sourceAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mpesa_transactions" ADD CONSTRAINT "mpesa_transactions_destinationAccountId_accounts_id_fk" FOREIGN KEY ("destinationAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "payment_methods" ADD CONSTRAINT "payment_methods_accountRefId_customer_accounts_id_fk" FOREIGN KEY ("accountRefId") REFERENCES "public"."customer_accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "recurring_bill_templates" ADD CONSTRAINT "recurring_bill_templates_liabilityAccountId_accounts_id_fk" FOREIGN KEY ("liabilityAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "revenue_categories" ADD CONSTRAINT "revenue_categories_incomeAccountId_accounts_id_fk" FOREIGN KEY ("incomeAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "users" ADD CONSTRAINT "users_accountRefId_customer_accounts_id_fk" FOREIGN KEY ("accountRefId") REFERENCES "public"."customer_accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint CREATE INDEX "idx_accounts_type" ON "accounts" USING btree ("accountType");--> statement-breakpoint CREATE INDEX "idx_accounts_business" ON "accounts" USING btree ("businessId");--> statement-breakpoint @@ -1063,107 +1096,4 @@ CREATE INDEX "idx_users_id" ON "users" USING btree ("id");--> statement-breakpoi CREATE INDEX "idx_users_deletedAt" ON "users" USING btree ("deletedAt");--> statement-breakpoint CREATE INDEX "idx_users_isActive" ON "users" USING btree ("isActive");--> statement-breakpoint CREATE INDEX "idx_users_currentBusinessId" ON "users" USING btree ("currentBusinessId");--> statement-breakpoint -CREATE UNIQUE INDEX "idx_users_username_accountId" ON "users" USING btree ("username","accountId"); - --- ============================================================ --- DOWN: Rollback the entire migration --- Drops all tables and enums created by this migration --- Run this to completely revert the database to a clean state --- ============================================================ - --- Step 1: Drop foreign key constraints -ALTER TABLE IF EXISTS "users" DROP CONSTRAINT IF EXISTS "users_accountRefId_customer_accounts_id_fk"; -ALTER TABLE IF EXISTS "payment_methods" DROP CONSTRAINT IF EXISTS "payment_methods_accountRefId_customer_accounts_id_fk"; -ALTER TABLE IF EXISTS "businesses" DROP CONSTRAINT IF EXISTS "businesses_accountRefId_customer_accounts_id_fk"; - --- Step 2: Drop all tables with CASCADE -DROP TABLE IF EXISTS "accounts" CASCADE; -DROP TABLE IF EXISTS "alerts_config" CASCADE; -DROP TABLE IF EXISTS "alerts_log" CASCADE; -DROP TABLE IF EXISTS "allocation_invites" CASCADE; -DROP TABLE IF EXISTS "api_keys" CASCADE; -DROP TABLE IF EXISTS "app_settings" CASCADE; -DROP TABLE IF EXISTS "attachments" CASCADE; -DROP TABLE IF EXISTS "audit_log" CASCADE; -DROP TABLE IF EXISTS "bill_items" CASCADE; -DROP TABLE IF EXISTS "bill_payments" CASCADE; -DROP TABLE IF EXISTS "bills" CASCADE; -DROP TABLE IF EXISTS "budgets" CASCADE; -DROP TABLE IF EXISTS "business_documents" CASCADE; -DROP TABLE IF EXISTS "business_inquiries" CASCADE; -DROP TABLE IF EXISTS "business_logos" CASCADE; -DROP TABLE IF EXISTS "businesses" CASCADE; -DROP TABLE IF EXISTS "cogs_targets" CASCADE; -DROP TABLE IF EXISTS "customer_accounts" CASCADE; -DROP TABLE IF EXISTS "daily_mpesa_ledger" CASCADE; -DROP TABLE IF EXISTS "daily_sale_payments" CASCADE; -DROP TABLE IF EXISTS "daily_sales" CASCADE; -DROP TABLE IF EXISTS "employees" CASCADE; -DROP TABLE IF EXISTS "expense_categories" CASCADE; -DROP TABLE IF EXISTS "expenses" CASCADE; -DROP TABLE IF EXISTS "external_sync_config" CASCADE; -DROP TABLE IF EXISTS "feedback_questionnaires" CASCADE; -DROP TABLE IF EXISTS "feedback_responses" CASCADE; -DROP TABLE IF EXISTS "financial_reports" CASCADE; -DROP TABLE IF EXISTS "fixed_asset_depreciation" CASCADE; -DROP TABLE IF EXISTS "items" CASCADE; -DROP TABLE IF EXISTS "journal_entries" CASCADE; -DROP TABLE IF EXISTS "journal_lines" CASCADE; -DROP TABLE IF EXISTS "ledger_entries" CASCADE; -DROP TABLE IF EXISTS "location_payment_methods" CASCADE; -DROP TABLE IF EXISTS "locations" CASCADE; -DROP TABLE IF EXISTS "master_items" CASCADE; -DROP TABLE IF EXISTS "mpesa_reconciliation" CASCADE; -DROP TABLE IF EXISTS "mpesa_transactions" CASCADE; -DROP TABLE IF EXISTS "notifications" CASCADE; -DROP TABLE IF EXISTS "partner_allocations" CASCADE; -DROP TABLE IF EXISTS "partner_commissions" CASCADE; -DROP TABLE IF EXISTS "payment_methods" CASCADE; -DROP TABLE IF EXISTS "payroll_advances" CASCADE; -DROP TABLE IF EXISTS "payroll_entries" CASCADE; -DROP TABLE IF EXISTS "payroll_periods" CASCADE; -DROP TABLE IF EXISTS "payroll_settings" CASCADE; -DROP TABLE IF EXISTS "price_alert_rules" CASCADE; -DROP TABLE IF EXISTS "purchase_order_items" CASCADE; -DROP TABLE IF EXISTS "purchase_orders" CASCADE; -DROP TABLE IF EXISTS "push_subscriptions" CASCADE; -DROP TABLE IF EXISTS "quick_actions_log" CASCADE; -DROP TABLE IF EXISTS "recurring_bill_templates" CASCADE; -DROP TABLE IF EXISTS "refresh_tokens" CASCADE; -DROP TABLE IF EXISTS "revenue_categories" CASCADE; -DROP TABLE IF EXISTS "role_permissions" CASCADE; -DROP TABLE IF EXISTS "supplier_price_history" CASCADE; -DROP TABLE IF EXISTS "suppliers" CASCADE; -DROP TABLE IF EXISTS "user_businesses" CASCADE; -DROP TABLE IF EXISTS "users" CASCADE; -DROP TABLE IF EXISTS "webhook_deliveries" CASCADE; -DROP TABLE IF EXISTS "webhooks" CASCADE; - --- Step 3: Drop all custom enum types -DROP TYPE IF EXISTS "public"."accountSubType"; -DROP TYPE IF EXISTS "public"."accountType"; -DROP TYPE IF EXISTS "public"."accountingClass"; -DROP TYPE IF EXISTS "public"."action"; -DROP TYPE IF EXISTS "public"."advanceStatus"; -DROP TYPE IF EXISTS "public"."allocation_invite_status"; -DROP TYPE IF EXISTS "public"."allocation_rights"; -DROP TYPE IF EXISTS "public"."billStatus"; -DROP TYPE IF EXISTS "public"."depreciationMethod"; -DROP TYPE IF EXISTS "public"."entryType"; -DROP TYPE IF EXISTS "public"."frequency"; -DROP TYPE IF EXISTS "public"."itemType"; -DROP TYPE IF EXISTS "public"."leadStatus"; -DROP TYPE IF EXISTS "public"."orderStatus"; -DROP TYPE IF EXISTS "public"."partner_allocation_status"; -DROP TYPE IF EXISTS "public"."paymentMethod"; -DROP TYPE IF EXISTS "public"."paymentMethod2"; -DROP TYPE IF EXISTS "public"."payrollStatus"; -DROP TYPE IF EXISTS "public"."revenueCategoryType"; -DROP TYPE IF EXISTS "public"."role"; -DROP TYPE IF EXISTS "public"."salaryType"; -DROP TYPE IF EXISTS "public"."severity"; -DROP TYPE IF EXISTS "public"."status"; -DROP TYPE IF EXISTS "public"."transactionType"; -DROP TYPE IF EXISTS "public"."txnType"; -DROP TYPE IF EXISTS "public"."type"; -DROP TYPE IF EXISTS "public"."user_type"; +CREATE UNIQUE INDEX "idx_users_username_accountId" ON "users" USING btree ("username","accountId"); \ No newline at end of file diff --git a/db/migrations/0001_gifted_secret_warriors.sql b/db/migrations/0001_gifted_secret_warriors.sql deleted file mode 100644 index d092ccf..0000000 --- a/db/migrations/0001_gifted_secret_warriors.sql +++ /dev/null @@ -1,19 +0,0 @@ -ALTER TABLE "accounts" ADD CONSTRAINT "accounts_parentAccountId_accounts_id_fk" FOREIGN KEY ("parentAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "alerts_config" ADD CONSTRAINT "alerts_config_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "alerts_log" ADD CONSTRAINT "alerts_log_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "bill_payments" ADD CONSTRAINT "bill_payments_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "daily_mpesa_ledger" ADD CONSTRAINT "daily_mpesa_ledger_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "expense_categories" ADD CONSTRAINT "expense_categories_defaultAccountId_accounts_id_fk" FOREIGN KEY ("defaultAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "expenses" ADD CONSTRAINT "expenses_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "items" ADD CONSTRAINT "items_incomeAccountId_accounts_id_fk" FOREIGN KEY ("incomeAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "items" ADD CONSTRAINT "items_expenseAccountId_accounts_id_fk" FOREIGN KEY ("expenseAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "items" ADD CONSTRAINT "items_assetAccountId_accounts_id_fk" FOREIGN KEY ("assetAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "journal_lines" ADD CONSTRAINT "journal_lines_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "ledger_entries" ADD CONSTRAINT "ledger_entries_accountId_accounts_id_fk" FOREIGN KEY ("accountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "location_payment_methods" ADD CONSTRAINT "location_payment_methods_linkedAccountId_accounts_id_fk" FOREIGN KEY ("linkedAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "locations" ADD CONSTRAINT "locations_defaultMpesaAccountId_accounts_id_fk" FOREIGN KEY ("defaultMpesaAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "locations" ADD CONSTRAINT "locations_defaultCashAccountId_accounts_id_fk" FOREIGN KEY ("defaultCashAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "mpesa_transactions" ADD CONSTRAINT "mpesa_transactions_sourceAccountId_accounts_id_fk" FOREIGN KEY ("sourceAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "mpesa_transactions" ADD CONSTRAINT "mpesa_transactions_destinationAccountId_accounts_id_fk" FOREIGN KEY ("destinationAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "recurring_bill_templates" ADD CONSTRAINT "recurring_bill_templates_liabilityAccountId_accounts_id_fk" FOREIGN KEY ("liabilityAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "revenue_categories" ADD CONSTRAINT "revenue_categories_incomeAccountId_accounts_id_fk" FOREIGN KEY ("incomeAccountId") REFERENCES "public"."accounts"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/db/migrations/0002_soft_flamingo.sql b/db/migrations/0002_soft_flamingo.sql deleted file mode 100644 index 649108d..0000000 --- a/db/migrations/0002_soft_flamingo.sql +++ /dev/null @@ -1,29 +0,0 @@ --- Migration: Add expense_items table for expense line items with multiple categories --- Created for: Multi-category expense support - -CREATE TABLE IF NOT EXISTS "expense_items" ( - "id" serial PRIMARY KEY, - "expenseId" bigint NOT NULL, - "itemName" varchar(255) NOT NULL, - "quantity" numeric(10, 3) DEFAULT '1.000' NOT NULL, - "unitPrice" numeric(15, 2) NOT NULL, - "totalPrice" numeric(15, 2) NOT NULL, - "categoryId" bigint NOT NULL, - "notes" text, - "createdAt" timestamp DEFAULT now() NOT NULL, - "updatedAt" timestamp DEFAULT now() NOT NULL, - "deletedAt" timestamp -); - --- Index for querying items by expense -CREATE INDEX IF NOT EXISTS "expense_items_expense_id_idx" ON "expense_items" ("expenseId"); -CREATE INDEX IF NOT EXISTS "expense_items_category_id_idx" ON "expense_items" ("categoryId"); -CREATE INDEX IF NOT EXISTS "expense_items_deleted_at_idx" ON "expense_items" ("deletedAt"); - --- Add foreign key constraint -ALTER TABLE "expense_items" ADD CONSTRAINT "expense_items_expense_id_fkey" FOREIGN KEY ("expenseId") REFERENCES "expenses"("id") ON DELETE NO ACTION; -ALTER TABLE "expense_items" ADD CONSTRAINT "expense_items_category_id_fkey" FOREIGN KEY ("categoryId") REFERENCES "expense_categories"("id") ON DELETE NO ACTION; - -COMMENT ON TABLE "expense_items" IS 'Line items for expenses with multiple category support'; -COMMENT ON COLUMN "expense_items"."expenseId" IS 'Reference to the parent expense'; -COMMENT ON COLUMN "expense_items"."categoryId" IS 'Category for this line item (allows different categories per expense)'; diff --git a/db/migrations/meta/0000_snapshot.json b/db/migrations/meta/0000_snapshot.json index 51b1855..2653557 100644 --- a/db/migrations/meta/0000_snapshot.json +++ b/db/migrations/meta/0000_snapshot.json @@ -1,5 +1,5 @@ { - "id": "99a6836b-010f-4916-b472-463840468a0b", + "id": "af10a21a-5f50-4ea1-ae7d-06aeb70d7194", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", @@ -224,7 +224,21 @@ "with": {} } }, - "foreignKeys": {}, + "foreignKeys": { + "accounts_parentAccountId_accounts_id_fk": { + "name": "accounts_parentAccountId_accounts_id_fk", + "tableFrom": "accounts", + "tableTo": "accounts", + "columnsFrom": [ + "parentAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -295,7 +309,21 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "alerts_config_accountId_accounts_id_fk": { + "name": "alerts_config_accountId_accounts_id_fk", + "tableFrom": "alerts_config", + "tableTo": "accounts", + "columnsFrom": [ + "accountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -366,7 +394,21 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "alerts_log_accountId_accounts_id_fk": { + "name": "alerts_log_accountId_accounts_id_fk", + "tableFrom": "alerts_log", + "tableTo": "accounts", + "columnsFrom": [ + "accountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -983,7 +1025,21 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "bill_payments_accountId_accounts_id_fk": { + "name": "bill_payments_accountId_accounts_id_fk", + "tableFrom": "bill_payments", + "tableTo": "accounts", + "columnsFrom": [ + "accountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -2056,7 +2112,21 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "daily_mpesa_ledger_accountId_accounts_id_fk": { + "name": "daily_mpesa_ledger_accountId_accounts_id_fk", + "tableFrom": "daily_mpesa_ledger", + "tableTo": "accounts", + "columnsFrom": [ + "accountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -2566,6 +2636,102 @@ "with": {} } }, + "foreignKeys": { + "expense_categories_defaultAccountId_accounts_id_fk": { + "name": "expense_categories_defaultAccountId_accounts_id_fk", + "tableFrom": "expense_categories", + "tableTo": "accounts", + "columnsFrom": [ + "defaultAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.expense_items": { + "name": "expense_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "expenseId": { + "name": "expenseId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "itemName": { + "name": "itemName", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 3)", + "primaryKey": false, + "notNull": true, + "default": "'1.000'" + }, + "unitPrice": { + "name": "unitPrice", + "type": "numeric(15, 2)", + "primaryKey": false, + "notNull": true + }, + "totalPrice": { + "name": "totalPrice", + "type": "numeric(15, 2)", + "primaryKey": false, + "notNull": true + }, + "categoryId": { + "name": "categoryId", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "notes": { + "name": "notes", + "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()" + }, + "deletedAt": { + "name": "deletedAt", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": {}, @@ -2765,7 +2931,21 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "expenses_accountId_accounts_id_fk": { + "name": "expenses_accountId_accounts_id_fk", + "tableFrom": "expenses", + "tableTo": "accounts", + "columnsFrom": [ + "accountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -3481,7 +3661,47 @@ "with": {} } }, - "foreignKeys": {}, + "foreignKeys": { + "items_incomeAccountId_accounts_id_fk": { + "name": "items_incomeAccountId_accounts_id_fk", + "tableFrom": "items", + "tableTo": "accounts", + "columnsFrom": [ + "incomeAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "items_expenseAccountId_accounts_id_fk": { + "name": "items_expenseAccountId_accounts_id_fk", + "tableFrom": "items", + "tableTo": "accounts", + "columnsFrom": [ + "expenseAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "items_assetAccountId_accounts_id_fk": { + "name": "items_assetAccountId_accounts_id_fk", + "tableFrom": "items", + "tableTo": "accounts", + "columnsFrom": [ + "assetAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": { "items_sku_unique": { @@ -3802,7 +4022,21 @@ "with": {} } }, - "foreignKeys": {}, + "foreignKeys": { + "journal_lines_accountId_accounts_id_fk": { + "name": "journal_lines_accountId_accounts_id_fk", + "tableFrom": "journal_lines", + "tableTo": "accounts", + "columnsFrom": [ + "accountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -3896,7 +4130,21 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "ledger_entries_accountId_accounts_id_fk": { + "name": "ledger_entries_accountId_accounts_id_fk", + "tableFrom": "ledger_entries", + "tableTo": "accounts", + "columnsFrom": [ + "accountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -3947,7 +4195,21 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "location_payment_methods_linkedAccountId_accounts_id_fk": { + "name": "location_payment_methods_linkedAccountId_accounts_id_fk", + "tableFrom": "location_payment_methods", + "tableTo": "accounts", + "columnsFrom": [ + "linkedAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -4097,7 +4359,34 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "locations_defaultMpesaAccountId_accounts_id_fk": { + "name": "locations_defaultMpesaAccountId_accounts_id_fk", + "tableFrom": "locations", + "tableTo": "accounts", + "columnsFrom": [ + "defaultMpesaAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "locations_defaultCashAccountId_accounts_id_fk": { + "name": "locations_defaultCashAccountId_accounts_id_fk", + "tableFrom": "locations", + "tableTo": "accounts", + "columnsFrom": [ + "defaultCashAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": { "locations_slug_unique": { @@ -4413,7 +4702,34 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "mpesa_transactions_sourceAccountId_accounts_id_fk": { + "name": "mpesa_transactions_sourceAccountId_accounts_id_fk", + "tableFrom": "mpesa_transactions", + "tableTo": "accounts", + "columnsFrom": [ + "sourceAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "mpesa_transactions_destinationAccountId_accounts_id_fk": { + "name": "mpesa_transactions_destinationAccountId_accounts_id_fk", + "tableFrom": "mpesa_transactions", + "tableTo": "accounts", + "columnsFrom": [ + "destinationAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": { "mpesa_transactions_txnId_unique": { @@ -5798,7 +6114,21 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "recurring_bill_templates_liabilityAccountId_accounts_id_fk": { + "name": "recurring_bill_templates_liabilityAccountId_accounts_id_fk", + "tableFrom": "recurring_bill_templates", + "tableTo": "accounts", + "columnsFrom": [ + "liabilityAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, @@ -6013,7 +6343,21 @@ "with": {} } }, - "foreignKeys": {}, + "foreignKeys": { + "revenue_categories_incomeAccountId_accounts_id_fk": { + "name": "revenue_categories_incomeAccountId_accounts_id_fk", + "tableFrom": "revenue_categories", + "tableTo": "accounts", + "columnsFrom": [ + "incomeAccountId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, diff --git a/db/migrations/meta/0001_snapshot.json b/db/migrations/meta/0001_snapshot.json deleted file mode 100644 index 3a2ea95..0000000 --- a/db/migrations/meta/0001_snapshot.json +++ /dev/null @@ -1,7342 +0,0 @@ -{ - "id": "768f881e-c5f3-4dc0-961f-459a816e8d1b", - "prevId": "99a6836b-010f-4916-b472-463840468a0b", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.accounts": { - "name": "accounts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "accountCode": { - "name": "accountCode", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "accountNumber": { - "name": "accountNumber", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "systemKey": { - "name": "systemKey", - "type": "varchar(120)", - "primaryKey": false, - "notNull": false - }, - "accountType": { - "name": "accountType", - "type": "accountType", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "accountSubType": { - "name": "accountSubType", - "type": "accountSubType", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "openingBalance": { - "name": "openingBalance", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "currentBalance": { - "name": "currentBalance", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "currency": { - "name": "currency", - "type": "varchar(3)", - "primaryKey": false, - "notNull": true, - "default": "'KES'" - }, - "isPaymentMethod": { - "name": "isPaymentMethod", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "isSystemGenerated": { - "name": "isSystemGenerated", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "isContra": { - "name": "isContra", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "parentAccountId": { - "name": "parentAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "externalId": { - "name": "externalId", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "externalSystem": { - "name": "externalSystem", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "lastSyncedAt": { - "name": "lastSyncedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_accounts_type": { - "name": "idx_accounts_type", - "columns": [ - { - "expression": "accountType", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_accounts_business": { - "name": "idx_accounts_business", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "uq_accounts_business_system_key": { - "name": "uq_accounts_business_system_key", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "systemKey", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "accounts_parentAccountId_accounts_id_fk": { - "name": "accounts_parentAccountId_accounts_id_fk", - "tableFrom": "accounts", - "tableTo": "accounts", - "columnsFrom": [ - "parentAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.alerts_config": { - "name": "alerts_config", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "accountId": { - "name": "accountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "minBalance": { - "name": "minBalance", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'10000.00'" - }, - "notifyEmail": { - "name": "notifyEmail", - "type": "varchar(320)", - "primaryKey": false, - "notNull": false - }, - "notifyPhone": { - "name": "notifyPhone", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "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": { - "alerts_config_accountId_accounts_id_fk": { - "name": "alerts_config_accountId_accounts_id_fk", - "tableFrom": "alerts_config", - "tableTo": "accounts", - "columnsFrom": [ - "accountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.alerts_log": { - "name": "alerts_log", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "type": { - "name": "type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "severity": { - "name": "severity", - "type": "severity", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'info'" - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "accountId": { - "name": "accountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "isRead": { - "name": "isRead", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "alerts_log_accountId_accounts_id_fk": { - "name": "alerts_log_accountId_accounts_id_fk", - "tableFrom": "alerts_log", - "tableTo": "accounts", - "columnsFrom": [ - "accountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.allocation_invites": { - "name": "allocation_invites", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "code": { - "name": "code", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true - }, - "ownerAccountId": { - "name": "ownerAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "rightsProfile": { - "name": "rightsProfile", - "type": "allocation_rights", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "allocation_invite_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "createdBy": { - "name": "createdBy", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "consumedByPartnerAccountId": { - "name": "consumedByPartnerAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "consumedByPartnerUserId": { - "name": "consumedByPartnerUserId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "consumedAt": { - "name": "consumedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "revokedAt": { - "name": "revokedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "expiresAt": { - "name": "expiresAt", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "uq_allocation_invites_code": { - "name": "uq_allocation_invites_code", - "columns": [ - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_allocation_invites_ownerAccountId": { - "name": "idx_allocation_invites_ownerAccountId", - "columns": [ - { - "expression": "ownerAccountId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_allocation_invites_businessId": { - "name": "idx_allocation_invites_businessId", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_allocation_invites_status": { - "name": "idx_allocation_invites_status", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_allocation_invites_deletedAt": { - "name": "idx_allocation_invites_deletedAt", - "columns": [ - { - "expression": "deletedAt", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.api_keys": { - "name": "api_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "keyHash": { - "name": "keyHash", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "keyPrefix": { - "name": "keyPrefix", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true - }, - "scopes": { - "name": "scopes", - "type": "json", - "primaryKey": false, - "notNull": false - }, - "lastUsedAt": { - "name": "lastUsedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_settings": { - "name": "app_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "key": { - "name": "key", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "updatedAt": { - "name": "updatedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.attachments": { - "name": "attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "recordType": { - "name": "recordType", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "recordId": { - "name": "recordId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "imageData": { - "name": "imageData", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mimeType": { - "name": "mimeType", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'image/jpeg'" - }, - "caption": { - "name": "caption", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.audit_log": { - "name": "audit_log", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "tableName": { - "name": "tableName", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "recordId": { - "name": "recordId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "action", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "oldValues": { - "name": "oldValues", - "type": "json", - "primaryKey": false, - "notNull": false - }, - "newValues": { - "name": "newValues", - "type": "json", - "primaryKey": false, - "notNull": false - }, - "changedBy": { - "name": "changedBy", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "ipAddress": { - "name": "ipAddress", - "type": "varchar(45)", - "primaryKey": false, - "notNull": false - }, - "userAgent": { - "name": "userAgent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.bill_items": { - "name": "bill_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "billId": { - "name": "billId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "itemName": { - "name": "itemName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "numeric(10, 3)", - "primaryKey": false, - "notNull": true, - "default": "'1.000'" - }, - "unitPrice": { - "name": "unitPrice", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "totalPrice": { - "name": "totalPrice", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "categoryId": { - "name": "categoryId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.bill_payments": { - "name": "bill_payments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "billId": { - "name": "billId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "paymentMethod": { - "name": "paymentMethod", - "type": "paymentMethod2", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "paymentDate": { - "name": "paymentDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "reference": { - "name": "reference", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "accountId": { - "name": "accountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "journalEntryId": { - "name": "journalEntryId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "enteredBy": { - "name": "enteredBy", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "bill_payments_accountId_accounts_id_fk": { - "name": "bill_payments_accountId_accounts_id_fk", - "tableFrom": "bill_payments", - "tableTo": "accounts", - "columnsFrom": [ - "accountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.bills": { - "name": "bills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "supplierId": { - "name": "supplierId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "categoryId": { - "name": "categoryId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "billNumber": { - "name": "billNumber", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "amountPaid": { - "name": "amountPaid", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "balanceDue": { - "name": "balanceDue", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "issueDate": { - "name": "issueDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "dueDate": { - "name": "dueDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "billStatus", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "journalEntryId": { - "name": "journalEntryId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "reversedAt": { - "name": "reversedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "reversedBy": { - "name": "reversedBy", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.budgets": { - "name": "budgets", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "categoryId": { - "name": "categoryId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "month": { - "name": "month", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "notes": { - "name": "notes", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.business_documents": { - "name": "business_documents", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "documentType": { - "name": "documentType", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "fileName": { - "name": "fileName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "fileData": { - "name": "fileData", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mimeType": { - "name": "mimeType", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploadedBy": { - "name": "uploadedBy", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.business_inquiries": { - "name": "business_inquiries", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessName": { - "name": "businessName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "contactName": { - "name": "contactName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "varchar(320)", - "primaryKey": false, - "notNull": true - }, - "phone": { - "name": "phone", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "position": { - "name": "position", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "suggestedPrice": { - "name": "suggestedPrice", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "leadStatus", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'new'" - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.business_logos": { - "name": "business_logos", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "fileName": { - "name": "fileName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "mimeType": { - "name": "mimeType", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "fileData": { - "name": "fileData", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "width": { - "name": "width", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "height": { - "name": "height", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "sizeBytes": { - "name": "sizeBytes", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "uploadedBy": { - "name": "uploadedBy", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_business_logos_businessId": { - "name": "idx_business_logos_businessId", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_business_logos_isActive": { - "name": "idx_business_logos_isActive", - "columns": [ - { - "expression": "isActive", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_business_logos_uploadedBy": { - "name": "idx_business_logos_uploadedBy", - "columns": [ - { - "expression": "uploadedBy", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_business_logos_deletedAt": { - "name": "idx_business_logos_deletedAt", - "columns": [ - { - "expression": "deletedAt", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.businesses": { - "name": "businesses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "accountId": { - "name": "accountId", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "accountRefId": { - "name": "accountRefId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "businessType": { - "name": "businessType", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "country": { - "name": "country", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "county": { - "name": "county", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "subCounty": { - "name": "subCounty", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "address": { - "name": "address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "businessRegNumber": { - "name": "businessRegNumber", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "natureOfBusiness": { - "name": "natureOfBusiness", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "kraPin": { - "name": "kraPin", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "maxBranches": { - "name": "maxBranches", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 1 - }, - "maxUsers": { - "name": "maxUsers", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 1 - }, - "maxTransactionsPerMonth": { - "name": "maxTransactionsPerMonth", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 100 - }, - "features": { - "name": "features", - "type": "json", - "primaryKey": false, - "notNull": false - }, - "subscriptionStatus": { - "name": "subscriptionStatus", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'active'" - }, - "subscriptionExpiry": { - "name": "subscriptionExpiry", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "isMultiLocation": { - "name": "isMultiLocation", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "isDemo": { - "name": "isDemo", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "isWhiteLabel": { - "name": "isWhiteLabel", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "whiteLabelDomain": { - "name": "whiteLabelDomain", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "referralCode": { - "name": "referralCode", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "referredByBusinessId": { - "name": "referredByBusinessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "referredByUserId": { - "name": "referredByUserId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "firstMonthDiscountApplied": { - "name": "firstMonthDiscountApplied", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "partnerId": { - "name": "partnerId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "revSharePercent": { - "name": "revSharePercent", - "type": "numeric(5, 2)", - "primaryKey": false, - "notNull": false, - "default": "'20.00'" - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updatedAt": { - "name": "updatedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "businesses_accountRefId_customer_accounts_id_fk": { - "name": "businesses_accountRefId_customer_accounts_id_fk", - "tableFrom": "businesses", - "tableTo": "customer_accounts", - "columnsFrom": [ - "accountRefId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "businesses_slug_unique": { - "name": "businesses_slug_unique", - "nullsNotDistinct": false, - "columns": [ - "slug" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.cogs_targets": { - "name": "cogs_targets", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "targetFoodCostPercent": { - "name": "targetFoodCostPercent", - "type": "numeric(5, 2)", - "primaryKey": false, - "notNull": false, - "default": "'35.00'" - }, - "alertThresholdPercent": { - "name": "alertThresholdPercent", - "type": "numeric(5, 2)", - "primaryKey": false, - "notNull": false, - "default": "'38.00'" - }, - "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.customer_accounts": { - "name": "customer_accounts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "accountId": { - "name": "accountId", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "plan": { - "name": "plan", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "maxBusinesses": { - "name": "maxBusinesses", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "maxUsers": { - "name": "maxUsers", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "maxTransactionsPerMonth": { - "name": "maxTransactionsPerMonth", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 100 - }, - "features": { - "name": "features", - "type": "json", - "primaryKey": false, - "notNull": false - }, - "subscriptionStatus": { - "name": "subscriptionStatus", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "subscriptionExpiry": { - "name": "subscriptionExpiry", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "migratedAt": { - "name": "migratedAt", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_customer_accounts_accountId": { - "name": "idx_customer_accounts_accountId", - "columns": [ - { - "expression": "accountId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.daily_mpesa_ledger": { - "name": "daily_mpesa_ledger", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "accountId": { - "name": "accountId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "ledgerDate": { - "name": "ledgerDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "openingBalance": { - "name": "openingBalance", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "totalTopups": { - "name": "totalTopups", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "totalExpenditures": { - "name": "totalExpenditures", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "totalFees": { - "name": "totalFees", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "closingBalance": { - "name": "closingBalance", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "transactionCount": { - "name": "transactionCount", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "enteredBy": { - "name": "enteredBy", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "daily_mpesa_ledger_accountId_accounts_id_fk": { - "name": "daily_mpesa_ledger_accountId_accounts_id_fk", - "tableFrom": "daily_mpesa_ledger", - "tableTo": "accounts", - "columnsFrom": [ - "accountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.daily_sale_payments": { - "name": "daily_sale_payments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "dailySaleId": { - "name": "dailySaleId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "paymentMethodId": { - "name": "paymentMethodId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.daily_sales": { - "name": "daily_sales", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "saleDate": { - "name": "saleDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "cashTotal": { - "name": "cashTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "cardTotal": { - "name": "cardTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "mpesaTotal": { - "name": "mpesaTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "familyBankTotal": { - "name": "familyBankTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "coopBankTotal": { - "name": "coopBankTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "equityBankTotal": { - "name": "equityBankTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "boltTotal": { - "name": "boltTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "glovoTotal": { - "name": "glovoTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "creditCardTotal": { - "name": "creditCardTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "deliveryPartnerTotal": { - "name": "deliveryPartnerTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "netSales": { - "name": "netSales", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "discountAmount": { - "name": "discountAmount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "voidAmount": { - "name": "voidAmount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "unpaidAmount": { - "name": "unpaidAmount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "ticketCount": { - "name": "ticketCount", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "orderCount": { - "name": "orderCount", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "voidCount": { - "name": "voidCount", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "giftCount": { - "name": "giftCount", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "unpaidNotes": { - "name": "unpaidNotes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "enteredBy": { - "name": "enteredBy", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.employees": { - "name": "employees", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "fullName": { - "name": "fullName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "phone": { - "name": "phone", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true - }, - "idNumber": { - "name": "idNumber", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "kraPin": { - "name": "kraPin", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "nssfNumber": { - "name": "nssfNumber", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "nhifNumber": { - "name": "nhifNumber", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "salaryType": { - "name": "salaryType", - "type": "salaryType", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "basicSalary": { - "name": "basicSalary", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "bankName": { - "name": "bankName", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "bankAccount": { - "name": "bankAccount", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "bankCode": { - "name": "bankCode", - "type": "varchar(10)", - "primaryKey": false, - "notNull": false - }, - "employmentDate": { - "name": "employmentDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "terminationDate": { - "name": "terminationDate", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.expense_categories": { - "name": "expense_categories", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "color": { - "name": "color", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'#C73E1D'" - }, - "accountingClass": { - "name": "accountingClass", - "type": "accountingClass", - "typeSchema": "public", - "primaryKey": false, - "notNull": false, - "default": "'operating_expense'" - }, - "defaultAccountId": { - "name": "defaultAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "externalAccountCode": { - "name": "externalAccountCode", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "externalSystem": { - "name": "externalSystem", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_expense_category_business": { - "name": "idx_expense_category_business", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_expense_categories_default_account": { - "name": "idx_expense_categories_default_account", - "columns": [ - { - "expression": "defaultAccountId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "expense_categories_defaultAccountId_accounts_id_fk": { - "name": "expense_categories_defaultAccountId_accounts_id_fk", - "tableFrom": "expense_categories", - "tableTo": "accounts", - "columnsFrom": [ - "defaultAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.expenses": { - "name": "expenses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "categoryId": { - "name": "categoryId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "supplierId": { - "name": "supplierId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "expenseNumber": { - "name": "expenseNumber", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "billId": { - "name": "billId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "refNo": { - "name": "refNo", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "amount": { - "name": "amount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "expenseDate": { - "name": "expenseDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "paymentMethod": { - "name": "paymentMethod", - "type": "paymentMethod2", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "accountId": { - "name": "accountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "receiptImageUrl": { - "name": "receiptImageUrl", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "mpesaTxnId": { - "name": "mpesaTxnId", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "expenseRef": { - "name": "expenseRef", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "isReimbursable": { - "name": "isReimbursable", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "reimbursedTo": { - "name": "reimbursedTo", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "isFixedAsset": { - "name": "isFixedAsset", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "fixedAssetItemId": { - "name": "fixedAssetItemId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "usefulLifeMonths": { - "name": "usefulLifeMonths", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "depreciationMethod": { - "name": "depreciationMethod", - "type": "depreciationMethod", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "salvageValue": { - "name": "salvageValue", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "journalEntryId": { - "name": "journalEntryId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "reversedAt": { - "name": "reversedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "reversedBy": { - "name": "reversedBy", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "enteredBy": { - "name": "enteredBy", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "expenses_accountId_accounts_id_fk": { - "name": "expenses_accountId_accounts_id_fk", - "tableFrom": "expenses", - "tableTo": "accounts", - "columnsFrom": [ - "accountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.external_sync_config": { - "name": "external_sync_config", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "systemName": { - "name": "systemName", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "config": { - "name": "config", - "type": "json", - "primaryKey": false, - "notNull": true - }, - "lastSyncAt": { - "name": "lastSyncAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "syncStatus": { - "name": "syncStatus", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'idle'" - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updatedAt": { - "name": "updatedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_sync_config_business_system": { - "name": "idx_sync_config_business_system", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "systemName", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.feedback_questionnaires": { - "name": "feedback_questionnaires", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "title": { - "name": "title", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "questions": { - "name": "questions", - "type": "json", - "primaryKey": false, - "notNull": true - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.feedback_responses": { - "name": "feedback_responses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "questionnaireId": { - "name": "questionnaireId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "respondentName": { - "name": "respondentName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "respondentEmail": { - "name": "respondentEmail", - "type": "varchar(320)", - "primaryKey": false, - "notNull": false - }, - "answers": { - "name": "answers", - "type": "json", - "primaryKey": false, - "notNull": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.financial_reports": { - "name": "financial_reports", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "reportType": { - "name": "reportType", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "periodStart": { - "name": "periodStart", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "periodEnd": { - "name": "periodEnd", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "reportData": { - "name": "reportData", - "type": "json", - "primaryKey": false, - "notNull": true - }, - "reportMetadata": { - "name": "reportMetadata", - "type": "json", - "primaryKey": false, - "notNull": false - }, - "generatedBy": { - "name": "generatedBy", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "generatedAt": { - "name": "generatedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_financial_report_business": { - "name": "idx_financial_report_business", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_financial_report_type_period": { - "name": "idx_financial_report_type_period", - "columns": [ - { - "expression": "reportType", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "periodStart", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "periodEnd", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.fixed_asset_depreciation": { - "name": "fixed_asset_depreciation", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "itemId": { - "name": "itemId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "journalEntryId": { - "name": "journalEntryId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "periodYear": { - "name": "periodYear", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "periodMonth": { - "name": "periodMonth", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "depreciationAmount": { - "name": "depreciationAmount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "accumulatedAfter": { - "name": "accumulatedAfter", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "bookValueAfter": { - "name": "bookValueAfter", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "isPosted": { - "name": "isPosted", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_depreciation_item": { - "name": "idx_depreciation_item", - "columns": [ - { - "expression": "itemId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_depreciation_period": { - "name": "idx_depreciation_period", - "columns": [ - { - "expression": "periodYear", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "periodMonth", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_depreciation_item_period": { - "name": "idx_depreciation_item_period", - "columns": [ - { - "expression": "itemId", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "periodYear", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "periodMonth", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.items": { - "name": "items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sku": { - "name": "sku", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "itemType": { - "name": "itemType", - "type": "itemType", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "incomeAccountId": { - "name": "incomeAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "expenseAccountId": { - "name": "expenseAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "assetAccountId": { - "name": "assetAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "isFixedAsset": { - "name": "isFixedAsset", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "purchaseDate": { - "name": "purchaseDate", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "purchasePrice": { - "name": "purchasePrice", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "usefulLifeMonths": { - "name": "usefulLifeMonths", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "depreciationMethod": { - "name": "depreciationMethod", - "type": "depreciationMethod", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "salvageValue": { - "name": "salvageValue", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "accumulatedDepreciation": { - "name": "accumulatedDepreciation", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "currentBookValue": { - "name": "currentBookValue", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "disposalDate": { - "name": "disposalDate", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "disposalValue": { - "name": "disposalValue", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "unitCost": { - "name": "unitCost", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "unitPrice": { - "name": "unitPrice", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "currentStock": { - "name": "currentStock", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0'" - }, - "reorderLevel": { - "name": "reorderLevel", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "taxRate": { - "name": "taxRate", - "type": "numeric(5, 2)", - "primaryKey": false, - "notNull": false - }, - "externalId": { - "name": "externalId", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "externalSystem": { - "name": "externalSystem", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "lastSyncedAt": { - "name": "lastSyncedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updatedAt": { - "name": "updatedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_items_sku": { - "name": "idx_items_sku", - "columns": [ - { - "expression": "sku", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_items_business": { - "name": "idx_items_business", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_items_type": { - "name": "idx_items_type", - "columns": [ - { - "expression": "itemType", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "items_incomeAccountId_accounts_id_fk": { - "name": "items_incomeAccountId_accounts_id_fk", - "tableFrom": "items", - "tableTo": "accounts", - "columnsFrom": [ - "incomeAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "items_expenseAccountId_accounts_id_fk": { - "name": "items_expenseAccountId_accounts_id_fk", - "tableFrom": "items", - "tableTo": "accounts", - "columnsFrom": [ - "expenseAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "items_assetAccountId_accounts_id_fk": { - "name": "items_assetAccountId_accounts_id_fk", - "tableFrom": "items", - "tableTo": "accounts", - "columnsFrom": [ - "assetAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "items_sku_unique": { - "name": "items_sku_unique", - "nullsNotDistinct": false, - "columns": [ - "sku" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.journal_entries": { - "name": "journal_entries", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "entryNumber": { - "name": "entryNumber", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "entryDate": { - "name": "entryDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "reference": { - "name": "reference", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "sourceType": { - "name": "sourceType", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "sourceId": { - "name": "sourceId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "isPosted": { - "name": "isPosted", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "postedBy": { - "name": "postedBy", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "postedAt": { - "name": "postedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "isReversed": { - "name": "isReversed", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "reversedBy": { - "name": "reversedBy", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "reversalOf": { - "name": "reversalOf", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "externalId": { - "name": "externalId", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "externalSystem": { - "name": "externalSystem", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "createdBy": { - "name": "createdBy", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updatedAt": { - "name": "updatedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_journal_entry_number": { - "name": "idx_journal_entry_number", - "columns": [ - { - "expression": "entryNumber", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_journal_entry_date": { - "name": "idx_journal_entry_date", - "columns": [ - { - "expression": "entryDate", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_journal_entry_source": { - "name": "idx_journal_entry_source", - "columns": [ - { - "expression": "sourceType", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "sourceId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_journal_entry_business": { - "name": "idx_journal_entry_business", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "journal_entries_entryNumber_unique": { - "name": "journal_entries_entryNumber_unique", - "nullsNotDistinct": false, - "columns": [ - "entryNumber" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.journal_lines": { - "name": "journal_lines", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "journalEntryId": { - "name": "journalEntryId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "accountId": { - "name": "accountId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "debit": { - "name": "debit", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "credit": { - "name": "credit", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lineNumber": { - "name": "lineNumber", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_journal_line_entry": { - "name": "idx_journal_line_entry", - "columns": [ - { - "expression": "journalEntryId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_journal_line_account": { - "name": "idx_journal_line_account", - "columns": [ - { - "expression": "accountId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "journal_lines_accountId_accounts_id_fk": { - "name": "journal_lines_accountId_accounts_id_fk", - "tableFrom": "journal_lines", - "tableTo": "accounts", - "columnsFrom": [ - "accountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.ledger_entries": { - "name": "ledger_entries", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "accountId": { - "name": "accountId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "transactionType": { - "name": "transactionType", - "type": "transactionType", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "transactionId": { - "name": "transactionId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "entryType": { - "name": "entryType", - "type": "entryType", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "balanceAfter": { - "name": "balanceAfter", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "refNo": { - "name": "refNo", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "entryDate": { - "name": "entryDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "createdBy": { - "name": "createdBy", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "ledger_entries_accountId_accounts_id_fk": { - "name": "ledger_entries_accountId_accounts_id_fk", - "tableFrom": "ledger_entries", - "tableTo": "accounts", - "columnsFrom": [ - "accountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.location_payment_methods": { - "name": "location_payment_methods", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "paymentMethodId": { - "name": "paymentMethodId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "linkedAccountId": { - "name": "linkedAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "location_payment_methods_linkedAccountId_accounts_id_fk": { - "name": "location_payment_methods_linkedAccountId_accounts_id_fk", - "tableFrom": "location_payment_methods", - "tableTo": "accounts", - "columnsFrom": [ - "linkedAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.locations": { - "name": "locations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "businessType": { - "name": "businessType", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "country": { - "name": "country", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "county": { - "name": "county", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "subCounty": { - "name": "subCounty", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "address": { - "name": "address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "businessRegNumber": { - "name": "businessRegNumber", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "natureOfBusiness": { - "name": "natureOfBusiness", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "kraPin": { - "name": "kraPin", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "defaultMpesaAccountId": { - "name": "defaultMpesaAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "defaultCashAccountId": { - "name": "defaultCashAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "nextBillNumber": { - "name": "nextBillNumber", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "nextExpenseNumber": { - "name": "nextExpenseNumber", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updatedAt": { - "name": "updatedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "locations_defaultMpesaAccountId_accounts_id_fk": { - "name": "locations_defaultMpesaAccountId_accounts_id_fk", - "tableFrom": "locations", - "tableTo": "accounts", - "columnsFrom": [ - "defaultMpesaAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "locations_defaultCashAccountId_accounts_id_fk": { - "name": "locations_defaultCashAccountId_accounts_id_fk", - "tableFrom": "locations", - "tableTo": "accounts", - "columnsFrom": [ - "defaultCashAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "locations_slug_unique": { - "name": "locations_slug_unique", - "nullsNotDistinct": false, - "columns": [ - "slug" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.master_items": { - "name": "master_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "lastUnitPrice": { - "name": "lastUnitPrice", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "lastCategoryId": { - "name": "lastCategoryId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "lastSupplierId": { - "name": "lastSupplierId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "usageCount": { - "name": "usageCount", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updatedAt": { - "name": "updatedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "master_items_name_unique": { - "name": "master_items_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.mpesa_reconciliation": { - "name": "mpesa_reconciliation", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "txnDate": { - "name": "txnDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "orphanCount": { - "name": "orphanCount", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "orphanTotal": { - "name": "orphanTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "matchedCount": { - "name": "matchedCount", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "matchedTotal": { - "name": "matchedTotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "status": { - "name": "status", - "type": "status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "resolvedAt": { - "name": "resolvedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.mpesa_transactions": { - "name": "mpesa_transactions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "txnId": { - "name": "txnId", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true - }, - "txnDate": { - "name": "txnDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "txnTime": { - "name": "txnTime", - "type": "varchar(10)", - "primaryKey": false, - "notNull": false - }, - "txnType": { - "name": "txnType", - "type": "txnType", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "partyName": { - "name": "partyName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "amount": { - "name": "amount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "txnFee": { - "name": "txnFee", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "balance": { - "name": "balance", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "rawText": { - "name": "rawText", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "isLinked": { - "name": "isLinked", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "linkedExpenseId": { - "name": "linkedExpenseId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "linkedBillId": { - "name": "linkedBillId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "linkedSupplierId": { - "name": "linkedSupplierId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "sourceAccountId": { - "name": "sourceAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "destinationAccountId": { - "name": "destinationAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "importedBy": { - "name": "importedBy", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "mpesa_transactions_sourceAccountId_accounts_id_fk": { - "name": "mpesa_transactions_sourceAccountId_accounts_id_fk", - "tableFrom": "mpesa_transactions", - "tableTo": "accounts", - "columnsFrom": [ - "sourceAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "mpesa_transactions_destinationAccountId_accounts_id_fk": { - "name": "mpesa_transactions_destinationAccountId_accounts_id_fk", - "tableFrom": "mpesa_transactions", - "tableTo": "accounts", - "columnsFrom": [ - "destinationAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "mpesa_transactions_txnId_unique": { - "name": "mpesa_transactions_txnId_unique", - "nullsNotDistinct": false, - "columns": [ - "txnId" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notifications": { - "name": "notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "type": { - "name": "type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "severity": { - "name": "severity", - "type": "severity", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'info'" - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "entityType": { - "name": "entityType", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "entityId": { - "name": "entityId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "isRead": { - "name": "isRead", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "isPushed": { - "name": "isPushed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.partner_allocations": { - "name": "partner_allocations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "ownerAccountId": { - "name": "ownerAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "ownerBusinessId": { - "name": "ownerBusinessId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "partnerAccountId": { - "name": "partnerAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "partnerUserId": { - "name": "partnerUserId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "rightsProfile": { - "name": "rightsProfile", - "type": "allocation_rights", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "inviteId": { - "name": "inviteId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "partner_allocation_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "revokedAt": { - "name": "revokedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "createdBy": { - "name": "createdBy", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_partner_allocations_ownerAccountId": { - "name": "idx_partner_allocations_ownerAccountId", - "columns": [ - { - "expression": "ownerAccountId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_partner_allocations_ownerBusinessId": { - "name": "idx_partner_allocations_ownerBusinessId", - "columns": [ - { - "expression": "ownerBusinessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_partner_allocations_partnerAccountId": { - "name": "idx_partner_allocations_partnerAccountId", - "columns": [ - { - "expression": "partnerAccountId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_partner_allocations_partnerUserId": { - "name": "idx_partner_allocations_partnerUserId", - "columns": [ - { - "expression": "partnerUserId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "uq_partner_allocations_inviteId": { - "name": "uq_partner_allocations_inviteId", - "columns": [ - { - "expression": "inviteId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_partner_allocations_status": { - "name": "idx_partner_allocations_status", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_partner_allocations_deletedAt": { - "name": "idx_partner_allocations_deletedAt", - "columns": [ - { - "expression": "deletedAt", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.partner_commissions": { - "name": "partner_commissions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "partnerId": { - "name": "partnerId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "month": { - "name": "month", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "year": { - "name": "year", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "subscriptionAmount": { - "name": "subscriptionAmount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "commissionPercent": { - "name": "commissionPercent", - "type": "numeric(5, 2)", - "primaryKey": false, - "notNull": false, - "default": "'20.00'" - }, - "commissionAmount": { - "name": "commissionAmount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "status": { - "name": "status", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'pending'" - }, - "paidAt": { - "name": "paidAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.payment_methods": { - "name": "payment_methods", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "accountRefId": { - "name": "accountRefId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "color": { - "name": "color", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'#C73E1D'" - }, - "sortOrder": { - "name": "sortOrder", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "isActive": { - "name": "isActive", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "payment_methods_accountRefId_customer_accounts_id_fk": { - "name": "payment_methods_accountRefId_customer_accounts_id_fk", - "tableFrom": "payment_methods", - "tableTo": "customer_accounts", - "columnsFrom": [ - "accountRefId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.payroll_advances": { - "name": "payroll_advances", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "employeeId": { - "name": "employeeId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "payrollPeriodId": { - "name": "payrollPeriodId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "amount": { - "name": "amount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "balanceRemaining": { - "name": "balanceRemaining", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "requestDate": { - "name": "requestDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "repaymentPeriods": { - "name": "repaymentPeriods", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 1 - }, - "status": { - "name": "status", - "type": "advanceStatus", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "approvedBy": { - "name": "approvedBy", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.payroll_entries": { - "name": "payroll_entries", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "periodId": { - "name": "periodId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "employeeId": { - "name": "employeeId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "basicPay": { - "name": "basicPay", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "advancesDeducted": { - "name": "advancesDeducted", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "deductions": { - "name": "deductions", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "bonuses": { - "name": "bonuses", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "overtimePay": { - "name": "overtimePay", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "payeDeducted": { - "name": "payeDeducted", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "nhifDeducted": { - "name": "nhifDeducted", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "nssfDeducted": { - "name": "nssfDeducted", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "netPay": { - "name": "netPay", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "paymentMethod": { - "name": "paymentMethod", - "type": "paymentMethod", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'mpesa'" - }, - "paidAt": { - "name": "paidAt", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.payroll_periods": { - "name": "payroll_periods", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "periodName": { - "name": "periodName", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "startDate": { - "name": "startDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "endDate": { - "name": "endDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "paymentDate": { - "name": "paymentDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "payrollStatus", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "generatedBillId": { - "name": "generatedBillId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "totalNetPay": { - "name": "totalNetPay", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updatedAt": { - "name": "updatedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.payroll_settings": { - "name": "payroll_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "nhifRate": { - "name": "nhifRate", - "type": "numeric(5, 2)", - "primaryKey": false, - "notNull": false, - "default": "'2.75'" - }, - "nssfTier1Limit": { - "name": "nssfTier1Limit", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'7000.00'" - }, - "nssfTier1Employee": { - "name": "nssfTier1Employee", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'420.00'" - }, - "nssfTier1Employer": { - "name": "nssfTier1Employer", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'420.00'" - }, - "nssfTier2Limit": { - "name": "nssfTier2Limit", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'36000.00'" - }, - "nssfTier2Employee": { - "name": "nssfTier2Employee", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'1740.00'" - }, - "nssfTier2Employer": { - "name": "nssfTier2Employer", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'1740.00'" - }, - "personalRelief": { - "name": "personalRelief", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'2400.00'" - }, - "insuranceRelief": { - "name": "insuranceRelief", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "payeBands": { - "name": "payeBands", - "type": "json", - "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": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.price_alert_rules": { - "name": "price_alert_rules", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "supplierId": { - "name": "supplierId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "itemName": { - "name": "itemName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "expectedPrice": { - "name": "expectedPrice", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "variancePercent": { - "name": "variancePercent", - "type": "numeric(5, 2)", - "primaryKey": false, - "notNull": false, - "default": "'10.00'" - }, - "isActive": { - "name": "isActive", - "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.purchase_order_items": { - "name": "purchase_order_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "poId": { - "name": "poId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "itemName": { - "name": "itemName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "numeric(10, 3)", - "primaryKey": false, - "notNull": true, - "default": "'1.000'" - }, - "unitPrice": { - "name": "unitPrice", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "totalPrice": { - "name": "totalPrice", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.purchase_orders": { - "name": "purchase_orders", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "supplierId": { - "name": "supplierId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "billId": { - "name": "billId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "poNumber": { - "name": "poNumber", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "orderStatus", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "subtotal": { - "name": "subtotal", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "taxAmount": { - "name": "taxAmount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "total": { - "name": "total", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "deliveryDate": { - "name": "deliveryDate", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "deliveryNotes": { - "name": "deliveryNotes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "terms": { - "name": "terms", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "createdBy": { - "name": "createdBy", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.push_subscriptions": { - "name": "push_subscriptions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "subscription": { - "name": "subscription", - "type": "json", - "primaryKey": false, - "notNull": true - }, - "isActive": { - "name": "isActive", - "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.quick_actions_log": { - "name": "quick_actions_log", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "action": { - "name": "action", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "entityType": { - "name": "entityType", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "entityId": { - "name": "entityId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "details": { - "name": "details", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.recurring_bill_templates": { - "name": "recurring_bill_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "supplierId": { - "name": "supplierId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "categoryId": { - "name": "categoryId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "liabilityAccountId": { - "name": "liabilityAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "frequency": { - "name": "frequency", - "type": "frequency", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "dayOfWeek": { - "name": "dayOfWeek", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "dayOfMonth": { - "name": "dayOfMonth", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "monthOfYear": { - "name": "monthOfYear", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "nextDueDate": { - "name": "nextDueDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "isActive": { - "name": "isActive", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "recurring_bill_templates_liabilityAccountId_accounts_id_fk": { - "name": "recurring_bill_templates_liabilityAccountId_accounts_id_fk", - "tableFrom": "recurring_bill_templates", - "tableTo": "accounts", - "columnsFrom": [ - "liabilityAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.refresh_tokens": { - "name": "refresh_tokens", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "tokenHash": { - "name": "tokenHash", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "expiresAt": { - "name": "expiresAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true - }, - "deviceInfo": { - "name": "deviceInfo", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "isRevoked": { - "name": "isRevoked", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "idx_refresh_tokens_userId": { - "name": "idx_refresh_tokens_userId", - "columns": [ - { - "expression": "userId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_refresh_tokens_tokenHash": { - "name": "idx_refresh_tokens_tokenHash", - "columns": [ - { - "expression": "tokenHash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_refresh_tokens_expires": { - "name": "idx_refresh_tokens_expires", - "columns": [ - { - "expression": "expiresAt", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.revenue_categories": { - "name": "revenue_categories", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "incomeAccountId": { - "name": "incomeAccountId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "accountCode": { - "name": "accountCode", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "categoryType": { - "name": "categoryType", - "type": "revenueCategoryType", - "typeSchema": "public", - "primaryKey": false, - "notNull": false, - "default": "'other'" - }, - "externalId": { - "name": "externalId", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "externalSystem": { - "name": "externalSystem", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updatedAt": { - "name": "updatedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_revenue_category_business": { - "name": "idx_revenue_category_business", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "revenue_categories_incomeAccountId_accounts_id_fk": { - "name": "revenue_categories_incomeAccountId_accounts_id_fk", - "tableFrom": "revenue_categories", - "tableTo": "accounts", - "columnsFrom": [ - "incomeAccountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.role_permissions": { - "name": "role_permissions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "roleKey": { - "name": "roleKey", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "roleLabel": { - "name": "roleLabel", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "permissions": { - "name": "permissions", - "type": "json", - "primaryKey": false, - "notNull": true - }, - "isActive": { - "name": "isActive", - "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.supplier_price_history": { - "name": "supplier_price_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "supplierId": { - "name": "supplierId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "itemName": { - "name": "itemName", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "billId": { - "name": "billId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "unitPrice": { - "name": "unitPrice", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "numeric(10, 3)", - "primaryKey": false, - "notNull": true, - "default": "'1.000'" - }, - "priceDate": { - "name": "priceDate", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.suppliers": { - "name": "suppliers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "phone": { - "name": "phone", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "contactPerson": { - "name": "contactPerson", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "kraPin": { - "name": "kraPin", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "paymentTermsDays": { - "name": "paymentTermsDays", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 30 - }, - "creditLimit": { - "name": "creditLimit", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": false - }, - "currentBalance": { - "name": "currentBalance", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "totalBilled": { - "name": "totalBilled", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "totalPaid": { - "name": "totalPaid", - "type": "numeric(15, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.00'" - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "autoCategoryId": { - "name": "autoCategoryId", - "type": "bigint", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "business_idx": { - "name": "business_idx", - "columns": [ - { - "expression": "businessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "location_idx": { - "name": "location_idx", - "columns": [ - { - "expression": "locationId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "deleted_idx": { - "name": "deleted_idx", - "columns": [ - { - "expression": "deletedAt", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_businesses": { - "name": "user_businesses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'admin'" - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "unionId": { - "name": "unionId", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "username": { - "name": "username", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "passwordHash": { - "name": "passwordHash", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "varchar(320)", - "primaryKey": false, - "notNull": false - }, - "avatar": { - "name": "avatar", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "role": { - "name": "role", - "type": "role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'viewer'" - }, - "userType": { - "name": "userType", - "type": "user_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'standard'" - }, - "phone": { - "name": "phone", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "locationId": { - "name": "locationId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "currentBusinessId": { - "name": "currentBusinessId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "accountId": { - "name": "accountId", - "type": "varchar(100)", - "primaryKey": false, - "notNull": false - }, - "accountRefId": { - "name": "accountRefId", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "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()" - }, - "lastSignInAt": { - "name": "lastSignInAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_users_id": { - "name": "idx_users_id", - "columns": [ - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_users_deletedAt": { - "name": "idx_users_deletedAt", - "columns": [ - { - "expression": "deletedAt", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_users_isActive": { - "name": "idx_users_isActive", - "columns": [ - { - "expression": "isActive", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_users_currentBusinessId": { - "name": "idx_users_currentBusinessId", - "columns": [ - { - "expression": "currentBusinessId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_users_username_accountId": { - "name": "idx_users_username_accountId", - "columns": [ - { - "expression": "username", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "accountId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "users_accountRefId_customer_accounts_id_fk": { - "name": "users_accountRefId_customer_accounts_id_fk", - "tableFrom": "users", - "tableTo": "customer_accounts", - "columnsFrom": [ - "accountRefId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "users_unionId_unique": { - "name": "users_unionId_unique", - "nullsNotDistinct": false, - "columns": [ - "unionId" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.webhook_deliveries": { - "name": "webhook_deliveries", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "webhookId": { - "name": "webhookId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "event": { - "name": "event", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "payload": { - "name": "payload", - "type": "json", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "statusCode": { - "name": "statusCode", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "response": { - "name": "response", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.webhooks": { - "name": "webhooks", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "businessId": { - "name": "businessId", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "url": { - "name": "url", - "type": "varchar(500)", - "primaryKey": false, - "notNull": true - }, - "events": { - "name": "events", - "type": "json", - "primaryKey": false, - "notNull": true - }, - "secret": { - "name": "secret", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false - }, - "isActive": { - "name": "isActive", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "lastTriggeredAt": { - "name": "lastTriggeredAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "lastStatus": { - "name": "lastStatus", - "type": "varchar(50)", - "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()" - }, - "deletedAt": { - "name": "deletedAt", - "type": "timestamp", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.accountSubType": { - "name": "accountSubType", - "schema": "public", - "values": [ - "cash", - "bank", - "accounts_receivable", - "inventory", - "prepaid_expense", - "fixed_asset", - "accumulated_depreciation", - "intangible_asset", - "other_asset", - "accounts_payable", - "accrued_expense", - "current_loan", - "long_term_loan", - "capital", - "retained_earnings", - "drawings", - "current_year_earnings", - "sales_revenue", - "service_revenue", - "subscription_revenue", - "other_income", - "cogs", - "operating_expense", - "admin_expense", - "marketing_expense", - "depreciation_expense" - ] - }, - "public.accountType": { - "name": "accountType", - "schema": "public", - "values": [ - "asset", - "liability", - "equity", - "revenue", - "expense" - ] - }, - "public.accountingClass": { - "name": "accountingClass", - "schema": "public", - "values": [ - "cogs", - "operating_expense", - "admin_expense", - "marketing", - "depreciation", - "other" - ] - }, - "public.action": { - "name": "action", - "schema": "public", - "values": [ - "CREATE", - "UPDATE", - "DELETE", - "RESTORE", - "LOGIN", - "LOGOUT" - ] - }, - "public.advanceStatus": { - "name": "advanceStatus", - "schema": "public", - "values": [ - "pending", - "approved", - "partially_repaid", - "repaid", - "cancelled" - ] - }, - "public.allocation_invite_status": { - "name": "allocation_invite_status", - "schema": "public", - "values": [ - "active", - "consumed", - "revoked", - "expired" - ] - }, - "public.allocation_rights": { - "name": "allocation_rights", - "schema": "public", - "values": [ - "view_only", - "create_view", - "manage" - ] - }, - "public.billStatus": { - "name": "billStatus", - "schema": "public", - "values": [ - "pending", - "partial", - "paid", - "overdue", - "cancelled" - ] - }, - "public.depreciationMethod": { - "name": "depreciationMethod", - "schema": "public", - "values": [ - "straight_line", - "declining_balance" - ] - }, - "public.entryType": { - "name": "entryType", - "schema": "public", - "values": [ - "debit", - "credit" - ] - }, - "public.frequency": { - "name": "frequency", - "schema": "public", - "values": [ - "daily", - "weekly", - "monthly", - "quarterly", - "annually" - ] - }, - "public.itemType": { - "name": "itemType", - "schema": "public", - "values": [ - "inventory", - "fixed_asset", - "service", - "non_inventory" - ] - }, - "public.leadStatus": { - "name": "leadStatus", - "schema": "public", - "values": [ - "new", - "contacted", - "converted", - "declined" - ] - }, - "public.orderStatus": { - "name": "orderStatus", - "schema": "public", - "values": [ - "draft", - "sent", - "delivered", - "billed", - "cancelled" - ] - }, - "public.partner_allocation_status": { - "name": "partner_allocation_status", - "schema": "public", - "values": [ - "active", - "revoked" - ] - }, - "public.paymentMethod2": { - "name": "paymentMethod2", - "schema": "public", - "values": [ - "cash", - "mpesa", - "bank_transfer", - "card" - ] - }, - "public.paymentMethod": { - "name": "paymentMethod", - "schema": "public", - "values": [ - "cash", - "mpesa", - "bank_transfer" - ] - }, - "public.payrollStatus": { - "name": "payrollStatus", - "schema": "public", - "values": [ - "open", - "processing", - "paid", - "cancelled" - ] - }, - "public.revenueCategoryType": { - "name": "revenueCategoryType", - "schema": "public", - "values": [ - "product_sales", - "service_revenue", - "subscription", - "membership", - "other" - ] - }, - "public.role": { - "name": "role", - "schema": "public", - "values": [ - "owner", - "admin", - "manager", - "employee", - "viewer" - ] - }, - "public.salaryType": { - "name": "salaryType", - "schema": "public", - "values": [ - "monthly", - "weekly", - "daily", - "hourly" - ] - }, - "public.severity": { - "name": "severity", - "schema": "public", - "values": [ - "info", - "warning", - "critical" - ] - }, - "public.status": { - "name": "status", - "schema": "public", - "values": [ - "open", - "resolved", - "partial" - ] - }, - "public.transactionType": { - "name": "transactionType", - "schema": "public", - "values": [ - "sale", - "expense", - "bill_payment", - "supplier_payment", - "payroll", - "advance", - "transfer", - "opening_balance", - "mpesa_topup", - "drawing", - "deposit", - "journal", - "depreciation", - "asset_disposal" - ] - }, - "public.txnType": { - "name": "txnType", - "schema": "public", - "values": [ - "topup", - "expense", - "transfer", - "bank_transfer", - "airtime", - "utility", - "withdrawal" - ] - }, - "public.type": { - "name": "type", - "schema": "public", - "values": [ - "cash", - "mpesa", - "bank_account" - ] - }, - "public.user_type": { - "name": "user_type", - "schema": "public", - "values": [ - "standard", - "partner" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/db/migrations/meta/0002_snapshot.json b/db/migrations/meta/0002_snapshot.json deleted file mode 100644 index fa10221..0000000 --- a/db/migrations/meta/0002_snapshot.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "id": "0002-soft-flamingo", - "prevId": "0001-gifted-secret-warriors", - "version": "7", - "dialect": "postgresql", - "tables": { - "expense_items": { - "name": "expense_items", - "columns": { - "id": { "name": "id", "type": "serial", "primaryKey": true, "autoincrement": true }, - "expenseId": { "name": "expenseId", "type": "bigint", "primaryKey": false, "autoincrement": false }, - "itemName": { "name": "itemName", "type": "varchar(255)", "primaryKey": false, "autoincrement": false }, - "quantity": { "name": "quantity", "type": "numeric(10, 3)", "primaryKey": false, "autoincrement": false, "default": "'1.000'" }, - "unitPrice": { "name": "unitPrice", "type": "numeric(15, 2)", "primaryKey": false, "autoincrement": false }, - "totalPrice": { "name": "totalPrice", "type": "numeric(15, 2)", "primaryKey": false, "autoincrement": false }, - "categoryId": { "name": "categoryId", "type": "bigint", "primaryKey": false, "autoincrement": false }, - "notes": { "name": "notes", "type": "text", "primaryKey": false, "autoincrement": false }, - "createdAt": { "name": "createdAt", "type": "timestamp", "primaryKey": false, "autoincrement": false, "default": "now()" }, - "updatedAt": { "name": "updatedAt", "type": "timestamp", "primaryKey": false, "autoincrement": false, "default": "now()" }, - "deletedAt": { "name": "deletedAt", "type": "timestamp", "primaryKey": false, "autoincrement": false } - }, - "indexes": { - "expense_items_expense_id_idx": { "name": "expense_items_expense_id_idx", "columns": ["expenseId"] }, - "expense_items_category_id_idx": { "name": "expense_items_category_id_idx", "columns": ["categoryId"] }, - "expense_items_deleted_at_idx": { "name": "expense_items_deleted_at_idx", "columns": ["deletedAt"] } - }, - "foreignKeys": { - "expense_items_expense_id_fkey": { - "name": "expense_items_expense_id_fkey", - "tableFrom": "expense_items", - "tableTo": "expenses", - "columnsFrom": ["expenseId"], - "columnsTo": ["id"], - "onDelete": "no action", - "onUpdate": "no action" - }, - "expense_items_category_id_fkey": { - "name": "expense_items_category_id_fkey", - "tableFrom": "expense_items", - "tableTo": "expense_categories", - "columnsFrom": ["categoryId"], - "columnsTo": ["id"], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "schemas": {}, - "sequences": {} -} diff --git a/db/migrations/meta/_journal.json b/db/migrations/meta/_journal.json index f0129f7..6b76100 100644 --- a/db/migrations/meta/_journal.json +++ b/db/migrations/meta/_journal.json @@ -5,23 +5,9 @@ { "idx": 0, "version": "7", - "when": 1778934650027, - "tag": "0000_flawless_jack_murdock", - "breakpoints": true - }, - { - "idx": 1, - "version": "7", - "when": 1779017871967, - "tag": "0001_gifted_secret_warriors", - "breakpoints": true - }, - { - "idx": 2, - "version": "7", - "when": 1779122000000, - "tag": "0002_soft_flamingo", + "when": 1779139318313, + "tag": "0000_outgoing_christian_walker", "breakpoints": true } ] -} +} \ No newline at end of file