@regincap/prisma-schema 0.0.0-stage → 1.0.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/README.md +108 -2
- package/package.json +33 -4
- package/prisma/schema.prisma +4243 -0
package/README.md
CHANGED
|
@@ -1,3 +1,109 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🏗️ Regincap Project — Prisma Schema
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Welcome to the **Regincap Project Schema Repository**.
|
|
4
|
+
This repository contains the **official Prisma schema**, migrations, and related setup for the Regincap backend system. It is designed specifically for **Regincap** and **must not** be reused or modified for any other projects.
|
|
5
|
+
|
|
6
|
+
> ⚠️ **Important:**
|
|
7
|
+
> This is a **private schema**. Usage of this schema outside of the Regincap environment is strictly prohibited.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 📚 Table of Contents
|
|
12
|
+
|
|
13
|
+
- [📌 Project Overview](#-project-overview)
|
|
14
|
+
- [🛠️ Tech Stack](#️-tech-stack)
|
|
15
|
+
- [📂 Project Structure](#-project-structure)
|
|
16
|
+
- [🚀 Getting Started](#-getting-started)
|
|
17
|
+
- [🧭 Development Workflow](#-development-workflow)
|
|
18
|
+
- [⚡ Common Commands](#-common-commands)
|
|
19
|
+
- [🔒 Important Notes](#-important-notes)
|
|
20
|
+
- [📄 License](#-license)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 📌 Project Overview
|
|
25
|
+
|
|
26
|
+
This schema serves as the **single source of truth** for the Regincap backend database.
|
|
27
|
+
It defines the models, relations, enums, and constraints required for all services interacting with the Regincap data layer.
|
|
28
|
+
|
|
29
|
+
- ✅ Centralized schema for all DB models
|
|
30
|
+
- ✅ Managed migrations with Prisma
|
|
31
|
+
- ✅ Enums and mappings aligned with business logic
|
|
32
|
+
- ✅ Designed for multi-tenant setups using Prisma Client
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🛠️ Tech Stack
|
|
37
|
+
|
|
38
|
+
- **[Prisma ORM](https://www.prisma.io/)** — Database modeling & migrations
|
|
39
|
+
- **TypeScript** — Type-safe schema and client code
|
|
40
|
+
- **MySQL** — Primary database engine
|
|
41
|
+
- **Node.js / NestJS** — For backend integration
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 📂 Project Structure
|
|
46
|
+
|
|
47
|
+
- `prisma/schema.prisma` → Core database models and enums for Regincap.
|
|
48
|
+
- `migrations/` → Auto-generated by Prisma when pushing changes.
|
|
49
|
+
- `package.json` → Used for managing versioning and publishing the schema internally.
|
|
50
|
+
- `README.md` → Project documentation.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 🚀 Getting Started
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
|
|
58
|
+
npm install
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
npx prisma generate
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
npm run db:plan -- describe_your_change
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Production database changes
|
|
68
|
+
|
|
69
|
+
Do not run `prisma db push` against production. This database is large and has
|
|
70
|
+
historical schema drift, so `db push` can unexpectedly alter unrelated tables.
|
|
71
|
+
|
|
72
|
+
Use one focused, reviewed SQL change instead:
|
|
73
|
+
|
|
74
|
+
1. Commit the current schema as the baseline.
|
|
75
|
+
2. Edit `prisma/schema.prisma` with one logical change.
|
|
76
|
+
3. Generate SQL containing only that edit:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm run db:plan -- add_customer_key
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
4. Review the generated file in `prisma/changes/`. The command reports common
|
|
83
|
+
operations that scan, lock, or rebuild populated tables.
|
|
84
|
+
5. Test the SQL on a production-sized staging database. For an index or foreign
|
|
85
|
+
key on a large table, use an online schema-change tool and schedule it during
|
|
86
|
+
low traffic; Prisma cannot make the MySQL table operation instant.
|
|
87
|
+
6. Apply the exact reviewed file:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm run db:check -- prisma/changes/<file>.sql
|
|
91
|
+
npm run db:apply -- prisma/changes/<file>.sql
|
|
92
|
+
npm run generate
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The command asks you to type `APPLY` before connecting to the configured
|
|
96
|
+
database. A file containing `DROP TABLE` or `DROP COLUMN` asks for a second
|
|
97
|
+
`DELETE` confirmation. Non-interactive CI can use `--confirm-production`
|
|
98
|
+
and, for destructive changes, `--confirm-data-loss`.
|
|
99
|
+
|
|
100
|
+
7. Commit `schema.prisma` and the SQL change file together.
|
|
101
|
+
|
|
102
|
+
`db:plan` compares the working schema to the committed schema rather than the
|
|
103
|
+
live database. This prevents old, unrelated database drift from being included
|
|
104
|
+
in a new production change. The `db:apply` command uses the database configured
|
|
105
|
+
by `DATABASE_URL`; verify that target before confirming production execution.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
_Built and maintained with ❤️ by the **Regincap Development Team**._
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regincap/prisma-schema",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Shared Prisma schema and generated client for Regin Cap projects",
|
|
5
|
+
"main": "generated/client/index.js",
|
|
6
|
+
"types": "generated/client/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"prisma/",
|
|
9
|
+
"package.json",
|
|
10
|
+
"generated/client/"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"generate": "prisma generate",
|
|
14
|
+
"build": "npm run generate",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"test": "echo \"No tests configured\" && exit 0"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"prisma",
|
|
20
|
+
"schema",
|
|
21
|
+
"shared",
|
|
22
|
+
"nestjs",
|
|
23
|
+
"database",
|
|
24
|
+
"factor-wise"
|
|
25
|
+
],
|
|
26
|
+
"author": "Regincap",
|
|
27
|
+
"license": "ISC",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@prisma/client": "^6.19.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^25.0.3",
|
|
33
|
+
"prisma": "^6.19.0"
|
|
34
|
+
}
|
|
35
|
+
}
|