@danielcok17/prisma-db 1.16.0 → 1.16.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielcok17/prisma-db",
3
- "version": "1.16.0",
3
+ "version": "1.16.1",
4
4
  "description": "Shared Prisma schema for Legal AI applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,2 +1,2 @@
1
1
  -- AlterTable
2
- ALTER TABLE "User" ADD COLUMN "phoneVerified" TIMESTAMP(3);
2
+ ALTER TABLE "User" ADD COLUMN IF NOT EXISTS "phoneVerified" TIMESTAMP(3);
@@ -1,5 +1,5 @@
1
1
  -- CreateTable
2
- CREATE TABLE "PhoneOtp" (
2
+ CREATE TABLE IF NOT EXISTS "PhoneOtp" (
3
3
  "id" TEXT NOT NULL,
4
4
  "userId" TEXT NOT NULL,
5
5
  "phone" TEXT NOT NULL,
@@ -11,7 +11,7 @@ CREATE TABLE "PhoneOtp" (
11
11
  );
12
12
 
13
13
  -- CreateTable
14
- CREATE TABLE "AdminGrant" (
14
+ CREATE TABLE IF NOT EXISTS "AdminGrant" (
15
15
  "id" TEXT NOT NULL,
16
16
  "userId" TEXT,
17
17
  "organizationId" TEXT,
@@ -31,7 +31,7 @@ CREATE TABLE "AdminGrant" (
31
31
  );
32
32
 
33
33
  -- CreateTable
34
- CREATE TABLE "AppInvite" (
34
+ CREATE TABLE IF NOT EXISTS "AppInvite" (
35
35
  "id" TEXT NOT NULL,
36
36
  "email" TEXT NOT NULL,
37
37
  "token" TEXT NOT NULL,
@@ -52,49 +52,70 @@ CREATE TABLE "AppInvite" (
52
52
  );
53
53
 
54
54
  -- CreateIndex
55
- CREATE UNIQUE INDEX "PhoneOtp_bulkgateId_key" ON "PhoneOtp"("bulkgateId");
55
+ CREATE UNIQUE INDEX IF NOT EXISTS "PhoneOtp_bulkgateId_key" ON "PhoneOtp"("bulkgateId");
56
56
 
57
57
  -- CreateIndex
58
- CREATE INDEX "PhoneOtp_userId_idx" ON "PhoneOtp"("userId");
58
+ CREATE INDEX IF NOT EXISTS "PhoneOtp_userId_idx" ON "PhoneOtp"("userId");
59
59
 
60
60
  -- CreateIndex
61
- CREATE INDEX "PhoneOtp_bulkgateId_idx" ON "PhoneOtp"("bulkgateId");
61
+ CREATE INDEX IF NOT EXISTS "PhoneOtp_bulkgateId_idx" ON "PhoneOtp"("bulkgateId");
62
62
 
63
63
  -- CreateIndex
64
- CREATE INDEX "PhoneOtp_expiresAt_idx" ON "PhoneOtp"("expiresAt");
64
+ CREATE INDEX IF NOT EXISTS "PhoneOtp_expiresAt_idx" ON "PhoneOtp"("expiresAt");
65
65
 
66
66
  -- CreateIndex
67
- CREATE INDEX "AdminGrant_userId_idx" ON "AdminGrant"("userId");
67
+ CREATE INDEX IF NOT EXISTS "AdminGrant_userId_idx" ON "AdminGrant"("userId");
68
68
 
69
69
  -- CreateIndex
70
- CREATE INDEX "AdminGrant_organizationId_idx" ON "AdminGrant"("organizationId");
70
+ CREATE INDEX IF NOT EXISTS "AdminGrant_organizationId_idx" ON "AdminGrant"("organizationId");
71
71
 
72
72
  -- CreateIndex
73
- CREATE INDEX "AdminGrant_expiresAt_idx" ON "AdminGrant"("expiresAt");
73
+ CREATE INDEX IF NOT EXISTS "AdminGrant_expiresAt_idx" ON "AdminGrant"("expiresAt");
74
74
 
75
75
  -- CreateIndex
76
- CREATE INDEX "AdminGrant_isActive_idx" ON "AdminGrant"("isActive");
76
+ CREATE INDEX IF NOT EXISTS "AdminGrant_isActive_idx" ON "AdminGrant"("isActive");
77
77
 
78
78
  -- CreateIndex
79
- CREATE UNIQUE INDEX "AppInvite_token_key" ON "AppInvite"("token");
79
+ CREATE UNIQUE INDEX IF NOT EXISTS "AppInvite_token_key" ON "AppInvite"("token");
80
80
 
81
81
  -- CreateIndex
82
- CREATE INDEX "AppInvite_email_idx" ON "AppInvite"("email");
82
+ CREATE INDEX IF NOT EXISTS "AppInvite_email_idx" ON "AppInvite"("email");
83
83
 
84
84
  -- CreateIndex
85
- CREATE INDEX "AppInvite_token_idx" ON "AppInvite"("token");
85
+ CREATE INDEX IF NOT EXISTS "AppInvite_token_idx" ON "AppInvite"("token");
86
86
 
87
87
  -- CreateIndex
88
- CREATE INDEX "AppInvite_isActive_idx" ON "AppInvite"("isActive");
88
+ CREATE INDEX IF NOT EXISTS "AppInvite_isActive_idx" ON "AppInvite"("isActive");
89
89
 
90
90
  -- CreateIndex
91
- CREATE INDEX "User_phone_idx" ON "User"("phone");
92
-
93
- -- AddForeignKey
94
- ALTER TABLE "PhoneOtp" ADD CONSTRAINT "PhoneOtp_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
95
-
96
- -- AddForeignKey
97
- ALTER TABLE "AdminGrant" ADD CONSTRAINT "AdminGrant_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
98
-
99
- -- AddForeignKey
100
- ALTER TABLE "AdminGrant" ADD CONSTRAINT "AdminGrant_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
91
+ CREATE INDEX IF NOT EXISTS "User_phone_idx" ON "User"("phone");
92
+
93
+ -- AddForeignKey (idempotent)
94
+ DO $$ BEGIN
95
+ IF NOT EXISTS (
96
+ SELECT 1 FROM pg_constraint WHERE conname = 'PhoneOtp_userId_fkey'
97
+ ) THEN
98
+ ALTER TABLE "PhoneOtp" ADD CONSTRAINT "PhoneOtp_userId_fkey"
99
+ FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
100
+ END IF;
101
+ END $$;
102
+
103
+ -- AddForeignKey (idempotent)
104
+ DO $$ BEGIN
105
+ IF NOT EXISTS (
106
+ SELECT 1 FROM pg_constraint WHERE conname = 'AdminGrant_userId_fkey'
107
+ ) THEN
108
+ ALTER TABLE "AdminGrant" ADD CONSTRAINT "AdminGrant_userId_fkey"
109
+ FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
110
+ END IF;
111
+ END $$;
112
+
113
+ -- AddForeignKey (idempotent)
114
+ DO $$ BEGIN
115
+ IF NOT EXISTS (
116
+ SELECT 1 FROM pg_constraint WHERE conname = 'AdminGrant_organizationId_fkey'
117
+ ) THEN
118
+ ALTER TABLE "AdminGrant" ADD CONSTRAINT "AdminGrant_organizationId_fkey"
119
+ FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
120
+ END IF;
121
+ END $$;