@javalabs/prisma-client 1.0.27 → 1.0.29
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/.github/CODEOWNERS +1 -1
- package/README.md +269 -269
- package/migration-config.json +63 -63
- package/migration-config.json.bk +95 -95
- package/migrations/add_reserved_amount.sql +7 -7
- package/package.json +44 -44
- package/prisma/migrations/add_uuid_to_transactions.sql +13 -13
- package/prisma/schema.prisma +609 -601
- package/src/index.ts +23 -23
- package/src/prisma-factory.service.ts +40 -40
- package/src/prisma.module.ts +9 -9
- package/src/prisma.service.ts +16 -16
- package/src/scripts/add-uuid-to-table.ts +138 -138
- package/src/scripts/create-tenant-schemas.ts +145 -145
- package/src/scripts/data-migration/batch-migrator.ts +248 -248
- package/src/scripts/data-migration/data-transformer.ts +426 -426
- package/src/scripts/data-migration/db-connector.ts +120 -120
- package/src/scripts/data-migration/dependency-resolver.ts +174 -174
- package/src/scripts/data-migration/entity-discovery.ts +196 -196
- package/src/scripts/data-migration/foreign-key-manager.ts +277 -277
- package/src/scripts/data-migration/migration-config.json +63 -63
- package/src/scripts/data-migration/migration-tool.ts +509 -509
- package/src/scripts/data-migration/schema-utils.ts +248 -248
- package/src/scripts/data-migration/tenant-migrator.ts +201 -201
- package/src/scripts/data-migration/typecast-manager.ts +193 -193
- package/src/scripts/data-migration/types.ts +113 -113
- package/src/scripts/database-initializer.ts +49 -49
- package/src/scripts/drop-database.ts +104 -104
- package/src/scripts/dump-source-db.sh +61 -61
- package/src/scripts/encrypt-user-passwords.ts +36 -36
- package/src/scripts/error-handler.ts +117 -117
- package/src/scripts/fix-data-types.ts +241 -241
- package/src/scripts/fix-enum-values.ts +357 -357
- package/src/scripts/fix-schema-discrepancies.ts +317 -317
- package/src/scripts/fix-table-indexes.ts +601 -601
- package/src/scripts/migrate-schema-structure.ts +90 -90
- package/src/scripts/migrate-uuid.ts +76 -76
- package/src/scripts/post-migration-validator.ts +526 -526
- package/src/scripts/pre-migration-validator.ts +610 -610
- package/src/scripts/reset-database.ts +263 -263
- package/src/scripts/retry-failed-migrations.ts +416 -416
- package/src/scripts/run-migration.ts +707 -707
- package/src/scripts/schema-sync.ts +128 -128
- package/src/scripts/sequence-sync-cli.ts +416 -416
- package/src/scripts/sequence-synchronizer.ts +127 -127
- package/src/scripts/sync-enum-types.ts +170 -170
- package/src/scripts/sync-enum-values.ts +563 -563
- package/src/scripts/truncate-database.ts +123 -123
- package/src/scripts/verify-migration-setup.ts +135 -135
- package/tsconfig.json +17 -17
package/migration-config.json.bk
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
{
|
|
2
|
-
"commonSchema": "public",
|
|
3
|
-
"tenantInfo": {
|
|
4
|
-
"sourceTable": "api_keys",
|
|
5
|
-
"tenantIdColumn": "api_key",
|
|
6
|
-
"providerIdColumn": "provider_id"
|
|
7
|
-
},
|
|
8
|
-
"tables": {
|
|
9
|
-
"countries": { "type": "public", "idField": "id" },
|
|
10
|
-
"users": { "type": "public", "idField": "user_id" },
|
|
11
|
-
"providers": { "type": "public", "idField": "provider_id" },
|
|
12
|
-
"banks": { "type": "public", "idField": "id" },
|
|
13
|
-
"api_keys": { "type": "public", "idField": "id" },
|
|
14
|
-
"transactions": {
|
|
15
|
-
"type": "tenant",
|
|
16
|
-
"idField": "id",
|
|
17
|
-
"filterColumn": "provider_id"
|
|
18
|
-
},
|
|
19
|
-
"invoices": {
|
|
20
|
-
"type": "tenant",
|
|
21
|
-
"idField": "id",
|
|
22
|
-
"filterColumn": "transaction_id",
|
|
23
|
-
"via": "transactions"
|
|
24
|
-
},
|
|
25
|
-
"balances": {
|
|
26
|
-
"type": "tenant",
|
|
27
|
-
"idField": "id",
|
|
28
|
-
"filterColumn": "user_id",
|
|
29
|
-
"via": "users"
|
|
30
|
-
},
|
|
31
|
-
"charges": {
|
|
32
|
-
"type": "tenant",
|
|
33
|
-
"idField": "id",
|
|
34
|
-
"filterColumn": "reference",
|
|
35
|
-
"via": "transactions"
|
|
36
|
-
},
|
|
37
|
-
"payouts": {
|
|
38
|
-
"type": "tenant",
|
|
39
|
-
"idField": "id",
|
|
40
|
-
"filterColumn": "provider_id"
|
|
41
|
-
},
|
|
42
|
-
"api_request_logs": {
|
|
43
|
-
"type": "tenant",
|
|
44
|
-
"idField": "id",
|
|
45
|
-
"filterColumn": "api_key",
|
|
46
|
-
"via": "api_keys"
|
|
47
|
-
},
|
|
48
|
-
"credit_requests": {
|
|
49
|
-
"type": "tenant",
|
|
50
|
-
"idField": "id",
|
|
51
|
-
"filterColumn": "user_id",
|
|
52
|
-
"via": "users"
|
|
53
|
-
},
|
|
54
|
-
"customers": {
|
|
55
|
-
"type": "tenant",
|
|
56
|
-
"idField": "id",
|
|
57
|
-
"filterColumn": "user_id",
|
|
58
|
-
"via": "users"
|
|
59
|
-
},
|
|
60
|
-
"daily_logs": {
|
|
61
|
-
"type": "tenant",
|
|
62
|
-
"idField": "id",
|
|
63
|
-
"filterColumn": "transaction_id",
|
|
64
|
-
"via": "transactions"
|
|
65
|
-
},
|
|
66
|
-
"global_user_transactions": {
|
|
67
|
-
"type": "tenant",
|
|
68
|
-
"idField": "id",
|
|
69
|
-
"filterColumn": "provider_id"
|
|
70
|
-
},
|
|
71
|
-
"notifications": {
|
|
72
|
-
"type": "tenant",
|
|
73
|
-
"idField": "id",
|
|
74
|
-
"filterColumn": "user_id",
|
|
75
|
-
"via": "users"
|
|
76
|
-
},
|
|
77
|
-
"pending_references": {
|
|
78
|
-
"type": "tenant",
|
|
79
|
-
"idField": "id",
|
|
80
|
-
"filterColumn": "provider_id"
|
|
81
|
-
},
|
|
82
|
-
"toku": {
|
|
83
|
-
"type": "tenant",
|
|
84
|
-
"idField": "id",
|
|
85
|
-
"filterColumn": "transaction_id",
|
|
86
|
-
"via": "transactions"
|
|
87
|
-
},
|
|
88
|
-
"transaction_updates": {
|
|
89
|
-
"type": "tenant",
|
|
90
|
-
"idField": "id",
|
|
91
|
-
"filterColumn": "transaction_id",
|
|
92
|
-
"via": "transactions"
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"commonSchema": "public",
|
|
3
|
+
"tenantInfo": {
|
|
4
|
+
"sourceTable": "api_keys",
|
|
5
|
+
"tenantIdColumn": "api_key",
|
|
6
|
+
"providerIdColumn": "provider_id"
|
|
7
|
+
},
|
|
8
|
+
"tables": {
|
|
9
|
+
"countries": { "type": "public", "idField": "id" },
|
|
10
|
+
"users": { "type": "public", "idField": "user_id" },
|
|
11
|
+
"providers": { "type": "public", "idField": "provider_id" },
|
|
12
|
+
"banks": { "type": "public", "idField": "id" },
|
|
13
|
+
"api_keys": { "type": "public", "idField": "id" },
|
|
14
|
+
"transactions": {
|
|
15
|
+
"type": "tenant",
|
|
16
|
+
"idField": "id",
|
|
17
|
+
"filterColumn": "provider_id"
|
|
18
|
+
},
|
|
19
|
+
"invoices": {
|
|
20
|
+
"type": "tenant",
|
|
21
|
+
"idField": "id",
|
|
22
|
+
"filterColumn": "transaction_id",
|
|
23
|
+
"via": "transactions"
|
|
24
|
+
},
|
|
25
|
+
"balances": {
|
|
26
|
+
"type": "tenant",
|
|
27
|
+
"idField": "id",
|
|
28
|
+
"filterColumn": "user_id",
|
|
29
|
+
"via": "users"
|
|
30
|
+
},
|
|
31
|
+
"charges": {
|
|
32
|
+
"type": "tenant",
|
|
33
|
+
"idField": "id",
|
|
34
|
+
"filterColumn": "reference",
|
|
35
|
+
"via": "transactions"
|
|
36
|
+
},
|
|
37
|
+
"payouts": {
|
|
38
|
+
"type": "tenant",
|
|
39
|
+
"idField": "id",
|
|
40
|
+
"filterColumn": "provider_id"
|
|
41
|
+
},
|
|
42
|
+
"api_request_logs": {
|
|
43
|
+
"type": "tenant",
|
|
44
|
+
"idField": "id",
|
|
45
|
+
"filterColumn": "api_key",
|
|
46
|
+
"via": "api_keys"
|
|
47
|
+
},
|
|
48
|
+
"credit_requests": {
|
|
49
|
+
"type": "tenant",
|
|
50
|
+
"idField": "id",
|
|
51
|
+
"filterColumn": "user_id",
|
|
52
|
+
"via": "users"
|
|
53
|
+
},
|
|
54
|
+
"customers": {
|
|
55
|
+
"type": "tenant",
|
|
56
|
+
"idField": "id",
|
|
57
|
+
"filterColumn": "user_id",
|
|
58
|
+
"via": "users"
|
|
59
|
+
},
|
|
60
|
+
"daily_logs": {
|
|
61
|
+
"type": "tenant",
|
|
62
|
+
"idField": "id",
|
|
63
|
+
"filterColumn": "transaction_id",
|
|
64
|
+
"via": "transactions"
|
|
65
|
+
},
|
|
66
|
+
"global_user_transactions": {
|
|
67
|
+
"type": "tenant",
|
|
68
|
+
"idField": "id",
|
|
69
|
+
"filterColumn": "provider_id"
|
|
70
|
+
},
|
|
71
|
+
"notifications": {
|
|
72
|
+
"type": "tenant",
|
|
73
|
+
"idField": "id",
|
|
74
|
+
"filterColumn": "user_id",
|
|
75
|
+
"via": "users"
|
|
76
|
+
},
|
|
77
|
+
"pending_references": {
|
|
78
|
+
"type": "tenant",
|
|
79
|
+
"idField": "id",
|
|
80
|
+
"filterColumn": "provider_id"
|
|
81
|
+
},
|
|
82
|
+
"toku": {
|
|
83
|
+
"type": "tenant",
|
|
84
|
+
"idField": "id",
|
|
85
|
+
"filterColumn": "transaction_id",
|
|
86
|
+
"via": "transactions"
|
|
87
|
+
},
|
|
88
|
+
"transaction_updates": {
|
|
89
|
+
"type": "tenant",
|
|
90
|
+
"idField": "id",
|
|
91
|
+
"filterColumn": "transaction_id",
|
|
92
|
+
"via": "transactions"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
-- Migration: Add reserved_amount column to balances table
|
|
2
|
-
-- Date: 2025-01-31
|
|
3
|
-
|
|
4
|
-
ALTER TABLE balances
|
|
5
|
-
ADD COLUMN reserved_amount DECIMAL(10,2) NOT NULL DEFAULT 0.00;
|
|
6
|
-
|
|
7
|
-
-- Add comment for documentation
|
|
1
|
+
-- Migration: Add reserved_amount column to balances table
|
|
2
|
+
-- Date: 2025-01-31
|
|
3
|
+
|
|
4
|
+
ALTER TABLE balances
|
|
5
|
+
ADD COLUMN reserved_amount DECIMAL(10,2) NOT NULL DEFAULT 0.00;
|
|
6
|
+
|
|
7
|
+
-- Add comment for documentation
|
|
8
8
|
COMMENT ON COLUMN balances.reserved_amount IS 'Amount reserved for pending payouts';
|
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@javalabs/prisma-client",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Shared Prisma client for Tupay microservices",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"private": false,
|
|
8
|
-
"publishConfig": {
|
|
9
|
-
"access": "
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc",
|
|
13
|
-
"generate": "prisma generate",
|
|
14
|
-
"migrate:dev": "prisma migrate dev",
|
|
15
|
-
"migrate:deploy": "prisma migrate deploy",
|
|
16
|
-
"migrate:data": "node dist/scripts/run-migration.js migrate",
|
|
17
|
-
"migrate:data:force": "node dist/scripts/run-migration.js migrate --force",
|
|
18
|
-
"migrate:data:yes": "node dist/scripts/run-migration.js migrate -y",
|
|
19
|
-
"postinstall": "npx prisma generate"
|
|
20
|
-
},
|
|
21
|
-
"prisma": {
|
|
22
|
-
"schema": "prisma/schema.prisma"
|
|
23
|
-
},
|
|
24
|
-
"keywords": [],
|
|
25
|
-
"author": "",
|
|
26
|
-
"license": "ISC",
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@nestjs/common": "^10.0.0",
|
|
29
|
-
"@nestjs/core": "^10.0.0",
|
|
30
|
-
"@prisma/client": "
|
|
31
|
-
"bcrypt": "^6.0.0",
|
|
32
|
-
"commander": "^11.1.0",
|
|
33
|
-
"dotenv": "^16.4.7",
|
|
34
|
-
"pg": "^8.14.1",
|
|
35
|
-
"uuid": "^11.1.0"
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@types/bcrypt": "^5.0.2",
|
|
39
|
-
"@types/node": "^20.3.1",
|
|
40
|
-
"@types/pg": "^8.11.11",
|
|
41
|
-
"prisma": "
|
|
42
|
-
"typescript": "^5.2.2"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@javalabs/prisma-client",
|
|
3
|
+
"version": "1.0.29",
|
|
4
|
+
"description": "Shared Prisma client for Tupay microservices",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"private": false,
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"generate": "prisma generate",
|
|
14
|
+
"migrate:dev": "prisma migrate dev",
|
|
15
|
+
"migrate:deploy": "prisma migrate deploy",
|
|
16
|
+
"migrate:data": "node dist/scripts/run-migration.js migrate",
|
|
17
|
+
"migrate:data:force": "node dist/scripts/run-migration.js migrate --force",
|
|
18
|
+
"migrate:data:yes": "node dist/scripts/run-migration.js migrate -y",
|
|
19
|
+
"postinstall": "npx prisma@6.17.1 generate"
|
|
20
|
+
},
|
|
21
|
+
"prisma": {
|
|
22
|
+
"schema": "prisma/schema.prisma"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "ISC",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@nestjs/common": "^10.0.0",
|
|
29
|
+
"@nestjs/core": "^10.0.0",
|
|
30
|
+
"@prisma/client": "6.17.1",
|
|
31
|
+
"bcrypt": "^6.0.0",
|
|
32
|
+
"commander": "^11.1.0",
|
|
33
|
+
"dotenv": "^16.4.7",
|
|
34
|
+
"pg": "^8.14.1",
|
|
35
|
+
"uuid": "^11.1.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/bcrypt": "^5.0.2",
|
|
39
|
+
"@types/node": "^20.3.1",
|
|
40
|
+
"@types/pg": "^8.11.11",
|
|
41
|
+
"prisma": "6.17.1",
|
|
42
|
+
"typescript": "^5.2.2"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
-- Habilitar la extensión uuid-ossp si no está habilitada
|
|
2
|
-
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
3
|
-
|
|
4
|
-
-- Añadir la columna uuid como nullable
|
|
5
|
-
ALTER TABLE transactions ADD COLUMN uuid VARCHAR(255);
|
|
6
|
-
|
|
7
|
-
-- Actualizar los registros existentes con UUIDs
|
|
8
|
-
UPDATE transactions SET uuid = uuid_generate_v4() WHERE uuid IS NULL;
|
|
9
|
-
|
|
10
|
-
-- Crear el índice
|
|
11
|
-
CREATE INDEX idx_transactions_uuid ON transactions(uuid);
|
|
12
|
-
|
|
13
|
-
-- Añadir la restricción unique
|
|
1
|
+
-- Habilitar la extensión uuid-ossp si no está habilitada
|
|
2
|
+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
3
|
+
|
|
4
|
+
-- Añadir la columna uuid como nullable
|
|
5
|
+
ALTER TABLE transactions ADD COLUMN uuid VARCHAR(255);
|
|
6
|
+
|
|
7
|
+
-- Actualizar los registros existentes con UUIDs
|
|
8
|
+
UPDATE transactions SET uuid = uuid_generate_v4() WHERE uuid IS NULL;
|
|
9
|
+
|
|
10
|
+
-- Crear el índice
|
|
11
|
+
CREATE INDEX idx_transactions_uuid ON transactions(uuid);
|
|
12
|
+
|
|
13
|
+
-- Añadir la restricción unique
|
|
14
14
|
ALTER TABLE transactions ADD CONSTRAINT transactions_uuid_key UNIQUE (uuid);
|