procbay-schema 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/prisma/.env +1 -1
- package/prisma/migrations/20250728072402_init_budget_management_tables/migration.sql +0 -0
- package/prisma/migrations/20250729100954_/migration.sql +91 -0
- package/prisma/migrations/20250729101424_init_vendor_reference_table/migration.sql +23 -0
- package/prisma/schema.prisma +26 -1
- package/src/prisma/edge.js +22 -5
- package/src/prisma/index-browser.js +19 -2
- package/src/prisma/index.d.ts +2448 -236
- package/src/prisma/index.js +22 -5
- package/src/prisma/package.json +1 -1
- package/src/prisma/schema.prisma +26 -1
- package/src/prisma/wasm.js +19 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "procbay-schema",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A set of utilities for managing Prisma database schemas, seeding, and maintenance operations for the Procure-to-Pay system",
|
|
5
5
|
"main": "src/prisma/index.js",
|
|
6
6
|
"type": "module",
|
package/prisma/.env
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
|
5
5
|
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
|
6
6
|
|
|
7
|
-
DEFAULT_DATABASE_URL="postgresql://postgres:root@localhost:5432/
|
|
7
|
+
DEFAULT_DATABASE_URL="postgresql://postgres:root@localhost:5432/procbay_new_db?schema=procbay_schema"
|
|
8
8
|
DETAILED_LOGGING=true
|
|
9
9
|
LOG_LEVEL=info
|
|
File without changes
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `financial_year` on the `budgets` table. All the data in the column will be lost.
|
|
5
|
+
- You are about to drop the column `supporting_documents` on the `budgets` table. All the data in the column will be lost.
|
|
6
|
+
- You are about to drop the column `budget_id` on the `category_budgets` table. All the data in the column will be lost.
|
|
7
|
+
- A unique constraint covering the columns `[department_budget_id,category_id]` on the table `category_budgets` will be added. If there are existing duplicate values, this will fail.
|
|
8
|
+
|
|
9
|
+
*/
|
|
10
|
+
-- AlterEnum
|
|
11
|
+
ALTER TYPE "AlertTypeEnum" ADD VALUE 'EXPORT';
|
|
12
|
+
|
|
13
|
+
-- DropForeignKey
|
|
14
|
+
ALTER TABLE "category_budgets" DROP CONSTRAINT "category_budgets_budget_id_fkey";
|
|
15
|
+
|
|
16
|
+
-- DropIndex
|
|
17
|
+
DROP INDEX "category_budgets_budget_id_category_id_key";
|
|
18
|
+
|
|
19
|
+
-- AlterTable
|
|
20
|
+
ALTER TABLE "budgets" DROP COLUMN "financial_year",
|
|
21
|
+
DROP COLUMN "supporting_documents",
|
|
22
|
+
ADD COLUMN "fiscal_year" TEXT;
|
|
23
|
+
|
|
24
|
+
-- AlterTable
|
|
25
|
+
ALTER TABLE "category_budgets" DROP COLUMN "budget_id",
|
|
26
|
+
ADD COLUMN "department_budget_id" INTEGER,
|
|
27
|
+
ADD COLUMN "description" TEXT;
|
|
28
|
+
|
|
29
|
+
-- AlterTable
|
|
30
|
+
ALTER TABLE "department_budgets" ADD COLUMN "description" TEXT,
|
|
31
|
+
ADD COLUMN "fiscal_year" TEXT,
|
|
32
|
+
ALTER COLUMN "allocated_budget" DROP NOT NULL;
|
|
33
|
+
|
|
34
|
+
-- AlterTable
|
|
35
|
+
ALTER TABLE "export_logs" ALTER COLUMN "expires_at" SET DEFAULT NOW() + INTERVAL '7 days';
|
|
36
|
+
|
|
37
|
+
-- CreateTable
|
|
38
|
+
CREATE TABLE "supporting_documents" (
|
|
39
|
+
"id" SERIAL NOT NULL,
|
|
40
|
+
"budget_id" INTEGER,
|
|
41
|
+
"department_budget_id" INTEGER,
|
|
42
|
+
"category_budget_id" INTEGER,
|
|
43
|
+
"file_name" TEXT,
|
|
44
|
+
"original_name" TEXT,
|
|
45
|
+
"file_path" TEXT,
|
|
46
|
+
"file_size" INTEGER,
|
|
47
|
+
"mime_type" TEXT,
|
|
48
|
+
"created_by" INTEGER,
|
|
49
|
+
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
50
|
+
"updated_by" INTEGER,
|
|
51
|
+
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
52
|
+
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
|
53
|
+
"deleted_by" INTEGER,
|
|
54
|
+
"deleted_at" TIMESTAMPTZ(6),
|
|
55
|
+
|
|
56
|
+
CONSTRAINT "supporting_documents_pkey" PRIMARY KEY ("id")
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
-- CreateTable
|
|
60
|
+
CREATE TABLE "expenses" (
|
|
61
|
+
"id" SERIAL NOT NULL,
|
|
62
|
+
"category_budget_id" INTEGER,
|
|
63
|
+
"amount" DECIMAL(15,2) NOT NULL,
|
|
64
|
+
"description" TEXT,
|
|
65
|
+
"expense_date" TIMESTAMP(3),
|
|
66
|
+
"receipt_number" TEXT,
|
|
67
|
+
"vendor_name" TEXT,
|
|
68
|
+
"notes" TEXT,
|
|
69
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
70
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
71
|
+
|
|
72
|
+
CONSTRAINT "expenses_pkey" PRIMARY KEY ("id")
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
-- CreateIndex
|
|
76
|
+
CREATE UNIQUE INDEX "category_budgets_department_budget_id_category_id_key" ON "category_budgets"("department_budget_id", "category_id");
|
|
77
|
+
|
|
78
|
+
-- AddForeignKey
|
|
79
|
+
ALTER TABLE "category_budgets" ADD CONSTRAINT "category_budgets_department_budget_id_fkey" FOREIGN KEY ("department_budget_id") REFERENCES "department_budgets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
80
|
+
|
|
81
|
+
-- AddForeignKey
|
|
82
|
+
ALTER TABLE "supporting_documents" ADD CONSTRAINT "supporting_documents_budget_id_fkey" FOREIGN KEY ("budget_id") REFERENCES "budgets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
83
|
+
|
|
84
|
+
-- AddForeignKey
|
|
85
|
+
ALTER TABLE "supporting_documents" ADD CONSTRAINT "supporting_documents_department_budget_id_fkey" FOREIGN KEY ("department_budget_id") REFERENCES "department_budgets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
86
|
+
|
|
87
|
+
-- AddForeignKey
|
|
88
|
+
ALTER TABLE "supporting_documents" ADD CONSTRAINT "supporting_documents_category_budget_id_fkey" FOREIGN KEY ("category_budget_id") REFERENCES "category_budgets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
89
|
+
|
|
90
|
+
-- AddForeignKey
|
|
91
|
+
ALTER TABLE "expenses" ADD CONSTRAINT "expenses_category_budget_id_fkey" FOREIGN KEY ("category_budget_id") REFERENCES "category_budgets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
-- AlterTable
|
|
2
|
+
ALTER TABLE "export_logs" ALTER COLUMN "expires_at" SET DEFAULT NOW() + INTERVAL '7 days';
|
|
3
|
+
|
|
4
|
+
-- CreateTable
|
|
5
|
+
CREATE TABLE "vendor_references" (
|
|
6
|
+
"id" SERIAL NOT NULL,
|
|
7
|
+
"global_vendor_id" INTEGER,
|
|
8
|
+
"tenant_vendor_code" TEXT,
|
|
9
|
+
"invited_by" INTEGER,
|
|
10
|
+
"invited_on" TIMESTAMP(3),
|
|
11
|
+
"is_deleted" BOOLEAN NOT NULL DEFAULT false,
|
|
12
|
+
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
13
|
+
"created_by" INTEGER,
|
|
14
|
+
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
15
|
+
"updated_by" INTEGER,
|
|
16
|
+
"deleted_at" TIMESTAMP(3),
|
|
17
|
+
"deleted_by" INTEGER,
|
|
18
|
+
|
|
19
|
+
CONSTRAINT "vendor_references_pkey" PRIMARY KEY ("id")
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
-- AddForeignKey
|
|
23
|
+
ALTER TABLE "vendor_references" ADD CONSTRAINT "vendor_references_invited_by_fkey" FOREIGN KEY ("invited_by") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
package/prisma/schema.prisma
CHANGED
|
@@ -99,6 +99,7 @@ model User {
|
|
|
99
99
|
export_logs ExportLog[]
|
|
100
100
|
department_head Department[] @relation("department_head")
|
|
101
101
|
budget_manager Department[] @relation("budget_manager")
|
|
102
|
+
vendor_reference VendorReference[]
|
|
102
103
|
|
|
103
104
|
@@map("users")
|
|
104
105
|
}
|
|
@@ -258,7 +259,7 @@ model Category {
|
|
|
258
259
|
vendor_categories VendorCategory[]
|
|
259
260
|
Item Item[]
|
|
260
261
|
category_uom UomCategory[]
|
|
261
|
-
CategoryBudget
|
|
262
|
+
category_budget CategoryBudget[]
|
|
262
263
|
|
|
263
264
|
@@map("categories")
|
|
264
265
|
}
|
|
@@ -1596,6 +1597,7 @@ enum AlertTypeEnum {
|
|
|
1596
1597
|
CONTRACT_CLAUSE
|
|
1597
1598
|
CONTRACT_TEMPLATE
|
|
1598
1599
|
UPLOAD
|
|
1600
|
+
EXPORT
|
|
1599
1601
|
}
|
|
1600
1602
|
|
|
1601
1603
|
model AdminAlert {
|
|
@@ -2530,6 +2532,7 @@ model FiscalYear {
|
|
|
2530
2532
|
}
|
|
2531
2533
|
|
|
2532
2534
|
//------------------------------------- FISCAL YEAR MODEL END --------------------------------------------
|
|
2535
|
+
|
|
2533
2536
|
//------------------------------------- BUDGET MODEL START --------------------------------------------
|
|
2534
2537
|
enum BudgetStatus {
|
|
2535
2538
|
WARNING
|
|
@@ -2669,3 +2672,25 @@ model Expense {
|
|
|
2669
2672
|
}
|
|
2670
2673
|
|
|
2671
2674
|
//------------------------------------- EXPENSE MODEL END ----------------------------------------------
|
|
2675
|
+
|
|
2676
|
+
//------------------------------------- VENDOR REFERENCE MODEL START --------------------------------------------
|
|
2677
|
+
|
|
2678
|
+
model VendorReference {
|
|
2679
|
+
id Int @id @default(autoincrement())
|
|
2680
|
+
global_vendor_id Int? // reference id from global vendor
|
|
2681
|
+
tenant_vendor_code String? // reference id from tenant vendor
|
|
2682
|
+
invited_by Int? // who invited the vendor to the tenant
|
|
2683
|
+
user User? @relation(fields: [invited_by], references: [id], onDelete: Cascade)
|
|
2684
|
+
invited_on DateTime?
|
|
2685
|
+
is_deleted Boolean @default(false)
|
|
2686
|
+
created_at DateTime @default(now())
|
|
2687
|
+
created_by Int?
|
|
2688
|
+
updated_at DateTime @updatedAt
|
|
2689
|
+
updated_by Int?
|
|
2690
|
+
deleted_at DateTime?
|
|
2691
|
+
deleted_by Int?
|
|
2692
|
+
|
|
2693
|
+
@@map("vendor_references")
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2696
|
+
//------------------------------------- VENDOR REFERENCE MODEL END --------------------------------------------
|