diff --git a/README.md b/README.md index fea9b70..85afb68 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,26 @@ docker builder prune --all npm install @prisma/client npm install -D prisma +npm install class-validator class-transformer --legacy-peer-deps + +npx prisma generate # generate client +npx prisma db pull # update local schema + +npx prisma db seed # seed database + +nest generate module +nest generate service +nest generate controller + +or / alias +nest g module +nest g service +nest g controller + +npm install @liaoliaots/nestjs-redis ioredis --legacy-peer-deps + +npx prisma migrate dev --name "comment" # good for production creates step of migration +npx prisma db push # update remote schema # not good for production creates no step of migration + +npx prisma validate +npx prisma format diff --git a/ServicesApi/Dockerfile b/ServicesApi/Dockerfile index ab934e6..9dfbf9b 100644 --- a/ServicesApi/Dockerfile +++ b/ServicesApi/Dockerfile @@ -3,12 +3,12 @@ FROM node:20-alpine AS builder WORKDIR /usr/src/app -COPY backend/package*.json ./ +COPY ServicesApi/package*.json ./ RUN npm install -g npm@latest -RUN npm ci +RUN npm ci --legacy-peer-deps -COPY backend . +COPY ServicesApi . RUN npm run build diff --git a/ServicesApi/package-lock.json b/ServicesApi/package-lock.json index b314fd5..9e03e39 100644 --- a/ServicesApi/package-lock.json +++ b/ServicesApi/package-lock.json @@ -9,12 +9,18 @@ "version": "0.0.1", "license": "UNLICENSED", "dependencies": { + "@liaoliaots/nestjs-redis": "^10.0.0", "@nestjs/common": "^11.0.1", "@nestjs/core": "^11.0.1", "@nestjs/platform-express": "^11.0.1", "@prisma/client": "^6.12.0", + "class-transformer": "^0.5.1", + "class-validator": "^0.14.2", + "ioredis": "^5.6.1", + "redis": "^5.6.1", "reflect-metadata": "^0.2.2", - "rxjs": "^7.8.1" + "rxjs": "^7.8.1", + "uuid": "^11.1.0" }, "devDependencies": { "@eslint/eslintrc": "^3.2.0", @@ -1292,6 +1298,12 @@ } } }, + "node_modules/@ioredis/commands": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz", + "integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==", + "license": "MIT" + }, "node_modules/@isaacs/balanced-match": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz", @@ -1916,6 +1928,29 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@liaoliaots/nestjs-redis": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@liaoliaots/nestjs-redis/-/nestjs-redis-10.0.0.tgz", + "integrity": "sha512-uCTmlzM4q+UYADwsJEQph0mbf4u0MrktFhByi50M5fNy/+fJoWlhSqrgvjtVKjHnqydxy1gyuU6vHJEOBp9cjg==", + "license": "MIT", + "dependencies": { + "tslib": "2.7.0" + }, + "engines": { + "node": ">=16.13.0" + }, + "peerDependencies": { + "@nestjs/common": "^10.0.0", + "@nestjs/core": "^10.0.0", + "ioredis": "^5.0.0" + } + }, + "node_modules/@liaoliaots/nestjs-redis/node_modules/tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "license": "0BSD" + }, "node_modules/@lukeed/csprng": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.1.0.tgz", @@ -2780,7 +2815,7 @@ "version": "6.12.0", "resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.12.0.tgz", "integrity": "sha512-HovZWzhWEMedHxmjefQBRZa40P81N7/+74khKFz9e1AFjakcIQdXgMWKgt20HaACzY+d1LRBC+L4tiz71t9fkg==", - "devOptional": true, + "dev": true, "license": "Apache-2.0", "dependencies": { "jiti": "2.4.2" @@ -2790,14 +2825,14 @@ "version": "6.12.0", "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.12.0.tgz", "integrity": "sha512-plbz6z72orcqr0eeio7zgUrZj5EudZUpAeWkFTA/DDdXEj28YHDXuiakvR6S7sD6tZi+jiwQEJAPeV6J6m/tEQ==", - "devOptional": true, + "dev": true, "license": "Apache-2.0" }, "node_modules/@prisma/engines": { "version": "6.12.0", "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.12.0.tgz", "integrity": "sha512-4BRZZUaAuB4p0XhTauxelvFs7IllhPmNLvmla0bO1nkECs8n/o1pUvAVbQ/VOrZR5DnF4HED0PrGai+rIOVePA==", - "devOptional": true, + "dev": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -2811,14 +2846,14 @@ "version": "6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc", "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.12.0-15.8047c96bbd92db98a2abc7c9323ce77c02c89dbc.tgz", "integrity": "sha512-70vhecxBJlRr06VfahDzk9ow4k1HIaSfVUT3X0/kZoHCMl9zbabut4gEXAyzJZxaCGi5igAA7SyyfBI//mmkbQ==", - "devOptional": true, + "dev": true, "license": "Apache-2.0" }, "node_modules/@prisma/fetch-engine": { "version": "6.12.0", "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.12.0.tgz", "integrity": "sha512-EamoiwrK46rpWaEbLX9aqKDPOd8IyLnZAkiYXFNuq0YsU0Z8K09/rH8S7feOWAVJ3xzeSgcEJtBlVDrajM9Sag==", - "devOptional": true, + "dev": true, "license": "Apache-2.0", "dependencies": { "@prisma/debug": "6.12.0", @@ -2830,12 +2865,72 @@ "version": "6.12.0", "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.12.0.tgz", "integrity": "sha512-nRerTGhTlgyvcBlyWgt8OLNIV7QgJS2XYXMJD1hysorMCuLAjuDDuoxmVt7C2nLxbuxbWPp7OuFRHC23HqD9dA==", - "devOptional": true, + "dev": true, "license": "Apache-2.0", "dependencies": { "@prisma/debug": "6.12.0" } }, + "node_modules/@redis/bloom": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-5.6.1.tgz", + "integrity": "sha512-5/22U76IMEfn6TeZ+uvjXspHw+ykBF0kpBa8xouzeHaQMXs/auqBUOEYzU2VKYDvnd2RSpPTyIg82oB7PpUgLg==", + "license": "MIT", + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@redis/client": "^5.6.1" + } + }, + "node_modules/@redis/client": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/@redis/client/-/client-5.6.1.tgz", + "integrity": "sha512-bWHmSFIJ5w1Y4aHsYs46XMDHKQsBHFRhNcllYaBxz2Zl+lu+gbm5yI9BqxvKh48bLTs/Wx1Kns0gN2WIasE8MA==", + "license": "MIT", + "dependencies": { + "cluster-key-slot": "1.1.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@redis/json": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/@redis/json/-/json-5.6.1.tgz", + "integrity": "sha512-cTggVzPIVuiFeXcEcnTRiUzV7rmUvM9KUYxWiHyjsAVACTEUe4ifKkvzrij0H/z3ammU5tfGACffDB3olBwtVA==", + "license": "MIT", + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@redis/client": "^5.6.1" + } + }, + "node_modules/@redis/search": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/@redis/search/-/search-5.6.1.tgz", + "integrity": "sha512-+eOjx8O2YoKygjqkLpTHqcAq0zKLjior+ee2tRBx/3RSf1+OHxiC9Y6NstshQpvB1XHqTw9n7+f0+MsRJZrp0g==", + "license": "MIT", + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@redis/client": "^5.6.1" + } + }, + "node_modules/@redis/time-series": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-5.6.1.tgz", + "integrity": "sha512-sd3q4jMJdoSO2akw1L9NrdFI1JJ6zeMgMUoTh4a34p9sY3AnOI4aDLCecy8L2IcPAP1oNR3TbLFJiCJDQ35QTA==", + "license": "MIT", + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@redis/client": "^5.6.1" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -3526,6 +3621,12 @@ "@types/superagent": "^8.1.0" } }, + "node_modules/@types/validator": { + "version": "13.15.2", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.15.2.tgz", + "integrity": "sha512-y7pa/oEJJ4iGYBxOpfAKn5b9+xuihvzDVnC/OSvlVnGxVg0pOqmjiMafiJ1KVNQEaPZf9HsEp5icEwGg8uIe5Q==", + "license": "MIT" + }, "node_modules/@types/yargs": { "version": "17.0.33", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", @@ -4274,20 +4375,6 @@ "node": ">=0.4.0" } }, - "node_modules/acorn-import-phases": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/acorn-import-phases/-/acorn-import-phases-1.0.4.tgz", - "integrity": "sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">=10.13.0" - }, - "peerDependencies": { - "acorn": "^8.14.0" - } - }, "node_modules/acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", @@ -5100,6 +5187,23 @@ "dev": true, "license": "MIT" }, + "node_modules/class-transformer": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", + "license": "MIT" + }, + "node_modules/class-validator": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.14.2.tgz", + "integrity": "sha512-3kMVRF2io8N8pY1IFIXlho9r8IPUUIfHe2hYVtiebvAzU2XeQFXTv+XI4WX+TnXmtwXMDcjngcpkiPM0O9PvLw==", + "license": "MIT", + "dependencies": { + "@types/validator": "^13.11.8", + "libphonenumber-js": "^1.11.1", + "validator": "^13.9.0" + } + }, "node_modules/cli-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", @@ -5218,6 +5322,15 @@ "node": ">=0.8" } }, + "node_modules/cluster-key-slot": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", + "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==", + "license": "Apache-2.0", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -5593,6 +5706,15 @@ "node": ">=0.4.0" } }, + "node_modules/denque": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", + "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", + "license": "Apache-2.0", + "engines": { + "node": ">=0.10" + } + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -7149,6 +7271,30 @@ "kind-of": "^6.0.2" } }, + "node_modules/ioredis": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.6.1.tgz", + "integrity": "sha512-UxC0Yv1Y4WRJiGQxQkP0hfdL0/5/6YvdfOOClRgJ0qppSarkhneSa6UvkMkms0AkdGimSH3Ikqm+6mkMmX7vGA==", + "license": "MIT", + "dependencies": { + "@ioredis/commands": "^1.1.1", + "cluster-key-slot": "^1.1.0", + "debug": "^4.3.4", + "denque": "^2.1.0", + "lodash.defaults": "^4.2.0", + "lodash.isarguments": "^3.1.0", + "redis-errors": "^1.2.0", + "redis-parser": "^3.0.0", + "standard-as-callback": "^2.1.0" + }, + "engines": { + "node": ">=12.22.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/ioredis" + } + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -8083,7 +8229,7 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz", "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", - "devOptional": true, + "dev": true, "license": "MIT", "bin": { "jiti": "lib/jiti-cli.mjs" @@ -8237,6 +8383,12 @@ "node": ">= 0.8.0" } }, + "node_modules/libphonenumber-js": { + "version": "1.12.10", + "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.12.10.tgz", + "integrity": "sha512-E91vHJD61jekHHR/RF/E83T/CMoaLXT7cwYA75T4gim4FZjnM6hbJjVIGg7chqlSqRsSvQ3izGmOjHy1SQzcGQ==", + "license": "MIT" + }, "node_modules/lines-and-columns": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", @@ -8296,6 +8448,18 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash.defaults": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", + "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==", + "license": "MIT" + }, + "node_modules/lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==", + "license": "MIT" + }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -9271,7 +9435,7 @@ "version": "6.12.0", "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.12.0.tgz", "integrity": "sha512-pmV7NEqQej9WjizN6RSNIwf7Y+jeh9mY1JEX2WjGxJi4YZWexClhde1yz/FuvAM+cTwzchcMytu2m4I6wPkIzg==", - "devOptional": true, + "dev": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -9465,6 +9629,43 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/redis": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/redis/-/redis-5.6.1.tgz", + "integrity": "sha512-O9DwAvcBm/lrlkGE0A6gNBtUdA8J9oD9njeLYlLzmm+MGTR7nd7VkpspfXqeXFg3gm89zldDqckyaHhXfhY80g==", + "license": "MIT", + "dependencies": { + "@redis/bloom": "5.6.1", + "@redis/client": "5.6.1", + "@redis/json": "5.6.1", + "@redis/search": "5.6.1", + "@redis/time-series": "5.6.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/redis-errors": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", + "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/redis-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", + "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", + "license": "MIT", + "dependencies": { + "redis-errors": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/reflect-metadata": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz", @@ -10045,6 +10246,12 @@ "node": ">=8" } }, + "node_modules/standard-as-callback": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", + "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==", + "license": "MIT" + }, "node_modules/statuses": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", @@ -10949,7 +11156,7 @@ "version": "5.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", - "devOptional": true, + "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -11091,6 +11298,19 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "license": "MIT" }, + "node_modules/uuid": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", + "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/esm/bin/uuid" + } + }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", @@ -11113,6 +11333,15 @@ "node": ">=10.12.0" } }, + "node_modules/validator": { + "version": "13.15.15", + "resolved": "https://registry.npmjs.org/validator/-/validator-13.15.15.tgz", + "integrity": "sha512-BgWVbCI72aIQy937xbawcs+hrVaN/CZ2UwutgaJ36hGqRrLNM+f5LUT/YPRbo8IV/ASeFzXszezV+y2+rq3l8A==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -11169,56 +11398,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/webpack": { - "version": "5.100.2", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.100.2.tgz", - "integrity": "sha512-QaNKAvGCDRh3wW1dsDjeMdDXwZm2vqq3zn6Pvq4rHOEOGSaUMgOOjG2Y9ZbIGzpfkJk9ZYTHpDqgDfeBDcnLaw==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@types/eslint-scope": "^3.7.7", - "@types/estree": "^1.0.8", - "@types/json-schema": "^7.0.15", - "@webassemblyjs/ast": "^1.14.1", - "@webassemblyjs/wasm-edit": "^1.14.1", - "@webassemblyjs/wasm-parser": "^1.14.1", - "acorn": "^8.15.0", - "acorn-import-phases": "^1.0.3", - "browserslist": "^4.24.0", - "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.17.2", - "es-module-lexer": "^1.2.1", - "eslint-scope": "5.1.1", - "events": "^3.2.0", - "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.2.11", - "json-parse-even-better-errors": "^2.3.1", - "loader-runner": "^4.2.0", - "mime-types": "^2.1.27", - "neo-async": "^2.6.2", - "schema-utils": "^4.3.2", - "tapable": "^2.1.1", - "terser-webpack-plugin": "^5.3.11", - "watchpack": "^2.4.1", - "webpack-sources": "^3.3.3" - }, - "bin": { - "webpack": "bin/webpack.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - }, - "peerDependenciesMeta": { - "webpack-cli": { - "optional": true - } - } - }, "node_modules/webpack-node-externals": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/webpack-node-externals/-/webpack-node-externals-3.0.0.tgz", @@ -11239,137 +11418,6 @@ "node": ">=10.13.0" } }, - "node_modules/webpack/node_modules/ajv": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", - "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/webpack/node_modules/ajv-formats": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", - "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "ajv": "^8.0.0" - }, - "peerDependencies": { - "ajv": "^8.0.0" - }, - "peerDependenciesMeta": { - "ajv": { - "optional": true - } - } - }, - "node_modules/webpack/node_modules/ajv-keywords": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", - "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, - "node_modules/webpack/node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "license": "BSD-2-Clause", - "peer": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/webpack/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "license": "BSD-2-Clause", - "peer": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/webpack/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/webpack/node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/webpack/node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/webpack/node_modules/schema-utils": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.3.2.tgz", - "integrity": "sha512-Gn/JaSk/Mt9gYubxTtSn/QCV4em9mpAPiR1rqy/Ocu19u/G9J5WWdNoUT4SiV6mFC3y6cxyFcFwdzPM3FgxGAQ==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@types/json-schema": "^7.0.9", - "ajv": "^8.9.0", - "ajv-formats": "^2.1.1", - "ajv-keywords": "^5.1.0" - }, - "engines": { - "node": ">= 10.13.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/ServicesApi/package.json b/ServicesApi/package.json index 52d9fcb..165a70e 100644 --- a/ServicesApi/package.json +++ b/ServicesApi/package.json @@ -20,12 +20,18 @@ "test:e2e": "jest --config ./test/jest-e2e.json" }, "dependencies": { + "@liaoliaots/nestjs-redis": "^10.0.0", "@nestjs/common": "^11.0.1", "@nestjs/core": "^11.0.1", "@nestjs/platform-express": "^11.0.1", "@prisma/client": "^6.12.0", + "class-transformer": "^0.5.1", + "class-validator": "^0.14.2", + "ioredis": "^5.6.1", + "redis": "^5.6.1", "reflect-metadata": "^0.2.2", - "rxjs": "^7.8.1" + "rxjs": "^7.8.1", + "uuid": "^11.1.0" }, "devDependencies": { "@eslint/eslintrc": "^3.2.0", diff --git a/ServicesApi/prisma/migrations/20250724210827_init/migration.sql b/ServicesApi/prisma/migrations/20250724210827_init/migration.sql deleted file mode 100644 index 0504f9b..0000000 --- a/ServicesApi/prisma/migrations/20250724210827_init/migration.sql +++ /dev/null @@ -1,11 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" SERIAL NOT NULL, - "name" TEXT NOT NULL, - "email" TEXT NOT NULL, - - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/ServicesApi/prisma/migrations/migration_lock.toml b/ServicesApi/prisma/migrations/migration_lock.toml deleted file mode 100644 index 044d57c..0000000 --- a/ServicesApi/prisma/migrations/migration_lock.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Please do not edit this file manually -# It should be added in your version-control system (e.g., Git) -provider = "postgresql" diff --git a/ServicesApi/prisma/prisma.module.ts b/ServicesApi/prisma/prisma.module.ts index 29e0642..80b9a8a 100644 --- a/ServicesApi/prisma/prisma.module.ts +++ b/ServicesApi/prisma/prisma.module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; -import { PrismaService } from '@/prisma.service'; +import { PrismaService } from '@/src/prisma.service'; @Module({ providers: [PrismaService], - exports: [PrismaService], // Dışarı açıyoruz ki başka modüller kullanabilsin + exports: [PrismaService], }) export class PrismaModule {} diff --git a/ServicesApi/prisma/schema.prisma b/ServicesApi/prisma/schema.prisma index efcb136..3764eae 100644 --- a/ServicesApi/prisma/schema.prisma +++ b/ServicesApi/prisma/schema.prisma @@ -1,10 +1,3616 @@ generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" binaryTargets = ["native", "linux-musl-openssl-3.0.x"] } datasource db { provider = "postgresql" - url = "postgresql://postgres:password@10.10.2.14:5432/sample_db?schema=public" + url = "postgresql://postgres:password@10.10.2.14:5432/postgres?schema=public" } +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model account_books { + country String @db.VarChar + branch_type Int @default(0) @db.SmallInt + company_id Int + company_uu_id String @db.VarChar + branch_id Int + branch_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_account_books_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + companies_account_books_branch_idTocompanies companies @relation("account_books_branch_idTocompanies", fields: [branch_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies_account_books_company_idTocompanies companies @relation("account_books_company_idTocompanies", fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + account_detail account_detail[] + account_master account_master[] + + @@index([company_id, expiry_starts], map: "account_companies_book_ndx_00") + @@index([created_at], map: "ix_account_books_created_at") + @@index([cryp_uu_id], map: "ix_account_books_cryp_uu_id") + @@index([ref_id], map: "ix_account_books_ref_id") + @@index([ref_int], map: "ix_account_books_ref_int") + @@index([updated_at], map: "ix_account_books_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model account_code_parser { + account_code_1 String @db.VarChar + account_code_2 String @db.VarChar + account_code_3 String @db.VarChar + account_code_4 String @default("") @db.VarChar + account_code_5 String @default("") @db.VarChar + account_code_6 String @default("") @db.VarChar + account_code_id Int + account_code_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_account_code_parser_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_codes account_codes @relation(fields: [account_code_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([account_code_id], map: "_account_code_parser_ndx_00") + @@index([created_at], map: "ix_account_code_parser_created_at") + @@index([cryp_uu_id], map: "ix_account_code_parser_cryp_uu_id") + @@index([ref_id], map: "ix_account_code_parser_ref_id") + @@index([ref_int], map: "ix_account_code_parser_ref_int") + @@index([updated_at], map: "ix_account_code_parser_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model account_codes { + account_code String @db.VarChar(48) + comment_line String @db.VarChar(128) + is_receive_or_debit Boolean + product_id Int @default(0) + nvi_id String @default("") @db.VarChar(48) + status_id Int @default(0) @db.SmallInt + account_code_seperator String @default(".") @db.VarChar(1) + system_id Int @default(0) @db.SmallInt + locked Int @default(0) @db.SmallInt + company_id Int + company_uu_id String @db.VarChar + customer_id Int + customer_uu_id String @db.VarChar + person_id Int + person_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_account_codes_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_code_parser account_code_parser[] + companies_account_codes_company_idTocompanies companies @relation("account_codes_company_idTocompanies", fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies_account_codes_customer_idTocompanies companies @relation("account_codes_customer_idTocompanies", fields: [customer_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people people @relation(fields: [person_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + account_detail account_detail[] + + @@index([created_at], map: "ix_account_codes_created_at") + @@index([cryp_uu_id], map: "ix_account_codes_cryp_uu_id") + @@index([ref_id], map: "ix_account_codes_ref_id") + @@index([ref_int], map: "ix_account_codes_ref_int") + @@index([updated_at], map: "ix_account_codes_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model account_delay_interest { + interest_turn String @default("akdi") @db.VarChar(10) + interest_rate Decimal @default(0) @db.Decimal(10, 2) + delay_day Int @default(0) + daily_rate Decimal @default(0) @db.Decimal(20, 6) + interest Decimal @default(0) @db.Decimal(20, 6) + bsmv Decimal @default(0) @db.Decimal(20, 6) + kkdf Decimal @default(0) @db.Decimal(20, 6) + total Decimal @default(0) @db.Decimal(20, 6) + account_record_bank_date DateTime? @db.Timestamptz(6) + book_payment_process_date DateTime? @db.Timestamptz(6) + debt Decimal @db.Decimal(20, 6) + approving_at DateTime? @db.Timestamptz(6) + approved_record Boolean @default(false) + approving_person_id Int? + approving_person_uu_id String? @db.VarChar + account_records_id Int + account_records_uu_id String @db.VarChar(100) + build_decision_book_payment_id Int + build_decision_book_payment_uu_id String? @db.VarChar(100) + new_build_decision_book_payment_id Int? + new_build_decision_book_payment_uu_id String? @db.VarChar + ref_int Int? + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_account_delay_interest_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + bank_resp_company_id Int? + bank_resp_company_uu_id String? @db.VarChar + account_records account_records @relation(fields: [account_records_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_payments build_decision_book_payments @relation(fields: [build_decision_book_payment_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([account_records_id, build_decision_book_payment_id], map: "_account_delay_interest_ndx_00") + @@index([created_at], map: "ix_account_delay_interest_created_at") + @@index([cryp_uu_id], map: "ix_account_delay_interest_cryp_uu_id") + @@index([ref_id], map: "ix_account_delay_interest_ref_id") + @@index([ref_int], map: "ix_account_delay_interest_ref_int") + @@index([updated_at], map: "ix_account_delay_interest_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model account_detail { + doc_date DateTime @db.Timestamptz(6) + line_no Int @db.SmallInt + receive_debit String @db.VarChar(1) + debit Decimal @db.Decimal(20, 6) + department String @default("") @db.VarChar(24) + special_code String @default("") @db.VarChar(12) + account_ref Int @default(0) + account_fiche_ref Int @default(0) + center_ref Int @default(0) + general_code String @default("") @db.VarChar(32) + credit Decimal @default(0) @db.Decimal(20, 6) + currency_type String @default("TL") @db.VarChar(4) + exchange_rate Decimal @default(0) @db.Decimal(20, 6) + debit_cur Decimal @default(0) @db.Decimal(20, 6) + credit_cur Decimal @default(0) @db.Decimal(20, 6) + discount_cur Decimal @default(0) @db.Decimal(20, 6) + amount Decimal @default(0) @db.Decimal(20, 6) + cross_account_code String @default("") @db.VarChar(32) + inf_index Decimal @default(0) @db.Decimal(20, 6) + not_inflated Int @default(0) @db.SmallInt + not_calculated Int @default(0) @db.SmallInt + comment_line1 String @default("") @db.VarChar(64) + comment_line2 String @default("") @db.VarChar(64) + comment_line3 String @default("") @db.VarChar(64) + comment_line4 String @default("") @db.VarChar(64) + comment_line5 String @default("") @db.VarChar(64) + comment_line6 String @default("") @db.VarChar(64) + owner_acc_ref Int @default(0) + from_where Int @default(0) + orj_eid Int @default(0) + canceled Int @default(0) @db.SmallInt + cross_ref Int @default(0) + data_center_id String @default("") @db.VarChar + data_center_rec_num Int @default(0) + status_id Int @default(0) @db.SmallInt + plug_type_id Int? + plug_type_uu_id String @db.VarChar + account_header_id Int + account_header_uu_id String @db.VarChar + account_code_id Int + account_code_uu_id String @db.VarChar + account_master_id Int + account_master_uu_id String @db.VarChar + project_id Int + project_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_account_detail_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_codes account_codes @relation(fields: [account_code_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + account_books account_books @relation(fields: [account_header_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + account_master account_master @relation(fields: [account_master_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown api_enum_dropdown? @relation(fields: [plug_type_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_projects build_decision_book_projects @relation(fields: [project_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([account_master_id, doc_date, line_no, account_header_id], map: "_account_detail_ndx_00") + @@index([created_at], map: "ix_account_detail_created_at") + @@index([cryp_uu_id], map: "ix_account_detail_cryp_uu_id") + @@index([ref_id], map: "ix_account_detail_ref_id") + @@index([ref_int], map: "ix_account_detail_ref_int") + @@index([updated_at], map: "ix_account_detail_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model account_master { + doc_date DateTime @db.Timestamptz(6) + plug_type String @db.VarChar + plug_number Int + special_code String @default("") @db.VarChar(12) + authorization_code String @default("") @db.VarChar(12) + doc_code String @default("") @db.VarChar(12) + doc_type Int @default(0) @db.SmallInt + comment_line1 String @default("") @db.VarChar + comment_line2 String @default("") @db.VarChar + comment_line3 String @default("") @db.VarChar + comment_line4 String @default("") @db.VarChar + comment_line5 String @default("") @db.VarChar + comment_line6 String @default("") @db.VarChar + project_code String @default("") @db.VarChar(12) + module_no String @default("") @db.VarChar + journal_no Int @default(0) + status_id Int @default(0) @db.SmallInt + canceled Boolean @default(false) + print_count Int @default(0) @db.SmallInt + total_active Decimal @default(0) @db.Decimal(20, 6) + total_passive Decimal @default(0) @db.Decimal(20, 6) + total_active_1 Decimal @default(0) @db.Decimal(20, 6) + total_passive_1 Decimal @default(0) @db.Decimal(20, 6) + total_active_2 Decimal @default(0) @db.Decimal(20, 6) + total_passive_2 Decimal @default(0) @db.Decimal(20, 6) + total_active_3 Decimal @default(0) @db.Decimal(20, 6) + total_passive_3 Decimal @default(0) @db.Decimal(20, 6) + total_active_4 Decimal @default(0) @db.Decimal(20, 6) + total_passive_4 Decimal @default(0) @db.Decimal(20, 6) + cross_ref Int @default(0) + data_center_id String @default("") @db.VarChar + data_center_rec_num Int @default(0) + account_header_id Int + account_header_uu_id String @db.VarChar + project_item_id Int + project_item_uu_id String @db.VarChar + department_id Int + department_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_account_master_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_detail account_detail[] + account_books account_books @relation(fields: [account_header_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + departments departments @relation(fields: [department_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_projects build_decision_book_projects @relation(fields: [project_item_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([doc_date, account_header_id], map: "_account_master_ndx_00") + @@index([created_at], map: "ix_account_master_created_at") + @@index([cryp_uu_id], map: "ix_account_master_cryp_uu_id") + @@index([ref_id], map: "ix_account_master_ref_id") + @@index([ref_int], map: "ix_account_master_ref_int") + @@index([updated_at], map: "ix_account_master_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model account_record_exchanges { + are_currency String @db.VarChar(5) + are_exchange_rate Decimal @default(1) @db.Decimal(18, 6) + usd_exchange_rate_value Decimal? @default(0) @db.Decimal(18, 6) + eur_exchange_rate_value Decimal? @default(0) @db.Decimal(18, 6) + gbp_exchange_rate_value Decimal? @default(0) @db.Decimal(18, 6) + cny_exchange_rate_value Decimal? @default(0) @db.Decimal(18, 6) + account_records_id Int + account_records_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_account_record_exchanges_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_records account_records @relation(fields: [account_records_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([account_records_id], map: "_account_record_exchanges_ndx_00") + @@index([created_at], map: "ix_account_record_exchanges_created_at") + @@index([cryp_uu_id], map: "ix_account_record_exchanges_cryp_uu_id") + @@index([ref_id], map: "ix_account_record_exchanges_ref_id") + @@index([ref_int], map: "ix_account_record_exchanges_ref_int") + @@index([updated_at], map: "ix_account_record_exchanges_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model account_records { + iban String @db.VarChar(64) + bank_date DateTime @db.Timestamptz(6) + currency_value Decimal @db.Decimal(20, 6) + bank_balance Decimal @db.Decimal(20, 6) + currency String @db.VarChar(5) + additional_balance Decimal @db.Decimal(20, 6) + channel_branch String @db.VarChar(120) + process_name String @db.VarChar + process_type String @db.VarChar + process_comment String @db.VarChar + process_garbage String? @db.VarChar + bank_reference_code String @db.VarChar + add_comment_note String @default("") @db.VarChar + is_receipt_mail_send Boolean @default(false) + found_from String? @default("") @db.VarChar + similarity Decimal @default(0) @db.Decimal(20, 6) + remainder_balance Decimal @default(0) @db.Decimal(20, 6) + bank_date_y Int + bank_date_m Int @db.SmallInt + bank_date_w Int @db.SmallInt + bank_date_d Int @db.SmallInt + approving_accounting_record Boolean @default(false) + accounting_receipt_date DateTime @default(dbgenerated("'1900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + accounting_receipt_number Int @default(0) + status_id Int @default(0) @db.SmallInt + approved_record Boolean @default(false) + import_file_name String? @db.VarChar + receive_debit Int? + receive_debit_uu_id String? @db.VarChar + budget_type Int? + budget_type_uu_id String? @db.VarChar + company_id Int? + company_uu_id String? @db.VarChar + send_company_id Int? + send_company_uu_id String? @db.VarChar + send_person_id Int? + send_person_uu_id String? @db.VarChar + approving_accounting_person Int? + approving_accounting_person_uu_id String? @db.VarChar + living_space_id Int? + living_space_uu_id String? @db.VarChar + customer_id Int? + customer_uu_id String? @db.VarChar + build_id Int? + build_uu_id String? @db.VarChar + build_parts_id Int? + build_parts_uu_id String? @db.VarChar + build_decision_book_id Int? + build_decision_book_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_account_records_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + payment_result_type Int? + payment_result_type_uu_id String? @db.VarChar + is_commission_applied Boolean @default(false) + account_delay_interest account_delay_interest[] + account_record_exchanges account_record_exchanges[] + people_account_records_approving_accounting_personTopeople people? @relation("account_records_approving_accounting_personTopeople", fields: [approving_accounting_person], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown_account_records_budget_typeToapi_enum_dropdown api_enum_dropdown? @relation("account_records_budget_typeToapi_enum_dropdown", fields: [budget_type], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book build_decision_book? @relation(fields: [build_decision_book_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build build? @relation(fields: [build_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_parts build_parts? @relation(fields: [build_parts_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies_account_records_company_idTocompanies companies? @relation("account_records_company_idTocompanies", fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people_account_records_customer_idTopeople people? @relation("account_records_customer_idTopeople", fields: [customer_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_living_space build_living_space? @relation(fields: [living_space_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown_account_records_payment_result_typeToapi_enum_dropdown api_enum_dropdown? @relation("account_records_payment_result_typeToapi_enum_dropdown", fields: [payment_result_type], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown_account_records_receive_debitToapi_enum_dropdown api_enum_dropdown? @relation("account_records_receive_debitToapi_enum_dropdown", fields: [receive_debit], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies_account_records_send_company_idTocompanies companies? @relation("account_records_send_company_idTocompanies", fields: [send_company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people_account_records_send_person_idTopeople people? @relation("account_records_send_person_idTopeople", fields: [send_person_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + account_records_model_train account_records_model_train[] + account_records_predict account_records_predict[] + build_decision_book_payments build_decision_book_payments[] + + @@unique([iban, bank_date, bank_reference_code, bank_balance], map: "_budget_records_ndx_01") + @@index([is_receipt_mail_send, bank_date], map: "_budget_records_ndx_00") + @@index([status_id, bank_date], map: "_budget_records_ndx_02") + @@index([created_at], map: "ix_account_records_created_at") + @@index([cryp_uu_id], map: "ix_account_records_cryp_uu_id") + @@index([ref_id], map: "ix_account_records_ref_id") + @@index([ref_int], map: "ix_account_records_ref_int") + @@index([updated_at], map: "ix_account_records_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model account_records_model_train { + start_index Int + end_index Int + search_text String @db.VarChar + category_id Int + category_uu_id String @db.VarChar(100) + account_records_id Int + account_records_uu_id String @db.VarChar(100) + ref_int Int? + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_account_records_model_train_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + is_model_trained Boolean @default(false) + trained_at DateTime? @db.Timestamptz(6) + account_records account_records @relation(fields: [account_records_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown api_enum_dropdown @relation(fields: [category_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_account_records_model_train_created_at") + @@index([cryp_uu_id], map: "ix_account_records_model_train_cryp_uu_id") + @@index([ref_id], map: "ix_account_records_model_train_ref_id") + @@index([ref_int], map: "ix_account_records_model_train_ref_int") + @@index([updated_at], map: "ix_account_records_model_train_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model account_records_predict { + account_records_id Int + account_records_uu_id String @db.VarChar(100) + prediction_result String + treshold Decimal? @db.Decimal(18, 6) + is_first_prediction Boolean @default(false) + is_approved Boolean @default(false) + approved_at DateTime? @db.Timestamptz(6) + ref_int Int? + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_account_records_predict_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + prediction_model String @db.VarChar + prediction_field String @default("") @db.VarChar + account_records account_records @relation(fields: [account_records_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_account_records_predict_created_at") + @@index([cryp_uu_id], map: "ix_account_records_predict_cryp_uu_id") + @@index([ref_id], map: "ix_account_records_predict_ref_id") + @@index([ref_int], map: "ix_account_records_predict_ref_int") + @@index([updated_at], map: "ix_account_records_predict_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model address_city { + city_code String @db.VarChar(24) + city_name String @db.VarChar + licence_plate String? @db.VarChar(24) + phone_code String? @db.VarChar(36) + gov_code String? @db.VarChar(128) + address_geographic_id BigInt? + state_id Int + state_uu_id String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_address_city_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + address_state address_state @relation(fields: [state_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + address_district address_district[] + + @@unique([state_id, city_code], map: "_address_city_ndx_01") + @@index([created_at], map: "ix_address_city_created_at") + @@index([cryp_uu_id], map: "ix_address_city_cryp_uu_id") + @@index([ref_id], map: "ix_address_city_ref_id") + @@index([ref_int], map: "ix_address_city_ref_int") + @@index([updated_at], map: "ix_address_city_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model address_country { + country_code String @unique(map: "_address_country_ndx_01") @db.VarChar(16) + country_name String @db.VarChar + money_code String? @db.VarChar(12) + language String? @db.VarChar + address_geographic_id BigInt? + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_address_country_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + address_state address_state[] + + @@index([money_code], map: "_address_country_ndx_00") + @@index([created_at], map: "ix_address_country_created_at") + @@index([cryp_uu_id], map: "ix_address_country_cryp_uu_id") + @@index([ref_id], map: "ix_address_country_ref_id") + @@index([ref_int], map: "ix_address_country_ref_int") + @@index([updated_at], map: "ix_address_country_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model address_district { + district_code String @db.VarChar(16) + district_name String @db.VarChar + phone_code String? @db.VarChar(36) + gov_code String? @db.VarChar(128) + address_geographic_id BigInt? + city_id Int + city_uu_id String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_address_district_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + address_city address_city @relation(fields: [city_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + address_locality address_locality[] + address_neighborhood address_neighborhood[] + + @@unique([city_id, district_code], map: "_address_district_ndx_01") + @@index([created_at], map: "ix_address_district_created_at") + @@index([cryp_uu_id], map: "ix_address_district_cryp_uu_id") + @@index([ref_id], map: "ix_address_district_ref_id") + @@index([ref_int], map: "ix_address_district_ref_int") + @@index([updated_at], map: "ix_address_district_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model address_geographic_locations { + geo_table String @db.VarChar + geo_id Int + geo_name String @db.VarChar + geo_latitude Decimal @default(0) @db.Decimal(20, 6) + geo_longitude Decimal @default(0) @db.Decimal(20, 6) + geo_altitude Decimal @default(0) @db.Decimal(20, 6) + geo_description String + geo_area_size Decimal? @default(0) @db.Decimal(20, 2) + geo_population BigInt? + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_address_geographic_locations_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + + @@index([geo_table, geo_id], map: "_address_geographic_locations_ndx_00") + @@index([geo_latitude, geo_longitude], map: "_address_geographic_locations_ndx_01") + @@index([created_at], map: "ix_address_geographic_locations_created_at") + @@index([cryp_uu_id], map: "ix_address_geographic_locations_cryp_uu_id") + @@index([ref_id], map: "ix_address_geographic_locations_ref_id") + @@index([ref_int], map: "ix_address_geographic_locations_ref_int") + @@index([updated_at], map: "ix_address_geographic_locations_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model address_locality { + locality_code String @db.VarChar(16) + locality_name String @db.VarChar + type_code String? @db.VarChar + type_description String? @db.VarChar + gov_code String? @db.VarChar(128) + address_show Boolean @default(true) + address_geographic_id BigInt? + district_id Int + district_uu_id String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_address_locality_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + address_district address_district @relation(fields: [district_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + address_neighborhood address_neighborhood[] + + @@unique([district_id, locality_code], map: "_address_locality_ndx_01") + @@index([created_at], map: "ix_address_locality_created_at") + @@index([cryp_uu_id], map: "ix_address_locality_cryp_uu_id") + @@index([ref_id], map: "ix_address_locality_ref_id") + @@index([ref_int], map: "ix_address_locality_ref_int") + @@index([updated_at], map: "ix_address_locality_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model address_neighborhood { + neighborhood_code String @db.VarChar(16) + neighborhood_name String @db.VarChar + type_code String? @db.VarChar + type_description String? @db.VarChar + gov_code String? @db.VarChar(128) + address_show Boolean @default(true) + address_geographic_id BigInt? + district_id Int? + district_uu_id String @default("") @db.VarChar + locality_id Int? + locality_uu_id String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_address_neighborhood_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + address_district address_district? @relation(fields: [district_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + address_locality address_locality? @relation(fields: [locality_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + address_street address_street[] + + @@unique([locality_id, neighborhood_code], map: "_address_neighborhood_ndx_01") + @@index([created_at], map: "ix_address_neighborhood_created_at") + @@index([cryp_uu_id], map: "ix_address_neighborhood_cryp_uu_id") + @@index([ref_id], map: "ix_address_neighborhood_ref_id") + @@index([ref_int], map: "ix_address_neighborhood_ref_int") + @@index([updated_at], map: "ix_address_neighborhood_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model address_postcode { + street_id Int + street_uu_id String @default("") @db.VarChar + postcode String @db.VarChar(32) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_address_postcode_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + address_street address_street @relation(fields: [street_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + relationship_employee2postcode relationship_employee2postcode[] + + @@index([created_at], map: "ix_address_postcode_created_at") + @@index([cryp_uu_id], map: "ix_address_postcode_cryp_uu_id") + @@index([ref_id], map: "ix_address_postcode_ref_id") + @@index([ref_int], map: "ix_address_postcode_ref_int") + @@index([updated_at], map: "ix_address_postcode_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model address_state { + state_code String @db.VarChar(16) + state_name String @db.VarChar + licence_plate String? @db.VarChar(24) + phone_code String? @db.VarChar(36) + gov_code String? @db.VarChar(128) + address_geographic_id BigInt? + country_id Int + country_uu_id String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_address_state_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + address_city address_city[] + address_country address_country @relation(fields: [country_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([country_id, state_code], map: "_address_state_ndx_01") + @@index([created_at], map: "ix_address_state_created_at") + @@index([cryp_uu_id], map: "ix_address_state_cryp_uu_id") + @@index([ref_id], map: "ix_address_state_ref_id") + @@index([ref_int], map: "ix_address_state_ref_int") + @@index([updated_at], map: "ix_address_state_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model address_street { + street_code String @db.VarChar(16) + street_name String @db.VarChar + type_code String? @db.VarChar + type_description String? @db.VarChar + gov_code String? @db.VarChar(128) + address_geographic_id BigInt? + neighborhood_id Int + neighborhood_uu_id String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_address_street_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + address_postcode address_postcode[] + address_neighborhood address_neighborhood @relation(fields: [neighborhood_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + addresses addresses[] + + @@unique([neighborhood_id, street_code], map: "_address_street_ndx_01") + @@index([created_at], map: "ix_address_street_created_at") + @@index([cryp_uu_id], map: "ix_address_street_cryp_uu_id") + @@index([ref_id], map: "ix_address_street_ref_id") + @@index([ref_int], map: "ix_address_street_ref_int") + @@index([updated_at], map: "ix_address_street_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model addresses { + build_number String @db.VarChar(24) + door_number String? @db.VarChar(24) + floor_number String? @db.VarChar(24) + comment_address String @db.VarChar + letter_address String @db.VarChar + short_letter_address String @db.VarChar + latitude Decimal @default(0) @db.Decimal(20, 12) + longitude Decimal @default(0) @db.Decimal(20, 12) + street_id Int + street_uu_id String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_addresses_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + address_street address_street @relation(fields: [street_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build build[] + build_sites build_sites[] + companies companies[] + + @@index([created_at], map: "ix_addresses_created_at") + @@index([cryp_uu_id], map: "ix_addresses_cryp_uu_id") + @@index([ref_id], map: "ix_addresses_ref_id") + @@index([ref_int], map: "ix_addresses_ref_int") + @@index([updated_at], map: "ix_addresses_updated_at") +} + +model alembic_version { + version_num String @id(map: "alembic_version_pkc") @db.VarChar(32) +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model api_enum_dropdown { + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_api_enum_dropdown_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + enum_class String @db.VarChar + key String @db.VarChar + value String @db.VarChar + description String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + lang String @default("tr") @db.VarChar + account_detail account_detail[] + account_records_account_records_budget_typeToapi_enum_dropdown account_records[] @relation("account_records_budget_typeToapi_enum_dropdown") + account_records_account_records_payment_result_typeToapi_enum_dropdown account_records[] @relation("account_records_payment_result_typeToapi_enum_dropdown") + account_records_account_records_receive_debitToapi_enum_dropdown account_records[] @relation("account_records_receive_debitToapi_enum_dropdown") + account_records_model_train account_records_model_train[] + build build[] + build_area build_area[] + build_companies_providing build_companies_providing[] + build_decision_book_items build_decision_book_items[] + build_decision_book_payments build_decision_book_payments[] + build_parts_build_parts_part_direction_idToapi_enum_dropdown build_parts[] @relation("build_parts_part_direction_idToapi_enum_dropdown") + build_parts_build_parts_part_type_idToapi_enum_dropdown build_parts[] @relation("build_parts_part_type_idToapi_enum_dropdown") + build_person_providing build_person_providing[] + decision_book_budget_master decision_book_budget_master[] + + @@index([created_at], map: "ix_api_enum_dropdown_created_at") + @@index([cryp_uu_id], map: "ix_api_enum_dropdown_cryp_uu_id") + @@index([ref_id], map: "ix_api_enum_dropdown_ref_id") + @@index([ref_int], map: "ix_api_enum_dropdown_ref_int") + @@index([updated_at], map: "ix_api_enum_dropdown_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model application2employee { + employee_id Int + employee_uu_id String @db.VarChar + service_id Int + service_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_application2employee_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + employees employees @relation(fields: [employee_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + services services @relation(fields: [service_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([employee_uu_id, service_uu_id], map: "application2employee_employee_to_service") + @@index([created_at], map: "ix_application2employee_created_at") + @@index([cryp_uu_id], map: "ix_application2employee_cryp_uu_id") + @@index([ref_id], map: "ix_application2employee_ref_id") + @@index([ref_int], map: "ix_application2employee_ref_int") + @@index([updated_at], map: "ix_application2employee_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model application2employee_extra { + employee_id Int + employee_uu_id String @db.VarChar + application_id Int + application_uu_id String @db.VarChar + site_url String @db.VarChar + application_code String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_application2employee_extra_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + applications applications @relation(fields: [application_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + employees employees @relation(fields: [employee_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([employee_id, site_url, application_id], map: "application_to_employee") + @@index([created_at], map: "ix_application2employee_extra_created_at") + @@index([cryp_uu_id], map: "ix_application2employee_extra_cryp_uu_id") + @@index([ref_id], map: "ix_application2employee_extra_ref_id") + @@index([ref_int], map: "ix_application2employee_extra_ref_int") + @@index([updated_at], map: "ix_application2employee_extra_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model application2occupant { + build_living_space_id Int + build_living_space_uu_id String @db.VarChar + service_id Int + service_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_application2occupant_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_living_space build_living_space @relation(fields: [build_living_space_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + services services @relation(fields: [service_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([build_living_space_uu_id, service_uu_id], map: "application2occupant_occupant_to_service") + @@index([created_at], map: "ix_application2occupant_created_at") + @@index([cryp_uu_id], map: "ix_application2occupant_cryp_uu_id") + @@index([ref_id], map: "ix_application2occupant_ref_id") + @@index([ref_int], map: "ix_application2occupant_ref_int") + @@index([updated_at], map: "ix_application2occupant_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model application2occupant_extra { + build_living_space_id Int + build_living_space_uu_id String @db.VarChar + application_id Int + application_uu_id String @db.VarChar + site_url String @db.VarChar + application_code String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_application2occupant_extra_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + applications applications @relation(fields: [application_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_living_space build_living_space @relation(fields: [build_living_space_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([build_living_space_id, site_url, application_id], map: "application_to_occupant") + @@index([created_at], map: "ix_application2occupant_extra_created_at") + @@index([cryp_uu_id], map: "ix_application2occupant_extra_cryp_uu_id") + @@index([ref_id], map: "ix_application2occupant_extra_ref_id") + @@index([ref_int], map: "ix_application2occupant_extra_ref_int") + @@index([updated_at], map: "ix_application2occupant_extra_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model applications { + name String @db.VarChar + site_url String @db.VarChar + application_code String @db.VarChar + application_type String @db.VarChar + application_for String @default("EMP") @db.VarChar + description String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_applications_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + application2employee_extra application2employee_extra[] + application2occupant_extra application2occupant_extra[] + services2applications services2applications[] + + @@index([created_at], map: "ix_applications_created_at") + @@index([cryp_uu_id], map: "ix_applications_cryp_uu_id") + @@index([ref_id], map: "ix_applications_ref_id") + @@index([ref_int], map: "ix_applications_ref_int") + @@index([updated_at], map: "ix_applications_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build { + gov_address_code String @unique @default("") @db.VarChar + build_name String @db.VarChar + build_no String @db.VarChar(8) + max_floor Int @default(1) + underground_floor Int @default(0) + build_date DateTime @default(dbgenerated("'1900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + decision_period_date DateTime @default(dbgenerated("'1900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + tax_no String @default("") @db.VarChar(24) + lift_count Int @default(0) + heating_system Boolean @default(true) + cooling_system Boolean @default(false) + hot_water_system Boolean @default(false) + block_service_man_count Int @default(0) + security_service_man_count Int @default(0) + garage_count Int @default(0) + management_room_id Int? + site_id Int? + site_uu_id String? @db.VarChar + address_id Int + address_uu_id String @db.VarChar + build_types_id Int + build_types_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_records account_records[] + addresses addresses @relation(fields: [address_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown api_enum_dropdown @relation(fields: [build_types_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_sites build_sites? @relation(fields: [site_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_area build_area[] + build_companies_providing build_companies_providing[] + build_decision_book build_decision_book[] + build_ibans build_ibans[] + build_management build_management[] + build_parts build_parts[] + build_person_providing build_person_providing[] + company_delay_interest company_delay_interest[] + relationship_employee2build relationship_employee2build[] + + @@index([gov_address_code], map: "_builds_ndx_00") + @@index([build_name, build_no], map: "_builds_ndx_01") + @@index([created_at], map: "ix_build_created_at") + @@index([cryp_uu_id], map: "ix_build_cryp_uu_id") + @@index([ref_id], map: "ix_build_ref_id") + @@index([ref_int], map: "ix_build_ref_int") + @@index([updated_at], map: "ix_build_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_area { + area_name String @default("") @db.VarChar + area_code String @default("") @db.VarChar + area_type String @default("GREEN") @db.VarChar + area_direction String @default("NN") @db.VarChar(2) + area_gross_size Decimal @default(0) @db.Decimal(20, 6) + area_net_size Decimal @default(0) @db.Decimal(20, 6) + width Int? @default(0) + size Int? @default(0) + build_id Int + build_uu_id String @db.VarChar + part_type_id Int? + part_type_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_area_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build build @relation(fields: [build_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown api_enum_dropdown? @relation(fields: [part_type_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([build_id, area_code], map: "_edm_build_parts_area_ndx_00") + @@index([created_at], map: "ix_build_area_created_at") + @@index([cryp_uu_id], map: "ix_build_area_cryp_uu_id") + @@index([ref_id], map: "ix_build_area_ref_id") + @@index([ref_int], map: "ix_build_area_ref_int") + @@index([updated_at], map: "ix_build_area_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_companies_providing { + build_id Int + build_uu_id String? @db.VarChar + company_id Int + company_uu_id String? @db.VarChar + provide_id Int? + provide_uu_id String? @db.VarChar + contract_id Int? + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_companies_providing_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build build @relation(fields: [build_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies_build_companies_providing_company_idTocompanies companies @relation("build_companies_providing_company_idTocompanies", fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies_build_companies_providing_contract_idTocompanies companies? @relation("build_companies_providing_contract_idTocompanies", fields: [contract_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown api_enum_dropdown? @relation(fields: [provide_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([build_id, company_id, provide_id], map: "_build_companies_providing_ndx_00") + @@index([created_at], map: "ix_build_companies_providing_created_at") + @@index([cryp_uu_id], map: "ix_build_companies_providing_cryp_uu_id") + @@index([ref_id], map: "ix_build_companies_providing_ref_id") + @@index([ref_int], map: "ix_build_companies_providing_ref_int") + @@index([updated_at], map: "ix_build_companies_providing_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book { + decision_book_pdf_path String? @default("") @db.VarChar + resp_company_fix_wage Decimal @default(0) @db.Decimal(10, 2) + is_out_sourced Boolean @default(false) + meeting_date DateTime @default(dbgenerated("'1900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + decision_type String @default("RBM") @db.VarChar(3) + meeting_is_completed Boolean @default(false) + meeting_completed_date DateTime? @db.Timestamptz(6) + build_id Int + build_uu_id String? @db.VarChar + resp_company_id Int + resp_company_uu_id String? @db.VarChar + contact_id Int? + contact_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_records account_records[] + build build @relation(fields: [build_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + contracts contracts? @relation(fields: [contact_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies companies @relation(fields: [resp_company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_invitations build_decision_book_invitations[] + build_decision_book_items build_decision_book_items[] + build_decision_book_payments build_decision_book_payments[] + build_decision_book_person build_decision_book_person[] + build_decision_book_projects build_decision_book_projects[] + decision_book_budget_books decision_book_budget_books[] + decision_book_budget_codes decision_book_budget_codes[] + + @@index([meeting_date, build_id], map: "build_decision_book_ndx_011") + @@index([created_at], map: "ix_build_decision_book_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_cryp_uu_id") + @@index([ref_id], map: "ix_build_decision_book_ref_id") + @@index([ref_int], map: "ix_build_decision_book_ref_int") + @@index([updated_at], map: "ix_build_decision_book_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book_invitations { + build_id Int + build_uu_id String? @db.VarChar + decision_book_id Int + decision_book_uu_id String? @db.VarChar + invitation_type String @db.VarChar + invitation_attempt Int @default(1) @db.SmallInt + living_part_count Int @default(1) @db.SmallInt + living_part_percentage Decimal @default(0.51) @db.Decimal(10, 2) + message String? + planned_date DateTime @db.Timestamptz(6) + planned_date_expires DateTime @db.Timestamptz(6) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_invitations_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book build_decision_book @relation(fields: [decision_book_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_person build_decision_book_person[] + build_decision_book_person_occupants build_decision_book_person_occupants[] + + @@unique([invitation_type, planned_date, invitation_attempt], map: "_build_decision_book_invitations_ndx_01") + @@index([created_at], map: "ix_build_decision_book_invitations_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_invitations_cryp_uu_id") + @@index([ref_id], map: "ix_build_decision_book_invitations_ref_id") + @@index([ref_int], map: "ix_build_decision_book_invitations_ref_int") + @@index([updated_at], map: "ix_build_decision_book_invitations_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book_items { + item_order Int @db.SmallInt + item_comment String + item_objection String? + info_is_completed Boolean @default(false) + is_payment_created Boolean @default(false) + info_type_id Int? + info_type_uu_id String? @db.VarChar + build_decision_book_id Int + build_decision_book_uu_id String? @db.VarChar + item_short_comment String? @db.VarChar(24) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_items_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book build_decision_book @relation(fields: [build_decision_book_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown api_enum_dropdown? @relation(fields: [info_type_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_items_unapproved_build_decision_book_items_unapproved_build_decision_book_itemTobuild_decision_book_items build_decision_book_items_unapproved[] @relation("build_decision_book_items_unapproved_build_decision_book_itemTobuild_decision_book_items") + build_decision_book_items_unapproved_build_decision_book_items_unapproved_decision_book_item_idTobuild_decision_book_items build_decision_book_items_unapproved[] @relation("build_decision_book_items_unapproved_decision_book_item_idTobuild_decision_book_items") + build_decision_book_legal build_decision_book_legal[] + build_decision_book_payments build_decision_book_payments[] + build_decision_book_projects build_decision_book_projects[] + + @@unique([build_decision_book_id, item_order], map: "_build_decision_book_item_ndx_02") + @@index([build_decision_book_id], map: "_build_decision_book_item_ndx_01") + @@index([created_at], map: "ix_build_decision_book_items_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_items_cryp_uu_id") + @@index([ref_id], map: "ix_build_decision_book_items_ref_id") + @@index([ref_int], map: "ix_build_decision_book_items_ref_int") + @@index([updated_at], map: "ix_build_decision_book_items_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book_items_unapproved { + item_objection String + item_order Int @db.SmallInt + decision_book_item_id Int + decision_book_item_uu_id String? @db.VarChar + person_id Int + person_uu_id String? @db.VarChar + build_decision_book_item Int + build_decision_book_item_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_items_unapproved_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book_items_build_decision_book_items_unapproved_build_decision_book_itemTobuild_decision_book_items build_decision_book_items @relation("build_decision_book_items_unapproved_build_decision_book_itemTobuild_decision_book_items", fields: [build_decision_book_item], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "build_decision_book_items_unappro_build_decision_book_item_fkey") + build_decision_book_items_build_decision_book_items_unapproved_decision_book_item_idTobuild_decision_book_items build_decision_book_items @relation("build_decision_book_items_unapproved_decision_book_item_idTobuild_decision_book_items", fields: [decision_book_item_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people people @relation(fields: [person_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([build_decision_book_item], map: "_build_decision_book_item_unapproved_ndx_01") + @@index([created_at], map: "ix_build_decision_book_items_unapproved_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_items_unapproved_cryp_uu_id") + @@index([ref_id], map: "ix_build_decision_book_items_unapproved_ref_id") + @@index([ref_int], map: "ix_build_decision_book_items_unapproved_ref_int") + @@index([updated_at], map: "ix_build_decision_book_items_unapproved_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book_legal { + period_start_date DateTime @db.Timestamptz(6) + lawsuits_decision_number String @db.VarChar + lawsuits_decision_date DateTime @db.Timestamptz(6) + period_stop_date DateTime @default(dbgenerated("'2099-12-31 23:59:59+00'::timestamp with time zone")) @db.Timestamptz(6) + decision_book_pdf_path String? @default("") @db.VarChar + resp_company_total_wage Decimal? @default(0) @db.Decimal(10, 2) + contact_agreement_path String? @default("") @db.VarChar + contact_agreement_date DateTime? @default(dbgenerated("'1900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + meeting_date DateTime @default(dbgenerated("'1900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + lawsuits_type String @default("C") @db.VarChar(1) + lawsuits_name String @db.VarChar(128) + lawsuits_note String @db.VarChar(512) + lawyer_cost Decimal @db.Decimal(20, 2) + mediator_lawyer_cost Decimal @db.Decimal(20, 2) + other_cost Decimal @db.Decimal(20, 2) + legal_cost Decimal @db.Decimal(20, 2) + approved_cost Decimal @db.Decimal(20, 2) + total_price Decimal @db.Decimal(20, 2) + build_db_item_id Int + build_db_item_uu_id String? @db.VarChar + resp_attorney_id Int + resp_attorney_uu_id String? @db.VarChar + resp_attorney_company_id Int + resp_attorney_company_uu_id String? @db.VarChar + mediator_lawyer_person_id Int + mediator_lawyer_person_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_legal_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book_items build_decision_book_items @relation(fields: [build_db_item_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people_build_decision_book_legal_mediator_lawyer_person_idTopeople people @relation("build_decision_book_legal_mediator_lawyer_person_idTopeople", fields: [mediator_lawyer_person_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies companies @relation(fields: [resp_attorney_company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people_build_decision_book_legal_resp_attorney_idTopeople people @relation("build_decision_book_legal_resp_attorney_idTopeople", fields: [resp_attorney_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([meeting_date], map: "_build_decision_book_legal_ndx_00") + @@index([created_at], map: "ix_build_decision_book_legal_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_legal_cryp_uu_id") + @@index([ref_id], map: "ix_build_decision_book_legal_ref_id") + @@index([ref_int], map: "ix_build_decision_book_legal_ref_int") + @@index([updated_at], map: "ix_build_decision_book_legal_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book_payments { + payment_plan_time_periods String @db.VarChar(10) + process_date DateTime @db.Timestamptz(6) + payment_amount Decimal @db.Decimal(16, 2) + currency String @default("TRY") @db.VarChar(8) + payment_types_id Int? + payment_types_uu_id String? @db.VarChar + period_time String @db.VarChar(12) + process_date_y Int @db.SmallInt + process_date_m Int @db.SmallInt + build_decision_book_item_id Int + build_decision_book_item_uu_id String @db.VarChar + build_parts_id Int + build_parts_uu_id String @db.VarChar + decision_book_project_id Int? + decision_book_project_uu_id String? @db.VarChar + account_records_id Int? + account_records_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_payments_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + account_is_debit Boolean? @default(true) + build_decision_book_id Int? + build_decision_book_uu_id String? @db.VarChar + ref_int Int? + is_closed Boolean @default(false) + debt_to_pay Decimal @default(0) @db.Decimal(16, 2) + debt_paid Decimal @default(0) @db.Decimal(16, 2) + account_delay_interest account_delay_interest[] + account_records account_records? @relation(fields: [account_records_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book build_decision_book? @relation(fields: [build_decision_book_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_items build_decision_book_items @relation(fields: [build_decision_book_item_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_parts build_parts @relation(fields: [build_parts_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_projects build_decision_book_projects? @relation(fields: [decision_book_project_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown api_enum_dropdown? @relation(fields: [payment_types_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([uu_id, ref_id, build_decision_book_item_id, build_parts_id, payment_plan_time_periods, process_date, payment_types_id, account_records_id, account_is_debit], map: "build_decision_book_payments_detail_ndx_00") + @@index([account_records_id], map: "build_decision_book_payments_detail_ndx_01") + @@index([created_at], map: "ix_build_decision_book_payments_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_payments_cryp_uu_id") + @@index([ref_id], map: "ix_build_decision_book_payments_ref_id") + @@index([ref_int], map: "ix_build_decision_book_payments_ref_int") + @@index([updated_at], map: "ix_build_decision_book_payments_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book_person { + dues_percent_discount Int @default(0) @db.SmallInt + dues_fix_discount Decimal @default(0) @db.Decimal(10, 2) + dues_discount_approval_date DateTime @default(dbgenerated("'1900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + send_date DateTime @db.Timestamptz(6) + is_attending Boolean @default(false) + confirmed_date DateTime? @db.Timestamptz(6) + token String @default("") @db.VarChar + vicarious_person_id Int? + vicarious_person_uu_id String? @db.VarChar + invite_id Int + invite_uu_id String @db.VarChar + build_decision_book_id Int + build_decision_book_uu_id String @db.VarChar + build_living_space_id Int + build_living_space_uu_id String? @db.VarChar + person_id Int + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_person_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book build_decision_book @relation(fields: [build_decision_book_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_living_space build_living_space @relation(fields: [build_living_space_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_invitations build_decision_book_invitations @relation(fields: [invite_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people_build_decision_book_person_person_idTopeople people @relation("build_decision_book_person_person_idTopeople", fields: [person_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people_build_decision_book_person_vicarious_person_idTopeople people? @relation("build_decision_book_person_vicarious_person_idTopeople", fields: [vicarious_person_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_person_occupants build_decision_book_person_occupants[] + + @@unique([build_decision_book_id, invite_id, build_living_space_id], map: "_build_decision_book_person_ndx_01") + @@index([created_at], map: "ix_build_decision_book_person_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_person_cryp_uu_id") + @@index([ref_id], map: "ix_build_decision_book_person_ref_id") + @@index([ref_int], map: "ix_build_decision_book_person_ref_int") + @@index([updated_at], map: "ix_build_decision_book_person_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book_person_occupants { + build_decision_book_person_id Int + build_decision_book_person_uu_id String? @db.VarChar + invite_id Int? + invite_uu_id String? @db.VarChar + occupant_type_id Int + occupant_type_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_person_occupants_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book_person build_decision_book_person @relation(fields: [build_decision_book_person_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "build_decision_book_person_oc_build_decision_book_person_i_fkey") + build_decision_book_invitations build_decision_book_invitations? @relation(fields: [invite_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + occupant_types occupant_types @relation(fields: [occupant_type_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([build_decision_book_person_id, occupant_type_id], map: "_build_decision_book_person_occupants_ndx_01") + @@index([created_at], map: "ix_build_decision_book_person_occupants_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_person_occupants_cryp_uu_id") + @@index([ref_id], map: "ix_build_decision_book_person_occupants_ref_id") + @@index([ref_int], map: "ix_build_decision_book_person_occupants_ref_int") + @@index([updated_at], map: "ix_build_decision_book_person_occupants_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book_project_items { + item_header String @db.VarChar + item_comment String + attachment_pdf_path String? @default("") @db.VarChar + item_estimated_cost Decimal @default(0) @db.Decimal(16, 2) + item_short_comment String? @db.VarChar(24) + build_decision_book_project_id Int + build_decision_book_project_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_project_items_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book_projects build_decision_book_projects @relation(fields: [build_decision_book_project_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "build_decision_book_project_i_build_decision_book_project__fkey") + + @@index([created_at], map: "ix_build_decision_book_project_items_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_project_items_cryp_uu_id") + @@index([ref_id], map: "ix_build_decision_book_project_items_ref_id") + @@index([ref_int], map: "ix_build_decision_book_project_items_ref_int") + @@index([updated_at], map: "ix_build_decision_book_project_items_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book_project_person { + dues_percent_discount Int @default(0) @db.SmallInt + job_fix_wage Decimal @default(0) @db.Decimal(10, 2) + bid_price Decimal @default(0) @db.Decimal(10, 2) + decision_price Decimal @default(0) @db.Decimal(10, 2) + build_decision_book_project_id Int + build_decision_book_project_uu_id String? @db.VarChar + living_space_id Int + living_space_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_project_person_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book_projects build_decision_book_projects @relation(fields: [build_decision_book_project_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "build_decision_book_project_p_build_decision_book_project__fkey") + build_living_space build_living_space @relation(fields: [living_space_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_build_decision_book_project_person_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_project_person_cryp_uu_id") + @@index([ref_id], map: "ix_build_decision_book_project_person_ref_id") + @@index([ref_int], map: "ix_build_decision_book_project_person_ref_int") + @@index([updated_at], map: "ix_build_decision_book_project_person_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_decision_book_projects { + project_no String? @db.VarChar(12) + project_name String @db.VarChar + project_start_date DateTime @db.Timestamptz(6) + project_stop_date DateTime @default(dbgenerated("'2099-12-31 23:59:59+00'::timestamp with time zone")) @db.Timestamptz(6) + project_type String @default("C") @db.VarChar + project_note String + decision_book_pdf_path String? @default("") @db.VarChar + is_completed Boolean @default(false) + status_code Int? @db.SmallInt + resp_company_fix_wage Decimal @default(0) @db.Decimal(10, 2) + is_out_sourced Boolean @default(false) + meeting_date DateTime @default(dbgenerated("'1900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + currency String @default("TRY") @db.VarChar(8) + bid_price Decimal @default(0) @db.Decimal(16, 4) + approved_price Decimal @default(0) @db.Decimal(16, 4) + final_price Decimal @default(0) @db.Decimal(16, 4) + contact_id Int? + contact_uu_id String? @db.VarChar + build_decision_book_id Int + build_decision_book_uu_id String? @db.VarChar + build_decision_book_item_id Int + build_decision_book_item_uu_id String? @db.VarChar + project_response_living_space_id Int? + project_response_living_space_uu_id String? @db.VarChar + resp_company_id Int? + resp_company_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_decision_book_projects_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_detail account_detail[] + account_master account_master[] + build_decision_book_payments build_decision_book_payments[] + build_decision_book_project_items build_decision_book_project_items[] + build_decision_book_project_person build_decision_book_project_person[] + build_decision_book build_decision_book @relation(fields: [build_decision_book_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book_items build_decision_book_items @relation(fields: [build_decision_book_item_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + contracts contracts? @relation(fields: [contact_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_living_space build_living_space? @relation(fields: [project_response_living_space_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies companies? @relation(fields: [resp_company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([project_no, project_start_date], map: "_build_decision_book_project_ndx_00") + @@index([created_at], map: "ix_build_decision_book_projects_created_at") + @@index([cryp_uu_id], map: "ix_build_decision_book_projects_cryp_uu_id") + @@index([meeting_date], map: "ix_build_decision_book_projects_meeting_date") + @@index([ref_id], map: "ix_build_decision_book_projects_ref_id") + @@index([ref_int], map: "ix_build_decision_book_projects_ref_int") + @@index([updated_at], map: "ix_build_decision_book_projects_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_iban_description { + iban String @db.VarChar + group_id Int @db.SmallInt + search_word String @db.VarChar + customer_id Int? + customer_uu_id String? @db.VarChar + company_id Int? + company_uu_id String? @db.VarChar + build_parts_id Int? + build_parts_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_iban_description_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_parts build_parts? @relation(fields: [build_parts_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies companies? @relation(fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people people? @relation(fields: [customer_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([iban, search_word, group_id], map: "_search_iban_description_ndx_00") + @@index([created_at], map: "ix_build_iban_description_created_at") + @@index([cryp_uu_id], map: "ix_build_iban_description_cryp_uu_id") + @@index([ref_id], map: "ix_build_iban_description_ref_id") + @@index([ref_int], map: "ix_build_iban_description_ref_int") + @@index([search_word], map: "ix_build_iban_description_search_word") + @@index([updated_at], map: "ix_build_iban_description_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_ibans { + iban String @default("") @db.VarChar(40) + start_date DateTime @db.Timestamptz(6) + stop_date DateTime @default(dbgenerated("'2900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + bank_code String @default("TR0000000000000") @db.VarChar(24) + xcomment String @default("????") @db.VarChar(64) + build_id Int? + build_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_ibans_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build build? @relation(fields: [build_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([iban, start_date], map: "_build_ibans_ndx_01") + @@index([build_uu_id], map: "ix_build_ibans_build_uu_id") + @@index([created_at], map: "ix_build_ibans_created_at") + @@index([cryp_uu_id], map: "ix_build_ibans_cryp_uu_id") + @@index([ref_id], map: "ix_build_ibans_ref_id") + @@index([ref_int], map: "ix_build_ibans_ref_int") + @@index([updated_at], map: "ix_build_ibans_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_living_space { + fix_value Decimal @default(0) @db.Decimal(20, 6) + fix_percent Decimal @default(0) @db.Decimal(6, 2) + agreement_no String @default("") @db.VarChar + marketing_process Boolean @default(false) + marketing_layer Int @default(0) + build_parts_id Int + build_parts_uu_id String @db.VarChar + person_id Int + person_uu_id String @db.VarChar + occupant_type_id Int + occupant_type_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_living_space_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_records account_records[] + application2occupant application2occupant[] + application2occupant_extra application2occupant_extra[] + build_decision_book_person build_decision_book_person[] + build_decision_book_project_person build_decision_book_project_person[] + build_decision_book_projects build_decision_book_projects[] + build_parts build_parts @relation(fields: [build_parts_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + occupant_types occupant_types @relation(fields: [occupant_type_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people people @relation(fields: [person_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + event2occupant event2occupant[] + event2occupant_extra event2occupant_extra[] + + @@index([build_parts_id], map: "ix_build_living_space_build_parts_id") + @@index([created_at], map: "ix_build_living_space_created_at") + @@index([cryp_uu_id], map: "ix_build_living_space_cryp_uu_id") + @@index([person_id], map: "ix_build_living_space_person_id") + @@index([ref_id], map: "ix_build_living_space_ref_id") + @@index([ref_int], map: "ix_build_living_space_ref_int") + @@index([updated_at], map: "ix_build_living_space_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_management { + discounted_percentage Decimal @default(0.00) @db.Decimal(6, 2) + discounted_price Decimal @default(0.00) @db.Decimal(20, 2) + calculated_price Decimal @default(0.00) @db.Decimal(20, 2) + occupant_type Int + occupant_type_uu_id String @db.VarChar + build_id Int + build_uu_id String @db.VarChar + build_parts_id Int + build_parts_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_management_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build build @relation(fields: [build_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_parts build_parts @relation(fields: [build_parts_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + occupant_types occupant_types @relation(fields: [occupant_type], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([build_parts_id, occupant_type, expiry_starts], map: "build_management_ndx_00") + @@index([build_parts_id], map: "ix_build_management_build_parts_id") + @@index([created_at], map: "ix_build_management_created_at") + @@index([cryp_uu_id], map: "ix_build_management_cryp_uu_id") + @@index([ref_id], map: "ix_build_management_ref_id") + @@index([ref_int], map: "ix_build_management_ref_int") + @@index([updated_at], map: "ix_build_management_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_parts { + address_gov_code String @db.VarChar + part_no Int @default(0) + part_level Int @default(0) + part_code String @default("") @db.VarChar + part_gross_size Int @default(0) + part_net_size Int @default(0) + default_accessory String @default("0") + human_livable Boolean @default(true) + due_part_key String @default("") @db.VarChar + build_id Int + build_uu_id String @db.VarChar + part_direction_id Int? + part_direction_uu_id String? @db.VarChar + part_type_id Int + part_type_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_parts_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_records account_records[] + build_decision_book_payments build_decision_book_payments[] + build_iban_description build_iban_description[] + build_living_space build_living_space[] + build_management build_management[] + build build @relation(fields: [build_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown_build_parts_part_direction_idToapi_enum_dropdown api_enum_dropdown? @relation("build_parts_part_direction_idToapi_enum_dropdown", fields: [part_direction_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown_build_parts_part_type_idToapi_enum_dropdown api_enum_dropdown @relation("build_parts_part_type_idToapi_enum_dropdown", fields: [part_type_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + decision_book_budget_codes decision_book_budget_codes[] + part2employee part2employee[] + + @@unique([build_id, part_no], map: "build_parts_ndx_1") + @@index([created_at], map: "ix_build_parts_created_at") + @@index([cryp_uu_id], map: "ix_build_parts_cryp_uu_id") + @@index([ref_id], map: "ix_build_parts_ref_id") + @@index([ref_int], map: "ix_build_parts_ref_int") + @@index([updated_at], map: "ix_build_parts_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_person_providing { + build_id Int + build_uu_id String? @db.VarChar + people_id Int + people_uu_id String? @db.VarChar + provide_id Int? + provide_uu_id String? @db.VarChar + contract_id Int? + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_person_providing_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build build @relation(fields: [build_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies companies? @relation(fields: [contract_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people people @relation(fields: [people_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown api_enum_dropdown? @relation(fields: [provide_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([build_id, people_id, provide_id], map: "_build_person_providing_ndx_00") + @@index([created_at], map: "ix_build_person_providing_created_at") + @@index([cryp_uu_id], map: "ix_build_person_providing_cryp_uu_id") + @@index([ref_id], map: "ix_build_person_providing_ref_id") + @@index([ref_int], map: "ix_build_person_providing_ref_int") + @@index([updated_at], map: "ix_build_person_providing_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_sites { + site_name String @db.VarChar(24) + site_no String @db.VarChar(8) + address_id Int + address_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_sites_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build build[] + addresses addresses @relation(fields: [address_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([site_no, site_name], map: "_sites_ndx_01") + @@index([created_at], map: "ix_build_sites_created_at") + @@index([cryp_uu_id], map: "ix_build_sites_cryp_uu_id") + @@index([ref_id], map: "ix_build_sites_ref_id") + @@index([ref_int], map: "ix_build_sites_ref_int") + @@index([updated_at], map: "ix_build_sites_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model build_types { + function_code String @default("") @db.VarChar(12) + type_code String @default("") @db.VarChar(12) + lang String @default("TR") @db.VarChar(4) + type_name String @default("") @db.VarChar(48) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_build_types_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + + @@unique([type_code, function_code, lang], map: "_build_types_ndx_00") + @@index([created_at], map: "ix_build_types_created_at") + @@index([cryp_uu_id], map: "ix_build_types_cryp_uu_id") + @@index([ref_id], map: "ix_build_types_ref_id") + @@index([ref_int], map: "ix_build_types_ref_int") + @@index([updated_at], map: "ix_build_types_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model companies { + formal_name String @db.VarChar + company_type String @db.VarChar + commercial_type String @db.VarChar + tax_no String @unique(map: "_company_ndx_01") @db.VarChar + public_name String @db.VarChar + company_tag String @db.VarChar + default_lang_type String @default("TR") @db.VarChar + default_money_type String @default("TL") @db.VarChar + is_commercial Boolean @default(false) + is_blacklist Boolean @default(false) + parent_id Int? + workplace_no String? @db.VarChar + official_address_id Int? + official_address_uu_id String? @db.VarChar + top_responsible_company_id Int? + top_responsible_company_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_companies_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_books_account_books_branch_idTocompanies account_books[] @relation("account_books_branch_idTocompanies") + account_books_account_books_company_idTocompanies account_books[] @relation("account_books_company_idTocompanies") + account_codes_account_codes_company_idTocompanies account_codes[] @relation("account_codes_company_idTocompanies") + account_codes_account_codes_customer_idTocompanies account_codes[] @relation("account_codes_customer_idTocompanies") + account_records_account_records_company_idTocompanies account_records[] @relation("account_records_company_idTocompanies") + account_records_account_records_send_company_idTocompanies account_records[] @relation("account_records_send_company_idTocompanies") + build_companies_providing_build_companies_providing_company_idTocompanies build_companies_providing[] @relation("build_companies_providing_company_idTocompanies") + build_companies_providing_build_companies_providing_contract_idTocompanies build_companies_providing[] @relation("build_companies_providing_contract_idTocompanies") + build_decision_book build_decision_book[] + build_decision_book_legal build_decision_book_legal[] + build_decision_book_projects build_decision_book_projects[] + build_iban_description build_iban_description[] + build_person_providing build_person_providing[] + addresses addresses? @relation(fields: [official_address_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies companies? @relation("companiesTocompanies", fields: [top_responsible_company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + other_companies companies[] @relation("companiesTocompanies") + company_delay_interest company_delay_interest[] + contracts contracts[] + decision_book_budget_books_decision_book_budget_books_branch_idTocompanies decision_book_budget_books[] @relation("decision_book_budget_books_branch_idTocompanies") + decision_book_budget_books_decision_book_budget_books_company_idTocompanies decision_book_budget_books[] @relation("decision_book_budget_books_company_idTocompanies") + decision_book_budget_codes decision_book_budget_codes[] + departments departments[] + relationship_duty_company_relationship_duty_company_member_idTocompanies relationship_duty_company[] @relation("relationship_duty_company_member_idTocompanies") + relationship_duty_company_relationship_duty_company_owner_idTocompanies relationship_duty_company[] @relation("relationship_duty_company_owner_idTocompanies") + relationship_duty_company_relationship_duty_company_parent_idTocompanies relationship_duty_company[] @relation("relationship_duty_company_parent_idTocompanies") + relationship_duty_people relationship_duty_people[] + relationship_employee2build relationship_employee2build[] + relationship_employee2postcode relationship_employee2postcode[] + + @@index([formal_name, public_name], map: "_company_ndx_02") + @@index([created_at], map: "ix_companies_created_at") + @@index([cryp_uu_id], map: "ix_companies_cryp_uu_id") + @@index([ref_id], map: "ix_companies_ref_id") + @@index([ref_int], map: "ix_companies_ref_int") + @@index([updated_at], map: "ix_companies_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model company_delay_interest { + company_id Int? + company_uu_id String? @db.VarChar + build_id Int? + build_uu_id String? @db.VarChar + daily_interest_type String? @db.VarChar(24) + daily_interest_rate Decimal @default(0) @db.Decimal(20, 6) + bsmv_rate Decimal @default(0) @db.Decimal(20, 6) + kkdf_rate Decimal @default(0) @db.Decimal(20, 6) + start_date DateTime @db.Timestamptz(6) + stop_date DateTime @default(dbgenerated("'2900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + ref_int Int? + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_company_delay_interest_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + build build? @relation(fields: [build_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies companies? @relation(fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([company_id, build_id, start_date], map: "_company_delay_interest_ndx_01") + @@index([company_id, build_id], map: "ix_company_delay_interest_build_uu_id") + @@index([created_at], map: "ix_company_delay_interest_created_at") + @@index([cryp_uu_id], map: "ix_company_delay_interest_cryp_uu_id") + @@index([ref_id], map: "ix_company_delay_interest_ref_id") + @@index([ref_int], map: "ix_company_delay_interest_ref_int") + @@index([updated_at], map: "ix_company_delay_interest_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model contracts { + contract_type String @db.VarChar(5) + contract_title String @db.VarChar(255) + contract_details String + contract_terms String + contract_code String @unique(map: "_contract_ndx_01") @db.VarChar(100) + contract_date DateTime @default(dbgenerated("'2099-12-31 23:59:59+00'::timestamp with time zone")) @db.Timestamptz(6) + company_id Int? + company_uu_id String @default("") @db.VarChar + person_id Int? + person_uu_id String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_contracts_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book build_decision_book[] + build_decision_book_projects build_decision_book_projects[] + companies companies? @relation(fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people people? @relation(fields: [person_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_contracts_created_at") + @@index([cryp_uu_id], map: "ix_contracts_cryp_uu_id") + @@index([ref_id], map: "ix_contracts_ref_id") + @@index([ref_int], map: "ix_contracts_ref_int") + @@index([updated_at], map: "ix_contracts_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model credentials { + credential_token String @default("") @db.VarChar + user_id Int + user_uu_id String @default("") @db.VarChar + person_id Int + person_uu_id String @default("") @db.VarChar + name String @default("") @db.VarChar + surname String @default("") @db.VarChar + email String @default("") @db.VarChar + phone String @default("") @db.VarChar + is_verified Boolean @default(false) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_credentials_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + people people @relation(fields: [person_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + users users @relation(fields: [user_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_credentials_created_at") + @@index([cryp_uu_id], map: "ix_credentials_cryp_uu_id") + @@index([email], map: "ix_credentials_email") + @@index([name], map: "ix_credentials_name") + @@index([person_uu_id], map: "ix_credentials_person_uu_id") + @@index([phone], map: "ix_credentials_phone") + @@index([ref_id], map: "ix_credentials_ref_id") + @@index([ref_int], map: "ix_credentials_ref_int") + @@index([surname], map: "ix_credentials_surname") + @@index([updated_at], map: "ix_credentials_updated_at") + @@index([user_uu_id], map: "ix_credentials_user_uu_id") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model decision_book_budget_books { + country String @db.VarChar + branch_type Int @default(0) @db.SmallInt + company_id Int + company_uu_id String @db.VarChar + branch_id Int? + branch_uu_id String? @db.VarChar + build_decision_book_id Int + build_decision_book_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_decision_book_budget_books_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + companies_decision_book_budget_books_branch_idTocompanies companies? @relation("decision_book_budget_books_branch_idTocompanies", fields: [branch_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_decision_book build_decision_book @relation(fields: [build_decision_book_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies_decision_book_budget_books_company_idTocompanies companies @relation("decision_book_budget_books_company_idTocompanies", fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + decision_book_budget_master decision_book_budget_master[] + + @@index([company_id, created_at], map: "_decision_book_budget_companies_book_ndx_00") + @@index([created_at], map: "ix_decision_book_budget_books_created_at") + @@index([cryp_uu_id], map: "ix_decision_book_budget_books_cryp_uu_id") + @@index([ref_id], map: "ix_decision_book_budget_books_ref_id") + @@index([ref_int], map: "ix_decision_book_budget_books_ref_int") + @@index([updated_at], map: "ix_decision_book_budget_books_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model decision_book_budget_codes { + budget_code String @db.VarChar(48) + comment_line String + build_decision_book_id Int? + build_decision_book_uu_id String? @db.VarChar + build_parts_id Int? + build_parts_uu_id String? @db.VarChar + company_id Int? + company_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_decision_book_budget_codes_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book build_decision_book? @relation(fields: [build_decision_book_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_parts build_parts? @relation(fields: [build_parts_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies companies? @relation(fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + decision_book_budgets decision_book_budgets[] + + @@index([budget_code, created_at], map: "_decision_book_budget_codes_ndx_00") + @@index([company_id, created_at], map: "_decision_book_budget_codes_ndx_01") + @@index([created_at], map: "ix_decision_book_budget_codes_created_at") + @@index([cryp_uu_id], map: "ix_decision_book_budget_codes_cryp_uu_id") + @@index([ref_id], map: "ix_decision_book_budget_codes_ref_id") + @@index([ref_int], map: "ix_decision_book_budget_codes_ref_int") + @@index([updated_at], map: "ix_decision_book_budget_codes_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model decision_book_budget_master { + budget_type String @db.VarChar(50) + currency String @default("TRY") @db.VarChar(8) + total_budget Decimal @db.Decimal(10, 2) + tracking_period_id Int? + tracking_period_uu_id String? @db.VarChar + budget_books_id Int + budget_books_uu_id String? @db.VarChar + department_id Int + department_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_decision_book_budget_master_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + decision_book_budget_books decision_book_budget_books @relation(fields: [budget_books_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + departments departments @relation(fields: [department_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + api_enum_dropdown api_enum_dropdown? @relation(fields: [tracking_period_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + decision_book_budgets decision_book_budgets[] + + @@index([created_at], map: "ix_decision_book_budget_master_created_at") + @@index([cryp_uu_id], map: "ix_decision_book_budget_master_cryp_uu_id") + @@index([ref_id], map: "ix_decision_book_budget_master_ref_id") + @@index([ref_int], map: "ix_decision_book_budget_master_ref_int") + @@index([updated_at], map: "ix_decision_book_budget_master_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model decision_book_budgets { + process_date DateTime @db.Timestamptz(6) + budget_codes_id Int + total_budget Decimal @db.Decimal(10, 2) + used_budget Decimal @db.Decimal(10, 2) + remaining_budget Decimal @db.Decimal(10, 2) + decision_book_budget_master_id Int + decision_book_budget_master_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_decision_book_budgets_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + decision_book_budget_codes decision_book_budget_codes @relation(fields: [budget_codes_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + decision_book_budget_master decision_book_budget_master @relation(fields: [decision_book_budget_master_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([decision_book_budget_master_uu_id, process_date], map: "_decision_book_budgets_ndx_00") + @@index([created_at], map: "ix_decision_book_budgets_created_at") + @@index([cryp_uu_id], map: "ix_decision_book_budgets_cryp_uu_id") + @@index([ref_id], map: "ix_decision_book_budgets_ref_id") + @@index([ref_int], map: "ix_decision_book_budgets_ref_int") + @@index([updated_at], map: "ix_decision_book_budgets_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model departments { + parent_department_id Int? @default(0) + department_code String @db.VarChar(16) + department_name String @db.VarChar(128) + department_description String @default("") @db.VarChar + company_id Int + company_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_departments_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + account_master account_master[] + decision_book_budget_master decision_book_budget_master[] + companies companies @relation(fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + duties duties[] + + @@index([created_at], map: "ix_departments_created_at") + @@index([cryp_uu_id], map: "ix_departments_cryp_uu_id") + @@index([department_code], map: "ix_departments_department_code") + @@index([ref_id], map: "ix_departments_ref_id") + @@index([ref_int], map: "ix_departments_ref_int") + @@index([updated_at], map: "ix_departments_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model duties { + users_default_duty Int? + company_id Int + company_uu_id String @db.VarChar + duties_id Int + duties_uu_id String @db.VarChar + department_id Int + department_uu_id String @db.VarChar + management_duty Boolean? @default(false) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_duties_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + departments departments @relation(fields: [department_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + duty_duties_duties_idToduty duty @relation("duties_duties_idToduty", fields: [duties_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + duty_duties_users_default_dutyToduty duty? @relation("duties_users_default_dutyToduty", fields: [users_default_duty], references: [id], onDelete: NoAction, onUpdate: NoAction) + relationship_duty_company relationship_duty_company[] + relationship_duty_people relationship_duty_people[] + staff staff[] + + @@unique([company_id, duties_id, department_id], map: "duty_ndx_00") + @@index([created_at], map: "ix_duties_created_at") + @@index([cryp_uu_id], map: "ix_duties_cryp_uu_id") + @@index([ref_id], map: "ix_duties_ref_id") + @@index([ref_int], map: "ix_duties_ref_int") + @@index([updated_at], map: "ix_duties_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model duty { + duty_name String @unique @db.VarChar + duty_code String @db.VarChar + duty_description String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_duty_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + duties_duties_duties_idToduty duties[] @relation("duties_duties_idToduty") + duties_duties_users_default_dutyToduty duties[] @relation("duties_users_default_dutyToduty") + + @@index([created_at], map: "ix_duty_created_at") + @@index([cryp_uu_id], map: "ix_duty_cryp_uu_id") + @@index([ref_id], map: "ix_duty_ref_id") + @@index([ref_int], map: "ix_duty_ref_int") + @@index([updated_at], map: "ix_duty_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model employee_history { + staff_id Int + staff_uu_id String @db.VarChar + people_id Int + people_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_employee_history_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + people people @relation(fields: [people_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + staff staff @relation(fields: [staff_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([people_id, staff_id], map: "_employee_history_ndx_00") + @@index([created_at], map: "ix_employee_history_created_at") + @@index([cryp_uu_id], map: "ix_employee_history_cryp_uu_id") + @@index([ref_id], map: "ix_employee_history_ref_id") + @@index([ref_int], map: "ix_employee_history_ref_int") + @@index([updated_at], map: "ix_employee_history_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model employee_salaries { + gross_salary Decimal @db.Decimal(20, 6) + net_salary Decimal @db.Decimal(20, 6) + people_id Int + people_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_employee_salaries_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + people people @relation(fields: [people_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([people_id, expiry_starts], map: "_employee_salaries_ndx_00") + @@index([created_at], map: "ix_employee_salaries_created_at") + @@index([cryp_uu_id], map: "ix_employee_salaries_cryp_uu_id") + @@index([ref_id], map: "ix_employee_salaries_ref_id") + @@index([ref_int], map: "ix_employee_salaries_ref_int") + @@index([updated_at], map: "ix_employee_salaries_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model employees { + staff_id Int + staff_uu_id String @db.VarChar + people_id Int? + people_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_employees_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + application2employee application2employee[] + application2employee_extra application2employee_extra[] + people people? @relation(fields: [people_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + staff staff @relation(fields: [staff_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + event2employee event2employee[] + event2employee_extra event2employee_extra[] + part2employee part2employee[] + relationship_employee2build relationship_employee2build[] + relationship_employee2postcode relationship_employee2postcode[] + + @@unique([people_id, staff_id], map: "employees_ndx_00") + @@index([created_at], map: "ix_employees_created_at") + @@index([cryp_uu_id], map: "ix_employees_cryp_uu_id") + @@index([ref_id], map: "ix_employees_ref_id") + @@index([ref_int], map: "ix_employees_ref_int") + @@index([updated_at], map: "ix_employees_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model endpoint_restriction { + operation_uu_id String @unique @db.VarChar + endpoint_function String @default("") @db.VarChar + endpoint_name String @default("") @db.VarChar + endpoint_method String @default("") @db.VarChar + endpoint_desc String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_endpoint_restriction_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + events events[] + + @@unique([operation_uu_id, endpoint_method, endpoint_name], map: "idx_endpoint_restriction_operation_uu_id") + @@index([created_at], map: "ix_endpoint_restriction_created_at") + @@index([cryp_uu_id], map: "ix_endpoint_restriction_cryp_uu_id") + @@index([ref_id], map: "ix_endpoint_restriction_ref_id") + @@index([ref_int], map: "ix_endpoint_restriction_ref_int") + @@index([updated_at], map: "ix_endpoint_restriction_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model event2employee { + employee_id Int + employee_uu_id String @db.VarChar + event_service_id Int + event_service_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_event2employee_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + employees employees @relation(fields: [employee_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + services services @relation(fields: [event_service_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([employee_id, event_service_id], map: "event2employee_employee_to_event") + @@index([created_at], map: "ix_event2employee_created_at") + @@index([cryp_uu_id], map: "ix_event2employee_cryp_uu_id") + @@index([ref_id], map: "ix_event2employee_ref_id") + @@index([ref_int], map: "ix_event2employee_ref_int") + @@index([updated_at], map: "ix_event2employee_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model event2employee_extra { + employee_id Int + employee_uu_id String @db.VarChar + event_id Int + event_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_event2employee_extra_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + employees employees @relation(fields: [employee_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + events events @relation(fields: [event_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([employee_id, event_id], map: "event2employee_extra_employee_to_event") + @@index([created_at], map: "ix_event2employee_extra_created_at") + @@index([cryp_uu_id], map: "ix_event2employee_extra_cryp_uu_id") + @@index([ref_id], map: "ix_event2employee_extra_ref_id") + @@index([ref_int], map: "ix_event2employee_extra_ref_int") + @@index([updated_at], map: "ix_event2employee_extra_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model event2occupant { + build_living_space_id Int + build_living_space_uu_id String @db.VarChar + event_service_id Int + event_service_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_event2occupant_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_living_space build_living_space @relation(fields: [build_living_space_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + services services @relation(fields: [event_service_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([build_living_space_id, event_service_id], map: "event2occupant_bind_event_to_occupant") + @@index([created_at], map: "ix_event2occupant_created_at") + @@index([cryp_uu_id], map: "ix_event2occupant_cryp_uu_id") + @@index([ref_id], map: "ix_event2occupant_ref_id") + @@index([ref_int], map: "ix_event2occupant_ref_int") + @@index([updated_at], map: "ix_event2occupant_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model event2occupant_extra { + build_living_space_id Int + build_living_space_uu_id String @db.VarChar + event_id Int + event_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_event2occupant_extra_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_living_space build_living_space @relation(fields: [build_living_space_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + events events @relation(fields: [event_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([build_living_space_id, event_id], map: "event2occupant_extra_bind_event_to_occupant") + @@index([created_at], map: "ix_event2occupant_extra_created_at") + @@index([cryp_uu_id], map: "ix_event2occupant_extra_cryp_uu_id") + @@index([ref_id], map: "ix_event2occupant_extra_ref_id") + @@index([ref_int], map: "ix_event2occupant_extra_ref_int") + @@index([updated_at], map: "ix_event2occupant_extra_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model events { + function_code String @unique @db.VarChar + function_class String @db.VarChar + description String @default("") @db.VarChar + property_description String @default("") @db.VarChar + marketing_layer Int? @default(3) @db.SmallInt + cost Decimal @default(0.00) @db.Decimal(20, 2) + unit_price Decimal @default(0.00) @db.Decimal(20, 2) + endpoint_code String @db.VarChar + endpoint_id Int? + endpoint_uu_id String? @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_events_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + event2employee_extra event2employee_extra[] + event2occupant_extra event2occupant_extra[] + endpoint_restriction endpoint_restriction? @relation(fields: [endpoint_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + module_price module_price[] + services2events services2events[] + + @@index([created_at], map: "ix_events_created_at") + @@index([cryp_uu_id], map: "ix_events_cryp_uu_id") + @@index([ref_id], map: "ix_events_ref_id") + @@index([ref_int], map: "ix_events_ref_int") + @@index([updated_at], map: "ix_events_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model module_price { + campaign_code String @db.VarChar + module_id Int + module_uu_id String @db.VarChar + service_id Int + service_uu_id String @db.VarChar + event_id Int + event_uu_id String @db.VarChar + is_counted_percentage Decimal @default(0.00) @db.Decimal(6, 2) + discounted_price Decimal @default(0.00) @db.Decimal(20, 2) + calculated_price Decimal @default(0.00) @db.Decimal(20, 2) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_module_price_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + events events @relation(fields: [event_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + modules modules @relation(fields: [module_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + services services @relation(fields: [service_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_module_price_created_at") + @@index([cryp_uu_id], map: "ix_module_price_cryp_uu_id") + @@index([ref_id], map: "ix_module_price_ref_id") + @@index([ref_int], map: "ix_module_price_ref_int") + @@index([updated_at], map: "ix_module_price_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model modules { + module_name String @db.VarChar + module_description String @default("") @db.VarChar + module_code String @db.VarChar + module_layer Int + is_default_module Boolean? @default(false) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_modules_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + module_price module_price[] + services services[] + + @@index([created_at], map: "ix_modules_created_at") + @@index([cryp_uu_id], map: "ix_modules_cryp_uu_id") + @@index([ref_id], map: "ix_modules_ref_id") + @@index([ref_int], map: "ix_modules_ref_int") + @@index([updated_at], map: "ix_modules_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model occupant_types { + occupant_type String @db.VarChar + occupant_description String @default("") @db.VarChar + occupant_code String @default("") @db.VarChar + occupant_category String @default("") @db.VarChar + occupant_category_type String @default("") @db.VarChar + occupant_is_unique Boolean @default(false) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_occupant_types_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + build_decision_book_person_occupants build_decision_book_person_occupants[] + build_living_space build_living_space[] + build_management build_management[] + + @@index([created_at], map: "ix_occupant_types_created_at") + @@index([cryp_uu_id], map: "ix_occupant_types_cryp_uu_id") + @@index([ref_id], map: "ix_occupant_types_ref_id") + @@index([ref_int], map: "ix_occupant_types_ref_int") + @@index([updated_at], map: "ix_occupant_types_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model part2employee { + build_id Int + part_id Int + employee_id Int + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_part2employee_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + employees employees @relation(fields: [employee_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build_parts build_parts @relation(fields: [part_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([employee_id, part_id], map: "_part2employee_ndx_00") + @@index([created_at], map: "ix_part2employee_created_at") + @@index([cryp_uu_id], map: "ix_part2employee_cryp_uu_id") + @@index([ref_id], map: "ix_part2employee_ref_id") + @@index([ref_int], map: "ix_part2employee_ref_int") + @@index([updated_at], map: "ix_part2employee_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model people { + firstname String @db.VarChar + surname String @db.VarChar(24) + middle_name String @default("") @db.VarChar + sex_code String @db.VarChar(1) + person_ref String @default("") @db.VarChar + person_tag String @default("") @db.VarChar + father_name String @default("") @db.VarChar + mother_name String @default("") @db.VarChar + country_code String @default("TR") @db.VarChar(4) + national_identity_id String @unique(map: "person_ndx_001") @default("") @db.VarChar + birth_place String @default("") @db.VarChar + birth_date DateTime @default(dbgenerated("'1900-01-01 00:00:00+00'::timestamp with time zone")) @db.Timestamptz(6) + tax_no String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_people_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + birthname String? @db.VarChar + account_codes account_codes[] + account_records_account_records_approving_accounting_personTopeople account_records[] @relation("account_records_approving_accounting_personTopeople") + account_records_account_records_customer_idTopeople account_records[] @relation("account_records_customer_idTopeople") + account_records_account_records_send_person_idTopeople account_records[] @relation("account_records_send_person_idTopeople") + build_decision_book_items_unapproved build_decision_book_items_unapproved[] + build_decision_book_legal_build_decision_book_legal_mediator_lawyer_person_idTopeople build_decision_book_legal[] @relation("build_decision_book_legal_mediator_lawyer_person_idTopeople") + build_decision_book_legal_build_decision_book_legal_resp_attorney_idTopeople build_decision_book_legal[] @relation("build_decision_book_legal_resp_attorney_idTopeople") + build_decision_book_person_build_decision_book_person_person_idTopeople build_decision_book_person[] @relation("build_decision_book_person_person_idTopeople") + build_decision_book_person_build_decision_book_person_vicarious_person_idTopeople build_decision_book_person[] @relation("build_decision_book_person_vicarious_person_idTopeople") + build_iban_description build_iban_description[] + build_living_space build_living_space[] + build_person_providing build_person_providing[] + contracts contracts[] + credentials credentials[] + employee_history employee_history[] + employee_salaries employee_salaries[] + employees employees[] + relationship_duty_people relationship_duty_people[] + users users[] + + @@index([created_at], map: "ix_people_created_at") + @@index([cryp_uu_id], map: "ix_people_cryp_uu_id") + @@index([ref_id], map: "ix_people_ref_id") + @@index([ref_int], map: "ix_people_ref_int") + @@index([updated_at], map: "ix_people_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model relationship_duty_company { + owner_id Int + duties_id Int + member_id Int + parent_id Int? + relationship_type String? @default("Commercial") @db.VarChar + child_count Int + show_only Boolean @default(false) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_relationship_duty_company_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + duties duties @relation(fields: [duties_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies_relationship_duty_company_member_idTocompanies companies @relation("relationship_duty_company_member_idTocompanies", fields: [member_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies_relationship_duty_company_owner_idTocompanies companies @relation("relationship_duty_company_owner_idTocompanies", fields: [owner_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + companies_relationship_duty_company_parent_idTocompanies companies? @relation("relationship_duty_company_parent_idTocompanies", fields: [parent_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([duties_id, owner_id, member_id, relationship_type], map: "_company_relationship_ndx_01") + @@index([created_at], map: "ix_relationship_duty_company_created_at") + @@index([cryp_uu_id], map: "ix_relationship_duty_company_cryp_uu_id") + @@index([ref_id], map: "ix_relationship_duty_company_ref_id") + @@index([ref_int], map: "ix_relationship_duty_company_ref_int") + @@index([updated_at], map: "ix_relationship_duty_company_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model relationship_duty_people { + company_id Int + duties_id Int + member_id Int + relationship_type String? @default("Employee") @db.VarChar + show_only Boolean @default(false) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_relationship_duty_people_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + companies companies @relation(fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + duties duties @relation(fields: [duties_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + people people @relation(fields: [member_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([company_id, duties_id, member_id, relationship_type], map: "person_relationship_ndx_01") + @@index([created_at], map: "ix_relationship_duty_people_created_at") + @@index([cryp_uu_id], map: "ix_relationship_duty_people_cryp_uu_id") + @@index([ref_id], map: "ix_relationship_duty_people_ref_id") + @@index([ref_int], map: "ix_relationship_duty_people_ref_int") + @@index([updated_at], map: "ix_relationship_duty_people_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model relationship_employee2build { + company_id Int + employee_id Int + member_id Int + relationship_type String? @default("Employee") @db.VarChar + show_only Boolean @default(false) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_relationship_employee2build_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + companies companies @relation(fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + employees employees @relation(fields: [employee_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + build build @relation(fields: [member_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@unique([company_id, employee_id, member_id, relationship_type], map: "relationship_build_employee_ndx_00") + @@index([created_at], map: "ix_relationship_employee2build_created_at") + @@index([cryp_uu_id], map: "ix_relationship_employee2build_cryp_uu_id") + @@index([ref_id], map: "ix_relationship_employee2build_ref_id") + @@index([ref_int], map: "ix_relationship_employee2build_ref_int") + @@index([updated_at], map: "ix_relationship_employee2build_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model relationship_employee2postcode { + company_id Int? + employee_id Int + member_id Int + relationship_type String? @default("Employee") @db.VarChar + show_only Boolean @default(false) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_relationship_employee2postcode_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + companies companies? @relation(fields: [company_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + employees employees @relation(fields: [employee_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + address_postcode address_postcode @relation(fields: [member_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_relationship_employee2postcode_created_at") + @@index([cryp_uu_id], map: "ix_relationship_employee2postcode_cryp_uu_id") + @@index([ref_id], map: "ix_relationship_employee2postcode_ref_id") + @@index([ref_int], map: "ix_relationship_employee2postcode_ref_int") + @@index([updated_at], map: "ix_relationship_employee2postcode_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model services { + module_id Int + module_uu_id String @db.VarChar + service_name String @db.VarChar + service_description String @default("") @db.VarChar + service_code String? @db.VarChar + related_responsibility String @default("") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_services_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + application2employee application2employee[] + application2occupant application2occupant[] + event2employee event2employee[] + event2occupant event2occupant[] + module_price module_price[] + modules modules @relation(fields: [module_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + services2applications services2applications[] + services2events services2events[] + + @@index([created_at], map: "ix_services_created_at") + @@index([cryp_uu_id], map: "ix_services_cryp_uu_id") + @@index([ref_id], map: "ix_services_ref_id") + @@index([ref_int], map: "ix_services_ref_int") + @@index([updated_at], map: "ix_services_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model services2applications { + application_id Int + application_uu_id String @db.VarChar + service_id Int + service_uu_id String @db.VarChar + application_code String @db.VarChar + site_url String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_services2applications_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + applications applications @relation(fields: [application_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + services services @relation(fields: [service_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_services2applications_created_at") + @@index([cryp_uu_id], map: "ix_services2applications_cryp_uu_id") + @@index([ref_id], map: "ix_services2applications_ref_id") + @@index([ref_int], map: "ix_services2applications_ref_int") + @@index([updated_at], map: "ix_services2applications_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model services2events { + service_id Int + service_uu_id String @db.VarChar + event_id Int + event_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_services2events_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + events events @relation(fields: [event_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + services services @relation(fields: [service_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_services2events_created_at") + @@index([cryp_uu_id], map: "ix_services2events_cryp_uu_id") + @@index([ref_id], map: "ix_services2events_ref_id") + @@index([ref_int], map: "ix_services2events_ref_int") + @@index([updated_at], map: "ix_services2events_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model staff { + staff_description String @default("") @db.VarChar + staff_name String @db.VarChar + staff_code String @db.VarChar + duties_id Int + duties_uu_id String @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_staff_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + employee_history employee_history[] + employees employees[] + duties duties @relation(fields: [duties_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_staff_created_at") + @@index([cryp_uu_id], map: "ix_staff_cryp_uu_id") + @@index([ref_id], map: "ix_staff_ref_id") + @@index([ref_int], map: "ix_staff_ref_int") + @@index([updated_at], map: "ix_staff_updated_at") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model users { + user_tag String @default("") @db.VarChar(64) + email String @default("") @db.VarChar(128) + phone_number String @default("") @db.VarChar + via String @default("111") @db.VarChar + avatar String @default("") @db.VarChar + hash_password String @default("") @db.VarChar(256) + password_token String @default("") @db.VarChar(256) + remember_me Boolean @default(false) + password_expires_day Int @default(30) + password_expiry_begins DateTime @default(now()) @db.Timestamptz(6) + related_company String @db.VarChar + person_id Int + person_uu_id String @default("") @db.VarChar + local_timezone String? @default("GMT+3") @db.VarChar + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_users_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + default_language String @default("tr") @db.VarChar + ref_int Int? + credentials credentials[] + people people @relation(fields: [person_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + users_tokens users_tokens[] + domain_data domain_data[] @relation("UserDomainData") + + @@index([created_at], map: "ix_users_created_at") + @@index([cryp_uu_id], map: "ix_users_cryp_uu_id") + @@index([email], map: "ix_users_email") + @@index([person_uu_id], map: "ix_users_person_uu_id") + @@index([phone_number], map: "ix_users_phone_number") + @@index([ref_id], map: "ix_users_ref_id") + @@index([ref_int], map: "ix_users_ref_int") + @@index([updated_at], map: "ix_users_updated_at") + @@index([user_tag], map: "ix_users_user_tag") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model users_tokens { + user_id Int + token_type String @default("RememberMe") @db.VarChar(16) + token String @default("") @db.VarChar + domain String @default("") @db.VarChar + expires_at DateTime @db.Timestamptz(6) + ref_id String? @db.VarChar(100) + replication_id Int @default(0) @db.SmallInt + cryp_uu_id String? @db.VarChar + created_credentials_token String? @db.VarChar + updated_credentials_token String? @db.VarChar + confirmed_credentials_token String? @db.VarChar + is_confirmed Boolean @default(false) + deleted Boolean @default(false) + active Boolean @default(true) + is_notification_send Boolean @default(false) + is_email_send Boolean @default(false) + id Int @id @default(autoincrement()) + uu_id String @unique(map: "ix_users_tokens_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + expiry_starts DateTime @default(now()) @db.Timestamptz(6) + expiry_ends DateTime @default(now()) @db.Timestamptz(6) + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + ref_int Int? + users users @relation(fields: [user_id], references: [id], onDelete: NoAction, onUpdate: NoAction) + + @@index([created_at], map: "ix_users_tokens_created_at") + @@index([cryp_uu_id], map: "ix_users_tokens_cryp_uu_id") + @@index([ref_id], map: "ix_users_tokens_ref_id") + @@index([ref_int], map: "ix_users_tokens_ref_int") + @@index([updated_at], map: "ix_users_tokens_updated_at") +} + +model domain_data { + id Int @id @default(autoincrement()) + uu_id String @unique(map: "domain_data_uu_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid + userUUID String @map("user_uuid") @db.Uuid + otherDomainsList String[] @map("other_domains_list") + mainDomain String? @map("main_domain") + modifiedAt Float @map("modified_at") + created_at DateTime @default(now()) @db.Timestamptz(6) + updated_at DateTime @default(now()) @db.Timestamptz(6) + users users @relation("UserDomainData", fields: [userUUID], references: [uu_id], onDelete: NoAction, onUpdate: NoAction, map: "domain_data_users_fkey") + + @@index([created_at], map: "ix_domain_data_created_at") + @@index([uu_id], map: "idx_domain_data_uu_id") + @@index([updated_at], map: "ix_domain_data_updated_at") +} + +enum tabledefs { + PKEY_INTERNAL + PKEY_EXTERNAL + FKEYS_INTERNAL + FKEYS_EXTERNAL + COMMENTS + FKEYS_NONE + INCLUDE_TRIGGERS + NO_TRIGGERS +} diff --git a/ServicesApi/src/accounts/accounts.controller.spec.ts b/ServicesApi/src/accounts/accounts.controller.spec.ts new file mode 100644 index 0000000..6308252 --- /dev/null +++ b/ServicesApi/src/accounts/accounts.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { AccountsController } from './accounts.controller'; + +describe('AccountsController', () => { + let controller: AccountsController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [AccountsController], + }).compile(); + + controller = module.get(AccountsController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/accounts/accounts.controller.ts b/ServicesApi/src/accounts/accounts.controller.ts new file mode 100644 index 0000000..e0c41c4 --- /dev/null +++ b/ServicesApi/src/accounts/accounts.controller.ts @@ -0,0 +1,39 @@ +import { + Controller, + Get, + Post, + Put, + Delete, + Param, + Body, + HttpCode, +} from '@nestjs/common'; +import { AccountsService } from './accounts.service'; + +@Controller('accounts') +export class AccountsController { + constructor(private accountsService: AccountsService) {} + + @Post('filter') + @HttpCode(200) + async filterAccounts(@Body() query: any) { + const result = await this.accountsService.findWithPagination(query); + const { pagination, data } = result; + + if (data.length === 0) { + return { pagination, data: [] }; + } + + const resultRefined = data.map((rec: any) => ({ + ...rec, + build_decision_book_payments: rec.build_decision_book_payments?.map( + (pmt: any) => ({ + ...pmt, + ratePercent: + ((pmt.payment_amount / rec.currency_value) * 100).toFixed(2) + '%', + }), + ), + })); + return { pagination, data: resultRefined }; + } +} diff --git a/ServicesApi/src/accounts/accounts.module.ts b/ServicesApi/src/accounts/accounts.module.ts new file mode 100644 index 0000000..946d09e --- /dev/null +++ b/ServicesApi/src/accounts/accounts.module.ts @@ -0,0 +1,13 @@ +import { Module } from '@nestjs/common'; +import { AccountsService } from './accounts.service'; +import { AccountsController } from './accounts.controller'; +import { PrismaModule } from '@/prisma/prisma.module'; +import { CacheService } from '../cache.service'; +import { UtilsModule } from '../utils/utils.module'; + +@Module({ + imports: [PrismaModule, UtilsModule], + providers: [AccountsService, CacheService], + controllers: [AccountsController], +}) +export class AccountsModule {} diff --git a/ServicesApi/src/accounts/accounts.service.spec.ts b/ServicesApi/src/accounts/accounts.service.spec.ts new file mode 100644 index 0000000..01304e2 --- /dev/null +++ b/ServicesApi/src/accounts/accounts.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { AccountsService } from './accounts.service'; + +describe('AccountsService', () => { + let service: AccountsService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [AccountsService], + }).compile(); + + service = module.get(AccountsService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/accounts/accounts.service.ts b/ServicesApi/src/accounts/accounts.service.ts new file mode 100644 index 0000000..cdb898a --- /dev/null +++ b/ServicesApi/src/accounts/accounts.service.ts @@ -0,0 +1,42 @@ +import { Injectable } from '@nestjs/common'; +import { PrismaService } from '@/src/prisma.service'; +import { Prisma, account_records } from '@prisma/client'; +import { CacheService } from '../cache.service'; +import { PaginationHelper, PaginationInfo } from '../utils/pagination-helper'; + +@Injectable() +export class AccountsService { + constructor( + private prisma: PrismaService, + private cacheService: CacheService, + private paginationHelper: PaginationHelper, + ) {} + + async findAll(filter: any): Promise[]> { + return this.prisma.account_records.findMany({ + where: { ...filter }, + }); + } + + async findDynamic( + query: Prisma.account_recordsFindManyArgs, + ): Promise<{ totalCount: number; result: Partial[] }> { + const totalCount = await this.prisma.account_records.count({ + where: query.where, + }); + const result = await this.prisma.account_records.findMany(query); + return { totalCount, result }; + } + + async findWithPagination( + query: any & { page?: number; pageSize?: number }, + ): Promise<{ data: any[]; pagination: PaginationInfo }> { + return this.paginationHelper.paginate(this.prisma.account_records, query); + } + + async findOne(uuid: string): Promise | null> { + return this.prisma.account_records.findUnique({ + where: { uu_id: uuid }, + }); + } +} diff --git a/ServicesApi/src/accounts/text_example.txt b/ServicesApi/src/accounts/text_example.txt new file mode 100644 index 0000000..ad0ee68 --- /dev/null +++ b/ServicesApi/src/accounts/text_example.txt @@ -0,0 +1,36 @@ +http://localhost:3000/accounts/filter + +{ + "where": { + "build_parts": { + "part_code": { + "contains": "10", + "mode": "insensitive" + } + } + }, + "select": { + "process_comment": true, + "bank_date": true, + "currency_value": true, + "build_parts": { + "select": { + "part_code": true + } + }, + "build_decision_book_payments": { + "select": { + "payment_amount": true, + "process_date": true, + "build_decision_book_items": { + "select": { + "item_order": true, + "item_comment": true + } + } + } + } + }, + "page": 2, + "pageSize": 5 +} diff --git a/ServicesApi/src/app.module.ts b/ServicesApi/src/app.module.ts index 971402e..41919f6 100644 --- a/ServicesApi/src/app.module.ts +++ b/ServicesApi/src/app.module.ts @@ -1,12 +1,50 @@ -import { Module } from '@nestjs/common'; +import { + MiddlewareConsumer, + Module, + NestModule, + RequestMethod, +} from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { UsersModule } from './users/users.module'; import { PrismaModule } from '@/prisma/prisma.module'; +import { AccountsModule } from './accounts/accounts.module'; +import { AuthModule } from './auth/auth.module'; +import { RedisModule } from '@liaoliaots/nestjs-redis'; +import { CacheService } from './cache.service'; +import { LoggerMiddleware } from '@/src/middleware/logger.middleware'; + +const redisConfig = { + host: '10.10.2.15', + port: 6379, + password: 'your_strong_password_here', +}; + +const modulesList = [UsersModule, AccountsModule, AuthModule]; +const serviceModuleList = [ + PrismaModule, + RedisModule.forRoot({ + config: redisConfig, + }), +]; +const controllersList = [AppController]; +const providersList = [AppService, CacheService]; +const exportsList = [CacheService]; @Module({ - imports: [PrismaModule, UsersModule], - controllers: [AppController], - providers: [AppService], + imports: [...modulesList, ...serviceModuleList], + controllers: controllersList, + providers: providersList, + exports: exportsList, }) -export class AppModule {} +export class AppModule implements NestModule { + configure(consumer: MiddlewareConsumer) { + consumer + .apply(LoggerMiddleware) + .exclude( + { path: 'accounts', method: RequestMethod.ALL }, + { path: 'users/*path', method: RequestMethod.ALL }, + ) + .forRoutes('*'); + } +} diff --git a/ServicesApi/src/auth/auth.module.ts b/ServicesApi/src/auth/auth.module.ts new file mode 100644 index 0000000..f32ceee --- /dev/null +++ b/ServicesApi/src/auth/auth.module.ts @@ -0,0 +1,21 @@ +import { Module } from '@nestjs/common'; +import { LoginModule } from '@/src/auth/login/login.module'; +import { SelectModule } from '@/src/auth/select/select.module'; +import { PasswordService } from '@/src/auth/password/password.service'; +import { PasswordModule } from '@/src/auth/password/password.module'; +import { LogoutModule } from '@/src/auth/logout/logout.module'; +import { DisconnectModule } from '@/src/auth/disconnect/disconnect.module'; +import { TokenModule } from '@/src/auth/token/token.module'; + +@Module({ + imports: [ + LoginModule, + LogoutModule, + SelectModule, + PasswordModule, + DisconnectModule, + TokenModule, + ], + providers: [PasswordService], +}) +export class AuthModule {} diff --git a/ServicesApi/src/auth/disconnect/disconnect.controller.spec.ts b/ServicesApi/src/auth/disconnect/disconnect.controller.spec.ts new file mode 100644 index 0000000..13daeed --- /dev/null +++ b/ServicesApi/src/auth/disconnect/disconnect.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { DisconnectController } from './disconnect.controller'; + +describe('DisconnectController', () => { + let controller: DisconnectController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [DisconnectController], + }).compile(); + + controller = module.get(DisconnectController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/disconnect/disconnect.controller.ts b/ServicesApi/src/auth/disconnect/disconnect.controller.ts new file mode 100644 index 0000000..6765fd3 --- /dev/null +++ b/ServicesApi/src/auth/disconnect/disconnect.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('disconnect') +export class DisconnectController {} diff --git a/ServicesApi/src/auth/disconnect/disconnect.module.ts b/ServicesApi/src/auth/disconnect/disconnect.module.ts new file mode 100644 index 0000000..d2d2224 --- /dev/null +++ b/ServicesApi/src/auth/disconnect/disconnect.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { DisconnectService } from './disconnect.service'; +import { DisconnectController } from './disconnect.controller'; + +@Module({ + providers: [DisconnectService], + controllers: [DisconnectController] +}) +export class DisconnectModule {} diff --git a/ServicesApi/src/auth/disconnect/disconnect.service.spec.ts b/ServicesApi/src/auth/disconnect/disconnect.service.spec.ts new file mode 100644 index 0000000..53ccd25 --- /dev/null +++ b/ServicesApi/src/auth/disconnect/disconnect.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { DisconnectService } from './disconnect.service'; + +describe('DisconnectService', () => { + let service: DisconnectService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [DisconnectService], + }).compile(); + + service = module.get(DisconnectService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/disconnect/disconnect.service.ts b/ServicesApi/src/auth/disconnect/disconnect.service.ts new file mode 100644 index 0000000..3b892ab --- /dev/null +++ b/ServicesApi/src/auth/disconnect/disconnect.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class DisconnectService {} diff --git a/ServicesApi/src/auth/login/login.controller.spec.ts b/ServicesApi/src/auth/login/login.controller.spec.ts new file mode 100644 index 0000000..e83e5de --- /dev/null +++ b/ServicesApi/src/auth/login/login.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { LoginController } from './login.controller'; + +describe('LoginController', () => { + let controller: LoginController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [LoginController], + }).compile(); + + controller = module.get(LoginController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/login/login.controller.ts b/ServicesApi/src/auth/login/login.controller.ts new file mode 100644 index 0000000..7c0cdfd --- /dev/null +++ b/ServicesApi/src/auth/login/login.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('login') +export class LoginController {} diff --git a/ServicesApi/src/auth/login/login.module.ts b/ServicesApi/src/auth/login/login.module.ts new file mode 100644 index 0000000..e5829c7 --- /dev/null +++ b/ServicesApi/src/auth/login/login.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { LoginController } from './login.controller'; +import { LoginService } from './login.service'; + +@Module({ + controllers: [LoginController], + providers: [LoginService] +}) +export class LoginModule {} diff --git a/ServicesApi/src/auth/login/login.service.spec.ts b/ServicesApi/src/auth/login/login.service.spec.ts new file mode 100644 index 0000000..c531e06 --- /dev/null +++ b/ServicesApi/src/auth/login/login.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { LoginService } from './login.service'; + +describe('LoginService', () => { + let service: LoginService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [LoginService], + }).compile(); + + service = module.get(LoginService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/login/login.service.ts b/ServicesApi/src/auth/login/login.service.ts new file mode 100644 index 0000000..6b0cd09 --- /dev/null +++ b/ServicesApi/src/auth/login/login.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class LoginService {} diff --git a/ServicesApi/src/auth/logout/logout.controller.spec.ts b/ServicesApi/src/auth/logout/logout.controller.spec.ts new file mode 100644 index 0000000..aee9143 --- /dev/null +++ b/ServicesApi/src/auth/logout/logout.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { LogoutController } from './logout.controller'; + +describe('LogoutController', () => { + let controller: LogoutController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [LogoutController], + }).compile(); + + controller = module.get(LogoutController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/logout/logout.controller.ts b/ServicesApi/src/auth/logout/logout.controller.ts new file mode 100644 index 0000000..3ef0a17 --- /dev/null +++ b/ServicesApi/src/auth/logout/logout.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('logout') +export class LogoutController {} diff --git a/ServicesApi/src/auth/logout/logout.module.ts b/ServicesApi/src/auth/logout/logout.module.ts new file mode 100644 index 0000000..497d216 --- /dev/null +++ b/ServicesApi/src/auth/logout/logout.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { LogoutService } from './logout.service'; +import { LogoutController } from './logout.controller'; + +@Module({ + providers: [LogoutService], + controllers: [LogoutController] +}) +export class LogoutModule {} diff --git a/ServicesApi/src/auth/logout/logout.service.spec.ts b/ServicesApi/src/auth/logout/logout.service.spec.ts new file mode 100644 index 0000000..fd48436 --- /dev/null +++ b/ServicesApi/src/auth/logout/logout.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { LogoutService } from './logout.service'; + +describe('LogoutService', () => { + let service: LogoutService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [LogoutService], + }).compile(); + + service = module.get(LogoutService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/logout/logout.service.ts b/ServicesApi/src/auth/logout/logout.service.ts new file mode 100644 index 0000000..17ff966 --- /dev/null +++ b/ServicesApi/src/auth/logout/logout.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class LogoutService {} diff --git a/ServicesApi/src/auth/password/change/change.controller.spec.ts b/ServicesApi/src/auth/password/change/change.controller.spec.ts new file mode 100644 index 0000000..803c511 --- /dev/null +++ b/ServicesApi/src/auth/password/change/change.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { ChangeController } from './change.controller'; + +describe('ChangeController', () => { + let controller: ChangeController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [ChangeController], + }).compile(); + + controller = module.get(ChangeController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/password/change/change.controller.ts b/ServicesApi/src/auth/password/change/change.controller.ts new file mode 100644 index 0000000..3bdbc12 --- /dev/null +++ b/ServicesApi/src/auth/password/change/change.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('change') +export class ChangeController {} diff --git a/ServicesApi/src/auth/password/change/change.module.ts b/ServicesApi/src/auth/password/change/change.module.ts new file mode 100644 index 0000000..9f4b352 --- /dev/null +++ b/ServicesApi/src/auth/password/change/change.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { ChangeService } from './change.service'; +import { ChangeController } from './change.controller'; + +@Module({ + providers: [ChangeService], + controllers: [ChangeController] +}) +export class ChangeModule {} diff --git a/ServicesApi/src/auth/password/change/change.service.spec.ts b/ServicesApi/src/auth/password/change/change.service.spec.ts new file mode 100644 index 0000000..e3dfee7 --- /dev/null +++ b/ServicesApi/src/auth/password/change/change.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { ChangeService } from './change.service'; + +describe('ChangeService', () => { + let service: ChangeService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [ChangeService], + }).compile(); + + service = module.get(ChangeService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/password/change/change.service.ts b/ServicesApi/src/auth/password/change/change.service.ts new file mode 100644 index 0000000..32fbea6 --- /dev/null +++ b/ServicesApi/src/auth/password/change/change.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class ChangeService {} diff --git a/ServicesApi/src/auth/password/create/create.controller.spec.ts b/ServicesApi/src/auth/password/create/create.controller.spec.ts new file mode 100644 index 0000000..74d64e5 --- /dev/null +++ b/ServicesApi/src/auth/password/create/create.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { CreateController } from './create.controller'; + +describe('CreateController', () => { + let controller: CreateController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [CreateController], + }).compile(); + + controller = module.get(CreateController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/password/create/create.controller.ts b/ServicesApi/src/auth/password/create/create.controller.ts new file mode 100644 index 0000000..770e81e --- /dev/null +++ b/ServicesApi/src/auth/password/create/create.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('create') +export class CreateController {} diff --git a/ServicesApi/src/auth/password/create/create.module.ts b/ServicesApi/src/auth/password/create/create.module.ts new file mode 100644 index 0000000..ae0db82 --- /dev/null +++ b/ServicesApi/src/auth/password/create/create.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { CreateService } from './create.service'; +import { CreateController } from './create.controller'; + +@Module({ + providers: [CreateService], + controllers: [CreateController] +}) +export class CreateModule {} diff --git a/ServicesApi/src/auth/password/create/create.service.spec.ts b/ServicesApi/src/auth/password/create/create.service.spec.ts new file mode 100644 index 0000000..9f1810e --- /dev/null +++ b/ServicesApi/src/auth/password/create/create.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { CreateService } from './create.service'; + +describe('CreateService', () => { + let service: CreateService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [CreateService], + }).compile(); + + service = module.get(CreateService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/password/create/create.service.ts b/ServicesApi/src/auth/password/create/create.service.ts new file mode 100644 index 0000000..fe1a048 --- /dev/null +++ b/ServicesApi/src/auth/password/create/create.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class CreateService {} diff --git a/ServicesApi/src/auth/password/password.controller.spec.ts b/ServicesApi/src/auth/password/password.controller.spec.ts new file mode 100644 index 0000000..7b581c5 --- /dev/null +++ b/ServicesApi/src/auth/password/password.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { PasswordController } from './password.controller'; + +describe('PasswordController', () => { + let controller: PasswordController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [PasswordController], + }).compile(); + + controller = module.get(PasswordController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/password/password.controller.ts b/ServicesApi/src/auth/password/password.controller.ts new file mode 100644 index 0000000..5c23395 --- /dev/null +++ b/ServicesApi/src/auth/password/password.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('password') +export class PasswordController {} diff --git a/ServicesApi/src/auth/password/password.module.ts b/ServicesApi/src/auth/password/password.module.ts new file mode 100644 index 0000000..d0c36ff --- /dev/null +++ b/ServicesApi/src/auth/password/password.module.ts @@ -0,0 +1,12 @@ +import { Module } from '@nestjs/common'; +import { PasswordController } from './password.controller'; +import { CreateModule } from './create/create.module'; +import { ChangeModule } from './change/change.module'; +import { ResetModule } from './reset/reset.module'; +import { VerifyOtpModule } from './verify-otp/verify-otp.module'; + +@Module({ + controllers: [PasswordController], + imports: [CreateModule, ChangeModule, ResetModule, VerifyOtpModule] +}) +export class PasswordModule {} diff --git a/ServicesApi/src/auth/password/password.service.spec.ts b/ServicesApi/src/auth/password/password.service.spec.ts new file mode 100644 index 0000000..730923b --- /dev/null +++ b/ServicesApi/src/auth/password/password.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { PasswordService } from './password.service'; + +describe('PasswordService', () => { + let service: PasswordService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [PasswordService], + }).compile(); + + service = module.get(PasswordService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/password/password.service.ts b/ServicesApi/src/auth/password/password.service.ts new file mode 100644 index 0000000..70ffc04 --- /dev/null +++ b/ServicesApi/src/auth/password/password.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class PasswordService {} diff --git a/ServicesApi/src/auth/password/reset/reset.controller.spec.ts b/ServicesApi/src/auth/password/reset/reset.controller.spec.ts new file mode 100644 index 0000000..a961f06 --- /dev/null +++ b/ServicesApi/src/auth/password/reset/reset.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { ResetController } from './reset.controller'; + +describe('ResetController', () => { + let controller: ResetController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [ResetController], + }).compile(); + + controller = module.get(ResetController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/password/reset/reset.controller.ts b/ServicesApi/src/auth/password/reset/reset.controller.ts new file mode 100644 index 0000000..72be6f7 --- /dev/null +++ b/ServicesApi/src/auth/password/reset/reset.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('reset') +export class ResetController {} diff --git a/ServicesApi/src/auth/password/reset/reset.module.ts b/ServicesApi/src/auth/password/reset/reset.module.ts new file mode 100644 index 0000000..e29af49 --- /dev/null +++ b/ServicesApi/src/auth/password/reset/reset.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { ResetService } from './reset.service'; +import { ResetController } from './reset.controller'; + +@Module({ + providers: [ResetService], + controllers: [ResetController] +}) +export class ResetModule {} diff --git a/ServicesApi/src/auth/password/reset/reset.service.spec.ts b/ServicesApi/src/auth/password/reset/reset.service.spec.ts new file mode 100644 index 0000000..de5eac7 --- /dev/null +++ b/ServicesApi/src/auth/password/reset/reset.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { ResetService } from './reset.service'; + +describe('ResetService', () => { + let service: ResetService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [ResetService], + }).compile(); + + service = module.get(ResetService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/password/reset/reset.service.ts b/ServicesApi/src/auth/password/reset/reset.service.ts new file mode 100644 index 0000000..c7c8793 --- /dev/null +++ b/ServicesApi/src/auth/password/reset/reset.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class ResetService {} diff --git a/ServicesApi/src/auth/password/verify-otp/verify-otp.controller.spec.ts b/ServicesApi/src/auth/password/verify-otp/verify-otp.controller.spec.ts new file mode 100644 index 0000000..84a59f8 --- /dev/null +++ b/ServicesApi/src/auth/password/verify-otp/verify-otp.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { VerifyOtpController } from './verify-otp.controller'; + +describe('VerifyOtpController', () => { + let controller: VerifyOtpController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [VerifyOtpController], + }).compile(); + + controller = module.get(VerifyOtpController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/password/verify-otp/verify-otp.controller.ts b/ServicesApi/src/auth/password/verify-otp/verify-otp.controller.ts new file mode 100644 index 0000000..3251806 --- /dev/null +++ b/ServicesApi/src/auth/password/verify-otp/verify-otp.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('verify-otp') +export class VerifyOtpController {} diff --git a/ServicesApi/src/auth/password/verify-otp/verify-otp.module.ts b/ServicesApi/src/auth/password/verify-otp/verify-otp.module.ts new file mode 100644 index 0000000..2d15f5a --- /dev/null +++ b/ServicesApi/src/auth/password/verify-otp/verify-otp.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { VerifyOtpService } from './verify-otp.service'; +import { VerifyOtpController } from './verify-otp.controller'; + +@Module({ + providers: [VerifyOtpService], + controllers: [VerifyOtpController] +}) +export class VerifyOtpModule {} diff --git a/ServicesApi/src/auth/password/verify-otp/verify-otp.service.spec.ts b/ServicesApi/src/auth/password/verify-otp/verify-otp.service.spec.ts new file mode 100644 index 0000000..e7f6722 --- /dev/null +++ b/ServicesApi/src/auth/password/verify-otp/verify-otp.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { VerifyOtpService } from './verify-otp.service'; + +describe('VerifyOtpService', () => { + let service: VerifyOtpService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [VerifyOtpService], + }).compile(); + + service = module.get(VerifyOtpService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/password/verify-otp/verify-otp.service.ts b/ServicesApi/src/auth/password/verify-otp/verify-otp.service.ts new file mode 100644 index 0000000..27d1338 --- /dev/null +++ b/ServicesApi/src/auth/password/verify-otp/verify-otp.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class VerifyOtpService {} diff --git a/ServicesApi/src/auth/select/select.controller.spec.ts b/ServicesApi/src/auth/select/select.controller.spec.ts new file mode 100644 index 0000000..37b94d8 --- /dev/null +++ b/ServicesApi/src/auth/select/select.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { SelectController } from './select.controller'; + +describe('SelectController', () => { + let controller: SelectController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [SelectController], + }).compile(); + + controller = module.get(SelectController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/select/select.controller.ts b/ServicesApi/src/auth/select/select.controller.ts new file mode 100644 index 0000000..cce3a45 --- /dev/null +++ b/ServicesApi/src/auth/select/select.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('select') +export class SelectController {} diff --git a/ServicesApi/src/auth/select/select.module.ts b/ServicesApi/src/auth/select/select.module.ts new file mode 100644 index 0000000..dbf9fe3 --- /dev/null +++ b/ServicesApi/src/auth/select/select.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { SelectController } from './select.controller'; +import { SelectService } from './select.service'; + +@Module({ + controllers: [SelectController], + providers: [SelectService] +}) +export class SelectModule {} diff --git a/ServicesApi/src/auth/select/select.service.spec.ts b/ServicesApi/src/auth/select/select.service.spec.ts new file mode 100644 index 0000000..ab0e81f --- /dev/null +++ b/ServicesApi/src/auth/select/select.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { SelectService } from './select.service'; + +describe('SelectService', () => { + let service: SelectService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [SelectService], + }).compile(); + + service = module.get(SelectService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/select/select.service.ts b/ServicesApi/src/auth/select/select.service.ts new file mode 100644 index 0000000..84595c0 --- /dev/null +++ b/ServicesApi/src/auth/select/select.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class SelectService {} diff --git a/ServicesApi/src/auth/token/check/check.controller.spec.ts b/ServicesApi/src/auth/token/check/check.controller.spec.ts new file mode 100644 index 0000000..5753bc5 --- /dev/null +++ b/ServicesApi/src/auth/token/check/check.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { CheckController } from './check.controller'; + +describe('CheckController', () => { + let controller: CheckController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [CheckController], + }).compile(); + + controller = module.get(CheckController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/token/check/check.controller.ts b/ServicesApi/src/auth/token/check/check.controller.ts new file mode 100644 index 0000000..1ef8045 --- /dev/null +++ b/ServicesApi/src/auth/token/check/check.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('check') +export class CheckController {} diff --git a/ServicesApi/src/auth/token/check/check.module.ts b/ServicesApi/src/auth/token/check/check.module.ts new file mode 100644 index 0000000..75e50d9 --- /dev/null +++ b/ServicesApi/src/auth/token/check/check.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { CheckService } from './check.service'; +import { CheckController } from './check.controller'; + +@Module({ + providers: [CheckService], + controllers: [CheckController] +}) +export class CheckModule {} diff --git a/ServicesApi/src/auth/token/check/check.service.spec.ts b/ServicesApi/src/auth/token/check/check.service.spec.ts new file mode 100644 index 0000000..20e646b --- /dev/null +++ b/ServicesApi/src/auth/token/check/check.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { CheckService } from './check.service'; + +describe('CheckService', () => { + let service: CheckService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [CheckService], + }).compile(); + + service = module.get(CheckService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/token/check/check.service.ts b/ServicesApi/src/auth/token/check/check.service.ts new file mode 100644 index 0000000..a799f8b --- /dev/null +++ b/ServicesApi/src/auth/token/check/check.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class CheckService {} diff --git a/ServicesApi/src/auth/token/refresh/refresh.controller.spec.ts b/ServicesApi/src/auth/token/refresh/refresh.controller.spec.ts new file mode 100644 index 0000000..dc100c7 --- /dev/null +++ b/ServicesApi/src/auth/token/refresh/refresh.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { RefreshController } from './refresh.controller'; + +describe('RefreshController', () => { + let controller: RefreshController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [RefreshController], + }).compile(); + + controller = module.get(RefreshController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/token/refresh/refresh.controller.ts b/ServicesApi/src/auth/token/refresh/refresh.controller.ts new file mode 100644 index 0000000..333c723 --- /dev/null +++ b/ServicesApi/src/auth/token/refresh/refresh.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('refresh') +export class RefreshController {} diff --git a/ServicesApi/src/auth/token/refresh/refresh.module.ts b/ServicesApi/src/auth/token/refresh/refresh.module.ts new file mode 100644 index 0000000..cc2113c --- /dev/null +++ b/ServicesApi/src/auth/token/refresh/refresh.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { RefreshService } from './refresh.service'; +import { RefreshController } from './refresh.controller'; + +@Module({ + providers: [RefreshService], + controllers: [RefreshController] +}) +export class RefreshModule {} diff --git a/ServicesApi/src/auth/token/refresh/refresh.service.spec.ts b/ServicesApi/src/auth/token/refresh/refresh.service.spec.ts new file mode 100644 index 0000000..bf17744 --- /dev/null +++ b/ServicesApi/src/auth/token/refresh/refresh.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { RefreshService } from './refresh.service'; + +describe('RefreshService', () => { + let service: RefreshService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [RefreshService], + }).compile(); + + service = module.get(RefreshService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/token/refresh/refresh.service.ts b/ServicesApi/src/auth/token/refresh/refresh.service.ts new file mode 100644 index 0000000..db53e85 --- /dev/null +++ b/ServicesApi/src/auth/token/refresh/refresh.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class RefreshService {} diff --git a/ServicesApi/src/auth/token/token.controller.spec.ts b/ServicesApi/src/auth/token/token.controller.spec.ts new file mode 100644 index 0000000..823fa44 --- /dev/null +++ b/ServicesApi/src/auth/token/token.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { TokenController } from './token.controller'; + +describe('TokenController', () => { + let controller: TokenController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [TokenController], + }).compile(); + + controller = module.get(TokenController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/token/token.controller.ts b/ServicesApi/src/auth/token/token.controller.ts new file mode 100644 index 0000000..522074c --- /dev/null +++ b/ServicesApi/src/auth/token/token.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('token') +export class TokenController {} diff --git a/ServicesApi/src/auth/token/token.module.ts b/ServicesApi/src/auth/token/token.module.ts new file mode 100644 index 0000000..cb54827 --- /dev/null +++ b/ServicesApi/src/auth/token/token.module.ts @@ -0,0 +1,12 @@ +import { Module } from '@nestjs/common'; +import { TokenService } from './token.service'; +import { TokenController } from './token.controller'; +import { CheckModule } from './check/check.module'; +import { RefreshModule } from './refresh/refresh.module'; + +@Module({ + providers: [TokenService], + controllers: [TokenController], + imports: [CheckModule, RefreshModule], +}) +export class TokenModule {} diff --git a/ServicesApi/src/auth/token/token.service.spec.ts b/ServicesApi/src/auth/token/token.service.spec.ts new file mode 100644 index 0000000..a5f5d65 --- /dev/null +++ b/ServicesApi/src/auth/token/token.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { TokenService } from './token.service'; + +describe('TokenService', () => { + let service: TokenService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [TokenService], + }).compile(); + + service = module.get(TokenService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/ServicesApi/src/auth/token/token.service.ts b/ServicesApi/src/auth/token/token.service.ts new file mode 100644 index 0000000..3f45ce4 --- /dev/null +++ b/ServicesApi/src/auth/token/token.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class TokenService {} diff --git a/ServicesApi/src/cache.service.ts b/ServicesApi/src/cache.service.ts new file mode 100644 index 0000000..839dbb1 --- /dev/null +++ b/ServicesApi/src/cache.service.ts @@ -0,0 +1,102 @@ +import { Injectable } from '@nestjs/common'; +import { RedisService } from '@liaoliaots/nestjs-redis'; +import Redis from 'ioredis'; + +@Injectable() +export class CacheService { + private client: Redis; + + constructor(private readonly redisService: RedisService) { + this.client = this.redisService.getOrThrow(); + } + + async set(key: string, value: any) { + await this.client.set(key, JSON.stringify(value)); + } + + async get(key: string): Promise { + const value = await this.client.get(key); + if (!value) { + return null; + } + return JSON.parse(value); + } + + async get_with_keys(listKeys: (string | null)[]): Promise { + const joinKeys = this.createRegexPattern(listKeys); + const value = await this.client.get(joinKeys); + if (!value) { + return null; + } + return JSON.parse(value); + } + + async set_with_ttl(key: string, value: any, ttl: number) { + await this.client.set(key, JSON.stringify(value), 'EX', ttl); + } + + async check_ttl(key: string): Promise { + return this.client.ttl(key); + } + + async delete(key: string): Promise { + const deleted = await this.client.del(key); + if (deleted === 0) { + return false; + } + return true; + } + + /** + * Delete multiple keys matching a pattern. + * Simplified version that just returns the count of deleted keys. + * + * @param listKeys - List of key components to form pattern for deletion. + * @returns Number of deleted keys + */ + async deleteMultiple(listKeys: (string | null)[]): Promise { + const regex = this.createRegexPattern(listKeys); + const keys: string[] = []; + let cursor = '0'; + + do { + const [nextCursor, matchedKeys] = await this.client.scan( + cursor, + 'MATCH', + regex, + ); + cursor = nextCursor; + keys.push(...matchedKeys); + } while (cursor !== '0'); + + if (keys.length === 0) { + return 0; + } + + let deletedCount = 0; + for (const key of keys) { + const result = await this.client.del(key); + deletedCount += result; + } + return deletedCount; + } + + /** + * Create a regex pattern from list of keys + * This is a simplified implementation - adjust according to your needs + */ + /** + * Create a regex pattern from list of keys + * Replaces null/undefined values with '*' wildcards + * @param listKeys Array of key components, can contain null/undefined values + * @returns Redis pattern string with wildcards + */ + createRegexPattern(listKeys: (string | null)[]): string { + return listKeys.map((key) => (key === null ? '*' : key)).join(':') + '*'; + } + + async check(key: string): Promise { + const exists = await this.client.exists(key); + return exists === 1; + } +} diff --git a/ServicesApi/src/middleware/logger.middleware.ts b/ServicesApi/src/middleware/logger.middleware.ts new file mode 100644 index 0000000..670925a --- /dev/null +++ b/ServicesApi/src/middleware/logger.middleware.ts @@ -0,0 +1,10 @@ +import { Injectable, NestMiddleware } from '@nestjs/common'; +import { Request, Response, NextFunction } from 'express'; + +@Injectable() +export class LoggerMiddleware implements NestMiddleware { + use(req: Request, res: Response, next: NextFunction) { + console.log(`[LoggerMiddleware] ${req.method} ${req.originalUrl}`); + next(); + } +} diff --git a/ServicesApi/prisma.service.ts b/ServicesApi/src/prisma.service.ts similarity index 100% rename from ServicesApi/prisma.service.ts rename to ServicesApi/src/prisma.service.ts diff --git a/ServicesApi/src/types/auth/token.ts b/ServicesApi/src/types/auth/token.ts new file mode 100644 index 0000000..f32d8c8 --- /dev/null +++ b/ServicesApi/src/types/auth/token.ts @@ -0,0 +1,90 @@ +// Token type redis base TOKEN object + +enum UserType { + employee = 1, + occupant = 2, +} + +interface Credentials { + person_id: number; + person_name: string; +} + +interface ApplicationToken { + // Application Token Object -> is the main object for the user + user_type: number; + credential_token: string; + user_uu_id: string; + user_id: number; + person_id: number; + person_uu_id: string; + request?: Record; // Request Info of Client + expires_at?: number; // Expiry timestamp + reachable_event_codes?: Record; // ID list of reachable event codes as "endpoint_code": ["UUID", "UUID"] + reachable_app_codes?: Record; // ID list of reachable applications as "page_url": ["UUID", "UUID"] +} + +interface OccupantToken { + // Selection of the occupant type for a build part is made by the user + living_space_id: number; // Internal use + living_space_uu_id: string; // Outer use + occupant_type_id: number; + occupant_type_uu_id: string; + occupant_type: string; + build_id: number; + build_uuid: string; + build_part_id: number; + build_part_uuid: string; + responsible_company_id?: number; + responsible_company_uuid?: string; + responsible_employee_id?: number; + responsible_employee_uuid?: string; +} + +interface CompanyToken { + // Selection of the company for an employee is made by the user + company_id: number; + company_uu_id: string; + department_id: number; // ID list of departments + department_uu_id: string; // UUID list of departments + duty_id: number; + duty_uu_id: string; + staff_id: number; + staff_uu_id: string; + employee_id: number; + employee_uu_id: string; + bulk_duties_id: number; +} + +interface OccupantTokenObject extends ApplicationToken { + // Occupant Token Object -> Requires selection of the occupant type for a specific build part + available_occupants: Record | null; + selected?: Record; // Selected Occupant Type + is_employee: boolean; // Always false + is_occupant: boolean; // Always true +} + +interface EmployeeTokenObject extends ApplicationToken { + // Full hierarchy Employee[staff_id] -> Staff -> Duty -> Department -> Company + companies_id_list: number[]; // List of company objects + companies_uu_id_list: string[]; // UUID list of company objects + duty_id_list: number[]; // List of duty objects + duty_uu_id_list: string[]; // UUID list of duty objects + selected?: Record; // Selected Company Object + is_employee: boolean; // Always true + is_occupant: boolean; // Always false +} + +// Union type for token objects +type TokenDictType = EmployeeTokenObject | OccupantTokenObject; + +export { + UserType, + Credentials, + ApplicationToken, + OccupantToken, + CompanyToken, + OccupantTokenObject, + EmployeeTokenObject, + TokenDictType, +}; diff --git a/ServicesApi/src/users/cluster/utils.ts b/ServicesApi/src/users/cluster/utils.ts new file mode 100644 index 0000000..0f50aa7 --- /dev/null +++ b/ServicesApi/src/users/cluster/utils.ts @@ -0,0 +1,3 @@ +export function processUsers(): void { + console.log('Processing users New...'); +} diff --git a/ServicesApi/src/users/users.controller.ts b/ServicesApi/src/users/users.controller.ts index 1e32b84..da51c78 100644 --- a/ServicesApi/src/users/users.controller.ts +++ b/ServicesApi/src/users/users.controller.ts @@ -6,39 +6,17 @@ import { Delete, Param, Body, + HttpCode, } from '@nestjs/common'; import { UsersService } from './users.service'; -import { User } from '@prisma/client'; @Controller('users') export class UsersController { constructor(private usersService: UsersService) {} - @Get() - async findAll(): Promise { - return this.usersService.findAll(); - } - - @Get(':id') - async findOne(@Param('id') id: string): Promise { - return this.usersService.findOne(Number(id)); - } - - @Post() - async create(@Body() data: { name: string; email: string }): Promise { - return this.usersService.create(data); - } - - @Put(':id') - async update( - @Param('id') id: string, - @Body() data: Partial<{ name: string; email: string }>, - ): Promise { - return this.usersService.update(Number(id), data); - } - - @Delete(':id') - async remove(@Param('id') id: string): Promise { - return this.usersService.remove(Number(id)); + @Post('filter') + @HttpCode(200) + async filterUsers(@Body() query: any) { + return this.usersService.findWithPagination(query); } } diff --git a/ServicesApi/src/users/users.module.ts b/ServicesApi/src/users/users.module.ts index 9494b5b..d901b58 100644 --- a/ServicesApi/src/users/users.module.ts +++ b/ServicesApi/src/users/users.module.ts @@ -2,10 +2,12 @@ import { Module } from '@nestjs/common'; import { UsersService } from './users.service'; import { UsersController } from './users.controller'; import { PrismaModule } from '@/prisma/prisma.module'; +import { CacheService } from '../cache.service'; +import { UtilsModule } from '../utils/utils.module'; @Module({ - imports: [PrismaModule], - providers: [UsersService], + imports: [PrismaModule, UtilsModule], + providers: [UsersService, CacheService], controllers: [UsersController], exports: [UsersService], }) diff --git a/ServicesApi/src/users/users.service.spec.ts b/ServicesApi/src/users/users.service.spec.ts index d18574a..d128b0e 100644 --- a/ServicesApi/src/users/users.service.spec.ts +++ b/ServicesApi/src/users/users.service.spec.ts @@ -1,31 +1,28 @@ import { Injectable } from '@nestjs/common'; -import { PrismaService } from '@/prisma.service'; -import { User } from '@prisma/client'; +import { PrismaService } from '@/src/prisma.service'; +import { users } from '@prisma/client'; @Injectable() export class UsersService { constructor(private prisma: PrismaService) {} - async findAll(): Promise { - return this.prisma.user.findMany(); + async findAll(): Promise { + return this.prisma.users.findMany(); } - async findOne(id: number): Promise { - return this.prisma.user.findUnique({ where: { id } }); + async findOne(id: number): Promise { + return this.prisma.users.findUnique({ where: { id } }); } - async create(data: { name: string; email: string }): Promise { - return this.prisma.user.create({ data }); + async create(data: any): Promise { + return this.prisma.users.create({ data }); } - async update( - id: number, - data: Partial<{ name: string; email: string }>, - ): Promise { - return this.prisma.user.update({ where: { id }, data }); + async update(id: number, data: any): Promise { + return this.prisma.users.update({ where: { id }, data }); } - async remove(id: number): Promise { - return this.prisma.user.delete({ where: { id } }); + async remove(id: number): Promise { + return this.prisma.users.delete({ where: { id } }); } } diff --git a/ServicesApi/src/users/users.service.ts b/ServicesApi/src/users/users.service.ts index d18574a..9182d09 100644 --- a/ServicesApi/src/users/users.service.ts +++ b/ServicesApi/src/users/users.service.ts @@ -1,31 +1,42 @@ import { Injectable } from '@nestjs/common'; -import { PrismaService } from '@/prisma.service'; -import { User } from '@prisma/client'; +import { PrismaService } from '@/src/prisma.service'; +import { Prisma, users } from '@prisma/client'; +import { CacheService } from '../cache.service'; +import { PaginationHelper, PaginationInfo } from '../utils/pagination-helper'; @Injectable() export class UsersService { - constructor(private prisma: PrismaService) {} + constructor( + private prisma: PrismaService, + private cacheService: CacheService, + private paginationHelper: PaginationHelper, + ) {} - async findAll(): Promise { - return this.prisma.user.findMany(); + async findAll(filter: any): Promise[]> { + return this.prisma.users.findMany({ + where: { ...filter }, + }); } - async findOne(id: number): Promise { - return this.prisma.user.findUnique({ where: { id } }); + async findDynamic( + query: Prisma.usersFindManyArgs, + ): Promise<{ totalCount: number; result: Partial[] }> { + const totalCount = await this.prisma.users.count({ + where: query.where, + }); + const result = await this.prisma.users.findMany(query); + return { totalCount, result }; } - async create(data: { name: string; email: string }): Promise { - return this.prisma.user.create({ data }); + async findWithPagination( + query: any & { page?: number; pageSize?: number }, + ): Promise<{ data: any[]; pagination: PaginationInfo }> { + return this.paginationHelper.paginate(this.prisma.users, query); } - async update( - id: number, - data: Partial<{ name: string; email: string }>, - ): Promise { - return this.prisma.user.update({ where: { id }, data }); - } - - async remove(id: number): Promise { - return this.prisma.user.delete({ where: { id } }); + async findOne(uuid: string): Promise | null> { + return this.prisma.users.findUnique({ + where: { uu_id: uuid }, + }); } } diff --git a/ServicesApi/src/utils/auth/login_handler.ts b/ServicesApi/src/utils/auth/login_handler.ts new file mode 100644 index 0000000..6533624 --- /dev/null +++ b/ServicesApi/src/utils/auth/login_handler.ts @@ -0,0 +1,65 @@ +import crypto from 'crypto'; +import { v4 as uuidv4 } from 'uuid'; + +interface TokenConfig { + ACCESS_TOKEN_LENGTH: number; + REFRESHER_TOKEN_LENGTH: number; +} + +const tokenConfig: TokenConfig = { + ACCESS_TOKEN_LENGTH: 64, + REFRESHER_TOKEN_LENGTH: 128, +}; + +class PasswordHandlers { + generate_random_uu_id(is_string: boolean = true): string { + return is_string ? uuidv4().toString() : uuidv4(); + } + + create_hashed_password( + domain: string, + uuid: string, + password: string, + ): string { + const data = `${domain}:${uuid}:${password}`; + return crypto.createHash('sha256').update(data).digest('hex'); + } + + check_password( + domain: string, + uuid: string, + password: string, + hashed_password: string, + ): boolean { + return ( + this.create_hashed_password(domain, uuid, password) === hashed_password + ); + } + + generateAccessToken(): string { + return this.generateToken(tokenConfig.ACCESS_TOKEN_LENGTH); + } + + generateRefreshToken(): string { + return this.generateToken(tokenConfig.REFRESHER_TOKEN_LENGTH); + } + + generateToken(length: number): string { + const letters = 'abcdefghijklmnopqrstuvwxyz'; + const mergedLetters = [...letters, ...letters.toUpperCase().split('')]; + let token = crypto.randomBytes(length).toString('base64url'); + + token = token + .split('') + .map((char) => + mergedLetters.includes(char) + ? char + : mergedLetters[Math.floor(Math.random() * mergedLetters.length)], + ) + .join(''); + + return token; + } +} + +export { PasswordHandlers }; diff --git a/ServicesApi/src/utils/auth/redis_handlers.ts b/ServicesApi/src/utils/auth/redis_handlers.ts new file mode 100644 index 0000000..f341d4f --- /dev/null +++ b/ServicesApi/src/utils/auth/redis_handlers.ts @@ -0,0 +1,124 @@ +import { + TokenDictType, + OccupantTokenObject, + EmployeeTokenObject, + UserType, +} from '@/src/types/auth/token'; +import { CacheService } from '@/src/cache.service'; +import { users } from '@prisma/client'; +import { PasswordHandlers } from './login_handler'; +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class RedisHandlers { + AUTH_TOKEN = 'AUTH_TOKEN'; + constructor( + private readonly cacheService: CacheService, + private readonly passwordService: PasswordHandlers, + ) { + this.cacheService = cacheService; + this.passwordService = passwordService; + } + + async process_redis_object(redis_object: any): Promise { + if (!redis_object) { + throw new Error('Invalid Redis object: Object is null or undefined'); + } + if (redis_object.user_type === UserType.employee) { + const validateEmployeeToken = (obj: any): obj is EmployeeTokenObject => { + return ( + typeof obj === 'object' && + obj !== null && + typeof obj.user_type === 'number' && + typeof obj.user_uu_id === 'string' && + typeof obj.user_id === 'number' && + typeof obj.person_id === 'number' && + typeof obj.person_uu_id === 'string' && + Array.isArray(obj.companies_id_list) && + Array.isArray(obj.companies_uu_id_list) && + Array.isArray(obj.duty_id_list) && + Array.isArray(obj.duty_uu_id_list) + ); + }; + const empToken: EmployeeTokenObject = { + ...redis_object, + is_employee: true, + is_occupant: false, + user_type: UserType.employee, + credential_token: redis_object.credential_token || '', + }; + if (!validateEmployeeToken(empToken)) { + throw new Error( + 'Invalid Redis object: Does not match EmployeeTokenObject interface', + ); + } + return empToken; + } + + if (redis_object.user_type === UserType.occupant) { + const validateOccupantToken = (obj: any): obj is OccupantTokenObject => { + return ( + typeof obj === 'object' && + obj !== null && + typeof obj.user_type === 'number' && + typeof obj.user_uu_id === 'string' && + typeof obj.user_id === 'number' && + typeof obj.person_id === 'number' && + typeof obj.person_uu_id === 'string' + ); + }; + const occToken: OccupantTokenObject = { + ...redis_object, + is_employee: false, + is_occupant: true, + user_type: UserType.occupant, + credential_token: redis_object.credential_token || '', + available_occupants: redis_object.available_occupants || null, + }; + if (!validateOccupantToken(occToken)) { + throw new Error( + 'Invalid Redis object: Does not match OccupantTokenObject interface', + ); + } + return occToken; + } + throw new Error(`Invalid user_type: ${redis_object.user_type}`); + } + + async get_object_from_redis(access_token: string): Promise { + const token = await this.cacheService.get(access_token); + return this.process_redis_object(token); + } + + async set_login_to_redis(user: users, token: TokenDictType): Promise { + const generated_token = this.passwordService.generateAccessToken(); + const listKeys = [this.AUTH_TOKEN, generated_token, user.uu_id]; + await this.cacheService.set_with_ttl( + this.cacheService.createRegexPattern(listKeys), + token, + 60 * 60 * 24, + ); + return generated_token; + } + + async update_token_via_token(token: string, additional: any): Promise { + const listKeys = [this.AUTH_TOKEN, token, '*']; + const accessObject = await this.cacheService.get_with_keys(listKeys); + if (!accessObject) throw new Error('Token not found'); + const processedObject: TokenDictType = + await this.process_redis_object(accessObject); + if (processedObject.is_employee) { + processedObject.selected = additional; + } + if (processedObject.is_occupant) { + processedObject.selected = additional; + } + const listKeysNew = [this.AUTH_TOKEN, token, processedObject.user_uu_id]; + await this.cacheService.set_with_ttl( + this.cacheService.createRegexPattern(listKeysNew), + processedObject, + 60 * 60 * 24, + ); + return token; + } +} diff --git a/ServicesApi/src/utils/auth/users_handlers.ts b/ServicesApi/src/utils/auth/users_handlers.ts new file mode 100644 index 0000000..e69de29 diff --git a/ServicesApi/src/utils/pagination-helper.ts b/ServicesApi/src/utils/pagination-helper.ts new file mode 100644 index 0000000..5e9b931 --- /dev/null +++ b/ServicesApi/src/utils/pagination-helper.ts @@ -0,0 +1,58 @@ +import { Injectable } from '@nestjs/common'; +import { PrismaService } from '@/src/prisma.service'; + +export interface PaginationInfo { + totalCount: number; + page: number; + pageSize: number; + totalPages: number; + hasNextPage: boolean; + hasPreviousPage: boolean; + pageCount: number; +} + +type ModelDelegate = { + count: (args: any) => Promise; + findMany: (args: any) => Promise; +}; + +@Injectable() +export class PaginationHelper { + constructor(private prisma: PrismaService) {} + + /** + * Sayfalama destekli sorgu yapar + * + * @param modelDelegate Prisma model delegesi (ör. prisma.users) + * @param query Prisma findMany argümanları + opsiyonel page, pageSize + * @returns { data, pagination } sonuç ve sayfalama bilgisi + */ + async paginate( + modelDelegate: ModelDelegate, + query: any & { page?: number; pageSize?: number }, + ): Promise<{ data: any[]; pagination: PaginationInfo }> { + const { page = 1, pageSize = 10, ...prismaQuery } = query; + const totalCount = await modelDelegate.count({ where: prismaQuery.where }); + const totalPages = Math.max(Math.ceil(totalCount / pageSize), 1); + const pageNumber = page < 1 ? 1 : page > totalPages ? totalPages : page; + const pageSizeNumber = pageSize > 0 ? pageSize : 10; + const data = await modelDelegate.findMany({ + ...prismaQuery, + skip: (pageNumber - 1) * pageSizeNumber, + take: pageSizeNumber, + }); + const pageCount = data.length; + return { + data, + pagination: { + totalCount, + page: pageNumber, + pageSize: pageSizeNumber, + totalPages, + hasNextPage: pageNumber < totalPages, + hasPreviousPage: pageNumber > 1, + pageCount, + }, + }; + } +} diff --git a/ServicesApi/src/utils/utils.module.ts b/ServicesApi/src/utils/utils.module.ts new file mode 100644 index 0000000..37b14e2 --- /dev/null +++ b/ServicesApi/src/utils/utils.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { PaginationHelper } from './pagination-helper'; +import { PrismaService } from '@/src/prisma.service'; + +@Module({ + providers: [PaginationHelper, PrismaService], + exports: [PaginationHelper], +}) +export class UtilsModule {} diff --git a/ServicesApi/tsconfig.json b/ServicesApi/tsconfig.json index 19f11fc..79dd344 100644 --- a/ServicesApi/tsconfig.json +++ b/ServicesApi/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "types": ["node"], + "typeRoots": ["./node_modules/@types"], "module": "commonjs", "declaration": true, "removeComments": true, diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 62f4113..1267d5e 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -3,7 +3,7 @@ services: container_name: backend_service build: context: . - dockerfile: backend/Dockerfile + dockerfile: ServicesApi/Dockerfile target: builder ports: - "3000:3000" @@ -14,7 +14,7 @@ services: command: npm run start:dev restart: unless-stopped volumes: - - ./backend:/usr/src/app + - ./ServicesApi:/usr/src/app - node_modules:/usr/src/app/node_modules volumes: