efiber-prisma-schema 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -6
- package/{index.js → index.ts} +4 -2
- package/package.json +18 -3
- package/prisma.config.ts +7 -2
- package/.github/workflows/main.yml +0 -84
- package/prisma/migrations_old/20231209164007_/migration.sql +0 -8
- package/prisma/migrations_old/20231209192452_country_table/migration.sql +0 -7
- package/prisma/migrations_old/20231209194848_/migration.sql +0 -10
- package/prisma/migrations_old/20231209195140_/migration.sql +0 -8
- package/prisma/migrations_old/20231209201218_country_update/migration.sql +0 -29
- package/prisma/migrations_old/20231209201405_/migration.sql +0 -8
- package/prisma/migrations_old/20231209213149_camusat_country/migration.sql +0 -20
- package/prisma/migrations_old/20231209221814_platform/migration.sql +0 -26
- package/prisma/migrations_old/20231209223246_/migration.sql +0 -16
- package/prisma/migrations_old/20231209231721_roles/migration.sql +0 -34
- package/prisma/migrations_old/20231210113501_team_and_users/migration.sql +0 -119
- package/prisma/migrations_old/20231210181832_user_update/migration.sql +0 -25
- package/prisma/migrations_old/20231219121311_add_projects/migration.sql +0 -60
- package/prisma/migrations_old/20231219123045_/migration.sql +0 -8
- package/prisma/migrations_old/20231219123850_audit/migration.sql +0 -20
- package/prisma/migrations_old/20240116090035_/migration.sql +0 -57
- package/prisma/migrations_old/20240220085809_emails/migration.sql +0 -82
- package/prisma/migrations_old/20240226075734_update_email_config_and_workorder/migration.sql +0 -33
- package/prisma/migrations_old/20240227112839_update_email_config/migration.sql +0 -2
- package/prisma/migrations_old/20240227124801_work_order_update/migration.sql +0 -6
- package/prisma/migrations_old/20250121073034_homogenize_migrations/migration.sql +0 -2481
- package/prisma/migrations_old/migration_lock.toml +0 -3
- package/prisma/seed.ts +0 -33
- package/tsconfig.json +0 -13
package/index.d.ts
CHANGED
package/{index.js → index.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'dotenv/config'
|
|
2
|
-
import { PrismaClient } from '
|
|
2
|
+
import { PrismaClient, Prisma } from './prisma/generated/client.js'
|
|
3
3
|
import { PrismaPg } from '@prisma/adapter-pg'
|
|
4
4
|
import pg from 'pg'
|
|
5
5
|
|
|
@@ -7,4 +7,6 @@ const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
|
|
|
7
7
|
const adapter = new PrismaPg(pool)
|
|
8
8
|
const prisma = new PrismaClient({ adapter })
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export type * from './prisma/generated/client.js'
|
|
11
|
+
export { Prisma, PrismaClient }
|
|
12
|
+
export { prisma }
|
package/package.json
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "efiber-prisma-schema",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Database schema for eFiber",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "index.
|
|
6
|
+
"main": "index.ts",
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"import": "./index.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"index.ts",
|
|
16
|
+
"index.d.ts",
|
|
17
|
+
"prisma/schema.prisma",
|
|
18
|
+
"prisma/generated/",
|
|
19
|
+
"prisma/migrations/",
|
|
20
|
+
"prisma.config.ts"
|
|
21
|
+
],
|
|
7
22
|
"scripts": {
|
|
8
23
|
"generate": "prisma generate",
|
|
9
|
-
"migrate": "prisma migrate
|
|
24
|
+
"migrate": "prisma migrate deploy",
|
|
10
25
|
"postinstall": "npm run generate"
|
|
11
26
|
},
|
|
12
27
|
"repository": {
|
package/prisma.config.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import 'dotenv/config'
|
|
2
1
|
import { defineConfig, env } from 'prisma/config'
|
|
3
2
|
|
|
3
|
+
try {
|
|
4
|
+
await import('dotenv/config')
|
|
5
|
+
} catch {}
|
|
6
|
+
|
|
7
|
+
const databaseUrl = process.env.DATABASE_URL || ''
|
|
8
|
+
|
|
4
9
|
export default defineConfig({
|
|
5
10
|
schema: 'prisma/schema.prisma',
|
|
6
11
|
migrations: {
|
|
@@ -8,6 +13,6 @@ export default defineConfig({
|
|
|
8
13
|
seed: 'tsx prisma/seed.ts',
|
|
9
14
|
},
|
|
10
15
|
datasource: {
|
|
11
|
-
url:
|
|
16
|
+
url: databaseUrl,
|
|
12
17
|
},
|
|
13
18
|
})
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
name: Run Prisma Migrations
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- development
|
|
7
|
-
- staging
|
|
8
|
-
- main
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
migrate-development:
|
|
12
|
-
if: github.ref == 'refs/heads/development'
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
environment: development
|
|
15
|
-
steps:
|
|
16
|
-
- name: Checkout
|
|
17
|
-
uses: actions/checkout@v4
|
|
18
|
-
|
|
19
|
-
- name: Setup SSH Key
|
|
20
|
-
run: |
|
|
21
|
-
mkdir -p ~/.ssh
|
|
22
|
-
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
|
23
|
-
chmod 600 ~/.ssh/id_rsa
|
|
24
|
-
echo -e "Host *\n StrictHostKeyChecking no\n" > ~/.ssh/config
|
|
25
|
-
|
|
26
|
-
- name: Run Migrations on Development
|
|
27
|
-
run: |
|
|
28
|
-
ssh ${{ secrets.DEVELOPMENT_SSH_USER }}@${{ secrets.DEVELOPMENT_SSH_HOST }} "
|
|
29
|
-
cd efiber-prisma-schema &&
|
|
30
|
-
git reset --hard && git clean -fd && git pull origin development &&
|
|
31
|
-
export PATH=\$PATH:/home/jacob/.nvm/versions/node/v24.7.0/bin &&
|
|
32
|
-
npm ci && npx prisma migrate deploy --schema=./prisma/schema.prisma
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
migrate-staging:
|
|
36
|
-
if: github.ref == 'refs/heads/staging'
|
|
37
|
-
runs-on: ubuntu-latest
|
|
38
|
-
environment: staging
|
|
39
|
-
steps:
|
|
40
|
-
- name: Checkout
|
|
41
|
-
uses: actions/checkout@v4
|
|
42
|
-
|
|
43
|
-
- name: Setup SSH Key
|
|
44
|
-
run: |
|
|
45
|
-
mkdir -p ~/.ssh
|
|
46
|
-
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
|
47
|
-
chmod 600 ~/.ssh/id_rsa
|
|
48
|
-
echo -e "Host *\n StrictHostKeyChecking no\n" > ~/.ssh/config
|
|
49
|
-
|
|
50
|
-
- name: Run Migrations on Staging (via Bastion → Prod → Staging)
|
|
51
|
-
run: |
|
|
52
|
-
ssh -J ${{ secrets.BASTION_USER }}@${{ secrets.BASTION_HOST }},${{ secrets.PRODUCTION_SSH_USER }}@${{ secrets.PRODUCTION_SSH_HOST }} \
|
|
53
|
-
${{ secrets.STAGING_SSH_USER }}@${{ secrets.STAGING_SSH_HOST }} "
|
|
54
|
-
cd efiber-prisma-schema &&
|
|
55
|
-
git reset --hard && git clean -fd && git pull origin staging &&
|
|
56
|
-
export PATH=\$PATH:/home/ubuni/.nvm/versions/node/v24.7.0/bin && npm ci &&
|
|
57
|
-
npx prisma migrate deploy --schema=./prisma/schema.prisma
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
migrate-production:
|
|
61
|
-
if: github.ref == 'refs/heads/main'
|
|
62
|
-
runs-on: ubuntu-latest
|
|
63
|
-
environment: production
|
|
64
|
-
steps:
|
|
65
|
-
- name: Checkout
|
|
66
|
-
uses: actions/checkout@v4
|
|
67
|
-
|
|
68
|
-
- name: Setup SSH Key
|
|
69
|
-
run: |
|
|
70
|
-
mkdir -p ~/.ssh
|
|
71
|
-
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
|
72
|
-
chmod 600 ~/.ssh/id_rsa
|
|
73
|
-
echo -e "Host *\n StrictHostKeyChecking no\n" > ~/.ssh/config
|
|
74
|
-
|
|
75
|
-
- name: Run Migrations on Production (via Bastion)
|
|
76
|
-
run: |
|
|
77
|
-
ssh -J ${{ secrets.BASTION_USER }}@${{ secrets.BASTION_HOST }} \
|
|
78
|
-
${{ secrets.PRODUCTION_SSH_USER }}@${{ secrets.PRODUCTION_SSH_HOST }} "
|
|
79
|
-
cd efiber-prisma-schema &&
|
|
80
|
-
git reset --hard && git clean -fd && git pull origin main &&
|
|
81
|
-
export PATH=\$PATH:/home/ubuni/.nvm/versions/node/v24.7.0/bin && npm ci &&
|
|
82
|
-
npx prisma migrate deploy --schema=./prisma/schema.prisma
|
|
83
|
-
"
|
|
84
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Warnings:
|
|
3
|
-
|
|
4
|
-
- The primary key for the `Country` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
-- AlterTable
|
|
8
|
-
ALTER TABLE "Country" DROP CONSTRAINT "Country_pkey",
|
|
9
|
-
ALTER COLUMN "id" SET DATA TYPE TEXT,
|
|
10
|
-
ADD CONSTRAINT "Country_pkey" PRIMARY KEY ("id");
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Warnings:
|
|
3
|
-
|
|
4
|
-
- Added the required column `capital` to the `Country` table without a default value. This is not possible if the table is not empty.
|
|
5
|
-
- Added the required column `code` to the `Country` table without a default value. This is not possible if the table is not empty.
|
|
6
|
-
- Added the required column `population` to the `Country` table without a default value. This is not possible if the table is not empty.
|
|
7
|
-
- Added the required column `region` to the `Country` table without a default value. This is not possible if the table is not empty.
|
|
8
|
-
- Added the required column `subregion` to the `Country` table without a default value. This is not possible if the table is not empty.
|
|
9
|
-
- Added the required column `timezones` to the `Country` table without a default value. This is not possible if the table is not empty.
|
|
10
|
-
- Added the required column `updatedAt` to the `Country` table without a default value. This is not possible if the table is not empty.
|
|
11
|
-
- Added the required column `updatedAt` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
-- AlterTable
|
|
15
|
-
ALTER TABLE "Country" ADD COLUMN "capital" TEXT NOT NULL,
|
|
16
|
-
ADD COLUMN "code" TEXT NOT NULL,
|
|
17
|
-
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
18
|
-
ADD COLUMN "flag" TEXT,
|
|
19
|
-
ADD COLUMN "population" TEXT NOT NULL,
|
|
20
|
-
ADD COLUMN "region" TEXT NOT NULL,
|
|
21
|
-
ADD COLUMN "subregion" TEXT NOT NULL,
|
|
22
|
-
ADD COLUMN "timezones" TEXT NOT NULL,
|
|
23
|
-
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL;
|
|
24
|
-
|
|
25
|
-
-- AlterTable
|
|
26
|
-
ALTER TABLE "User" ADD COLUMN "activatedAt" TIMESTAMP(3),
|
|
27
|
-
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
28
|
-
ADD COLUMN "deletedAt" TIMESTAMP(3),
|
|
29
|
-
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
-- CreateTable
|
|
2
|
-
CREATE TABLE "CamusatCountry" (
|
|
3
|
-
"id" TEXT NOT NULL,
|
|
4
|
-
"name" TEXT NOT NULL,
|
|
5
|
-
"description" TEXT,
|
|
6
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
7
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
8
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
9
|
-
"activatedAt" TIMESTAMP(3),
|
|
10
|
-
"deletedAt" TIMESTAMP(3),
|
|
11
|
-
"countryId" TEXT NOT NULL,
|
|
12
|
-
|
|
13
|
-
CONSTRAINT "CamusatCountry_pkey" PRIMARY KEY ("id")
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
-- CreateIndex
|
|
17
|
-
CREATE UNIQUE INDEX "CamusatCountry_id_key" ON "CamusatCountry"("id");
|
|
18
|
-
|
|
19
|
-
-- AddForeignKey
|
|
20
|
-
ALTER TABLE "CamusatCountry" ADD CONSTRAINT "CamusatCountry_countryId_fkey" FOREIGN KEY ("countryId") REFERENCES "Country"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Warnings:
|
|
3
|
-
|
|
4
|
-
- You are about to drop the column `activatedAt` on the `CamusatCountry` table. All the data in the column will be lost.
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
-- AlterTable
|
|
8
|
-
ALTER TABLE "CamusatCountry" DROP COLUMN "activatedAt";
|
|
9
|
-
|
|
10
|
-
-- CreateTable
|
|
11
|
-
CREATE TABLE "Platform" (
|
|
12
|
-
"id" TEXT NOT NULL,
|
|
13
|
-
"name" TEXT NOT NULL,
|
|
14
|
-
"url" TEXT,
|
|
15
|
-
"directory" TEXT,
|
|
16
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
17
|
-
"countries" JSONB,
|
|
18
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
19
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
20
|
-
"deletedAt" TIMESTAMP(3),
|
|
21
|
-
|
|
22
|
-
CONSTRAINT "Platform_pkey" PRIMARY KEY ("id")
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
-- CreateIndex
|
|
26
|
-
CREATE UNIQUE INDEX "Platform_id_key" ON "Platform"("id");
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
-- CreateTable
|
|
2
|
-
CREATE TABLE "Position" (
|
|
3
|
-
"id" TEXT NOT NULL,
|
|
4
|
-
"name" TEXT NOT NULL,
|
|
5
|
-
"description" TEXT,
|
|
6
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
7
|
-
"countries" JSONB,
|
|
8
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
9
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
10
|
-
"deletedAt" TIMESTAMP(3),
|
|
11
|
-
|
|
12
|
-
CONSTRAINT "Position_pkey" PRIMARY KEY ("id")
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
-- CreateIndex
|
|
16
|
-
CREATE UNIQUE INDEX "Position_id_key" ON "Position"("id");
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
-- CreateTable
|
|
2
|
-
CREATE TABLE "Role" (
|
|
3
|
-
"id" TEXT NOT NULL,
|
|
4
|
-
"name" TEXT NOT NULL,
|
|
5
|
-
"description" TEXT,
|
|
6
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
7
|
-
"countries" JSONB,
|
|
8
|
-
"platforms" JSONB,
|
|
9
|
-
"login" BOOLEAN NOT NULL DEFAULT false,
|
|
10
|
-
"access_web" BOOLEAN NOT NULL DEFAULT false,
|
|
11
|
-
"access_mobile" BOOLEAN NOT NULL DEFAULT false,
|
|
12
|
-
"add_users" BOOLEAN NOT NULL DEFAULT false,
|
|
13
|
-
"view_users" BOOLEAN NOT NULL DEFAULT false,
|
|
14
|
-
"delete_users" BOOLEAN NOT NULL DEFAULT false,
|
|
15
|
-
"view_requests" BOOLEAN NOT NULL DEFAULT false,
|
|
16
|
-
"manage_requests" BOOLEAN NOT NULL DEFAULT false,
|
|
17
|
-
"full_projects" BOOLEAN NOT NULL DEFAULT false,
|
|
18
|
-
"add_projects" BOOLEAN NOT NULL DEFAULT false,
|
|
19
|
-
"view_projects" BOOLEAN NOT NULL DEFAULT false,
|
|
20
|
-
"add_sub_projects" BOOLEAN NOT NULL DEFAULT false,
|
|
21
|
-
"manage_work_orders" BOOLEAN NOT NULL DEFAULT false,
|
|
22
|
-
"full_teams" BOOLEAN NOT NULL DEFAULT false,
|
|
23
|
-
"add_team" BOOLEAN NOT NULL DEFAULT false,
|
|
24
|
-
"view_team" BOOLEAN NOT NULL DEFAULT false,
|
|
25
|
-
"quality" BOOLEAN NOT NULL DEFAULT false,
|
|
26
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
27
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
28
|
-
"deletedAt" TIMESTAMP(3),
|
|
29
|
-
|
|
30
|
-
CONSTRAINT "Role_pkey" PRIMARY KEY ("id")
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
-- CreateIndex
|
|
34
|
-
CREATE UNIQUE INDEX "Role_id_key" ON "Role"("id");
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Warnings:
|
|
3
|
-
|
|
4
|
-
- You are about to drop the column `pin` on the `User` table. All the data in the column will be lost.
|
|
5
|
-
- You are about to drop the column `username` on the `User` table. All the data in the column will be lost.
|
|
6
|
-
- Added the required column `countryId` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
7
|
-
- Added the required column `email` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
8
|
-
- Added the required column `mobile` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
9
|
-
- Added the required column `name` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
10
|
-
- Added the required column `password` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
11
|
-
- Added the required column `positionId` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
12
|
-
- Added the required column `roleId` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
13
|
-
- Added the required column `surname` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
14
|
-
- Added the required column `teamId` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
15
|
-
- Added the required column `teamTypeId` to the `User` table without a default value. This is not possible if the table is not empty.
|
|
16
|
-
|
|
17
|
-
*/
|
|
18
|
-
-- AlterTable
|
|
19
|
-
ALTER TABLE "User" DROP COLUMN "pin",
|
|
20
|
-
DROP COLUMN "username",
|
|
21
|
-
ADD COLUMN "countries" JSONB,
|
|
22
|
-
ADD COLUMN "countryId" TEXT NOT NULL,
|
|
23
|
-
ADD COLUMN "email" TEXT NOT NULL,
|
|
24
|
-
ADD COLUMN "mobile" TEXT NOT NULL,
|
|
25
|
-
ADD COLUMN "name" TEXT NOT NULL,
|
|
26
|
-
ADD COLUMN "otp" TEXT,
|
|
27
|
-
ADD COLUMN "passport" TEXT,
|
|
28
|
-
ADD COLUMN "passportFile" TEXT,
|
|
29
|
-
ADD COLUMN "password" TEXT NOT NULL,
|
|
30
|
-
ADD COLUMN "platforms" JSONB,
|
|
31
|
-
ADD COLUMN "positionId" TEXT NOT NULL,
|
|
32
|
-
ADD COLUMN "roleId" TEXT NOT NULL,
|
|
33
|
-
ADD COLUMN "status" TEXT NOT NULL DEFAULT 'created',
|
|
34
|
-
ADD COLUMN "surname" TEXT NOT NULL,
|
|
35
|
-
ADD COLUMN "teamId" TEXT NOT NULL,
|
|
36
|
-
ADD COLUMN "teamTypeId" TEXT NOT NULL;
|
|
37
|
-
|
|
38
|
-
-- CreateTable
|
|
39
|
-
CREATE TABLE "TeamType" (
|
|
40
|
-
"id" TEXT NOT NULL,
|
|
41
|
-
"name" TEXT NOT NULL,
|
|
42
|
-
"description" TEXT,
|
|
43
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
44
|
-
"countries" JSONB,
|
|
45
|
-
"platforms" JSONB,
|
|
46
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
47
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
48
|
-
"deletedAt" TIMESTAMP(3),
|
|
49
|
-
|
|
50
|
-
CONSTRAINT "TeamType_pkey" PRIMARY KEY ("id")
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
-- CreateTable
|
|
54
|
-
CREATE TABLE "Team" (
|
|
55
|
-
"id" TEXT NOT NULL,
|
|
56
|
-
"name" TEXT NOT NULL,
|
|
57
|
-
"description" TEXT,
|
|
58
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
59
|
-
"countries" JSONB,
|
|
60
|
-
"platforms" JSONB,
|
|
61
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
62
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
63
|
-
"deletedAt" TIMESTAMP(3),
|
|
64
|
-
"teamTypeId" TEXT NOT NULL,
|
|
65
|
-
|
|
66
|
-
CONSTRAINT "Team_pkey" PRIMARY KEY ("id")
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
-- CreateTable
|
|
70
|
-
CREATE TABLE "TeamPlatform" (
|
|
71
|
-
"id" TEXT NOT NULL,
|
|
72
|
-
"name" TEXT NOT NULL,
|
|
73
|
-
"description" TEXT,
|
|
74
|
-
"priority" TEXT,
|
|
75
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
76
|
-
"countries" JSONB,
|
|
77
|
-
"platforms" JSONB,
|
|
78
|
-
"staffs" JSONB,
|
|
79
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
80
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
81
|
-
"deletedAt" TIMESTAMP(3),
|
|
82
|
-
"teamId" TEXT NOT NULL,
|
|
83
|
-
"userId" INTEGER,
|
|
84
|
-
|
|
85
|
-
CONSTRAINT "TeamPlatform_pkey" PRIMARY KEY ("id")
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
-- CreateIndex
|
|
89
|
-
CREATE UNIQUE INDEX "TeamType_id_key" ON "TeamType"("id");
|
|
90
|
-
|
|
91
|
-
-- CreateIndex
|
|
92
|
-
CREATE UNIQUE INDEX "Team_id_key" ON "Team"("id");
|
|
93
|
-
|
|
94
|
-
-- CreateIndex
|
|
95
|
-
CREATE UNIQUE INDEX "TeamPlatform_id_key" ON "TeamPlatform"("id");
|
|
96
|
-
|
|
97
|
-
-- AddForeignKey
|
|
98
|
-
ALTER TABLE "Team" ADD CONSTRAINT "Team_teamTypeId_fkey" FOREIGN KEY ("teamTypeId") REFERENCES "TeamType"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
99
|
-
|
|
100
|
-
-- AddForeignKey
|
|
101
|
-
ALTER TABLE "TeamPlatform" ADD CONSTRAINT "TeamPlatform_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
102
|
-
|
|
103
|
-
-- AddForeignKey
|
|
104
|
-
ALTER TABLE "TeamPlatform" ADD CONSTRAINT "TeamPlatform_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
105
|
-
|
|
106
|
-
-- AddForeignKey
|
|
107
|
-
ALTER TABLE "User" ADD CONSTRAINT "User_positionId_fkey" FOREIGN KEY ("positionId") REFERENCES "Position"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
108
|
-
|
|
109
|
-
-- AddForeignKey
|
|
110
|
-
ALTER TABLE "User" ADD CONSTRAINT "User_teamTypeId_fkey" FOREIGN KEY ("teamTypeId") REFERENCES "TeamType"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
111
|
-
|
|
112
|
-
-- AddForeignKey
|
|
113
|
-
ALTER TABLE "User" ADD CONSTRAINT "User_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
114
|
-
|
|
115
|
-
-- AddForeignKey
|
|
116
|
-
ALTER TABLE "User" ADD CONSTRAINT "User_countryId_fkey" FOREIGN KEY ("countryId") REFERENCES "Country"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
117
|
-
|
|
118
|
-
-- AddForeignKey
|
|
119
|
-
ALTER TABLE "User" ADD CONSTRAINT "User_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES "Role"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Warnings:
|
|
3
|
-
|
|
4
|
-
- The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
|
5
|
-
- A unique constraint covering the columns `[id]` on the table `User` will be added. If there are existing duplicate values, this will fail.
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
-- DropForeignKey
|
|
9
|
-
ALTER TABLE "TeamPlatform" DROP CONSTRAINT "TeamPlatform_userId_fkey";
|
|
10
|
-
|
|
11
|
-
-- AlterTable
|
|
12
|
-
ALTER TABLE "TeamPlatform" ALTER COLUMN "userId" SET DATA TYPE TEXT;
|
|
13
|
-
|
|
14
|
-
-- AlterTable
|
|
15
|
-
ALTER TABLE "User" DROP CONSTRAINT "User_pkey",
|
|
16
|
-
ALTER COLUMN "id" DROP DEFAULT,
|
|
17
|
-
ALTER COLUMN "id" SET DATA TYPE TEXT,
|
|
18
|
-
ADD CONSTRAINT "User_pkey" PRIMARY KEY ("id");
|
|
19
|
-
DROP SEQUENCE "User_id_seq";
|
|
20
|
-
|
|
21
|
-
-- CreateIndex
|
|
22
|
-
CREATE UNIQUE INDEX "User_id_key" ON "User"("id");
|
|
23
|
-
|
|
24
|
-
-- AddForeignKey
|
|
25
|
-
ALTER TABLE "TeamPlatform" ADD CONSTRAINT "TeamPlatform_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
-- DropForeignKey
|
|
2
|
-
ALTER TABLE "User" DROP CONSTRAINT "User_countryId_fkey";
|
|
3
|
-
|
|
4
|
-
-- DropForeignKey
|
|
5
|
-
ALTER TABLE "User" DROP CONSTRAINT "User_positionId_fkey";
|
|
6
|
-
|
|
7
|
-
-- DropForeignKey
|
|
8
|
-
ALTER TABLE "User" DROP CONSTRAINT "User_roleId_fkey";
|
|
9
|
-
|
|
10
|
-
-- DropForeignKey
|
|
11
|
-
ALTER TABLE "User" DROP CONSTRAINT "User_teamId_fkey";
|
|
12
|
-
|
|
13
|
-
-- DropForeignKey
|
|
14
|
-
ALTER TABLE "User" DROP CONSTRAINT "User_teamTypeId_fkey";
|
|
15
|
-
|
|
16
|
-
-- AlterTable
|
|
17
|
-
ALTER TABLE "User" ALTER COLUMN "countryId" DROP NOT NULL,
|
|
18
|
-
ALTER COLUMN "positionId" DROP NOT NULL,
|
|
19
|
-
ALTER COLUMN "roleId" DROP NOT NULL,
|
|
20
|
-
ALTER COLUMN "teamId" DROP NOT NULL,
|
|
21
|
-
ALTER COLUMN "teamTypeId" DROP NOT NULL;
|
|
22
|
-
|
|
23
|
-
-- CreateTable
|
|
24
|
-
CREATE TABLE "Project" (
|
|
25
|
-
"id" TEXT NOT NULL,
|
|
26
|
-
"name" TEXT NOT NULL,
|
|
27
|
-
"client" TEXT NOT NULL,
|
|
28
|
-
"logo" TEXT,
|
|
29
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
30
|
-
"countries" JSONB,
|
|
31
|
-
"platforms" JSONB,
|
|
32
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
33
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
34
|
-
"activatedAt" TIMESTAMP(3),
|
|
35
|
-
"deletedAt" TIMESTAMP(3),
|
|
36
|
-
"userId" TEXT NOT NULL,
|
|
37
|
-
|
|
38
|
-
CONSTRAINT "Project_pkey" PRIMARY KEY ("id")
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
-- CreateIndex
|
|
42
|
-
CREATE UNIQUE INDEX "Project_id_key" ON "Project"("id");
|
|
43
|
-
|
|
44
|
-
-- AddForeignKey
|
|
45
|
-
ALTER TABLE "User" ADD CONSTRAINT "User_positionId_fkey" FOREIGN KEY ("positionId") REFERENCES "Position"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
46
|
-
|
|
47
|
-
-- AddForeignKey
|
|
48
|
-
ALTER TABLE "User" ADD CONSTRAINT "User_teamTypeId_fkey" FOREIGN KEY ("teamTypeId") REFERENCES "TeamType"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
49
|
-
|
|
50
|
-
-- AddForeignKey
|
|
51
|
-
ALTER TABLE "User" ADD CONSTRAINT "User_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
52
|
-
|
|
53
|
-
-- AddForeignKey
|
|
54
|
-
ALTER TABLE "User" ADD CONSTRAINT "User_countryId_fkey" FOREIGN KEY ("countryId") REFERENCES "Country"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
55
|
-
|
|
56
|
-
-- AddForeignKey
|
|
57
|
-
ALTER TABLE "User" ADD CONSTRAINT "User_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES "Role"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
58
|
-
|
|
59
|
-
-- AddForeignKey
|
|
60
|
-
ALTER TABLE "Project" ADD CONSTRAINT "Project_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
-- DropForeignKey
|
|
2
|
-
ALTER TABLE "Project" DROP CONSTRAINT "Project_userId_fkey";
|
|
3
|
-
|
|
4
|
-
-- AlterTable
|
|
5
|
-
ALTER TABLE "Project" ALTER COLUMN "userId" DROP NOT NULL;
|
|
6
|
-
|
|
7
|
-
-- AddForeignKey
|
|
8
|
-
ALTER TABLE "Project" ADD CONSTRAINT "Project_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
-- CreateTable
|
|
2
|
-
CREATE TABLE "Audit" (
|
|
3
|
-
"id" SERIAL NOT NULL,
|
|
4
|
-
"module" TEXT NOT NULL,
|
|
5
|
-
"moduleId" INTEGER,
|
|
6
|
-
"activity" TEXT NOT NULL,
|
|
7
|
-
"detail" TEXT,
|
|
8
|
-
"device" TEXT,
|
|
9
|
-
"deviceIp" TEXT,
|
|
10
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
11
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
12
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
13
|
-
"deletedAt" TIMESTAMP(3),
|
|
14
|
-
"userId" TEXT,
|
|
15
|
-
|
|
16
|
-
CONSTRAINT "Audit_pkey" PRIMARY KEY ("id")
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
-- AddForeignKey
|
|
20
|
-
ALTER TABLE "Audit" ADD CONSTRAINT "Audit_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
-- CreateTable
|
|
2
|
-
CREATE TABLE "DispatchTeam" (
|
|
3
|
-
"id" TEXT NOT NULL,
|
|
4
|
-
"name" TEXT,
|
|
5
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
6
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
7
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
8
|
-
"deletedAt" TIMESTAMP(3),
|
|
9
|
-
"leadTechnicianId" TEXT NOT NULL,
|
|
10
|
-
"firstTechnicianId" TEXT,
|
|
11
|
-
"secondTechnicianId" TEXT,
|
|
12
|
-
"otherTechnicianId" TEXT,
|
|
13
|
-
|
|
14
|
-
CONSTRAINT "DispatchTeam_pkey" PRIMARY KEY ("id")
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
-- CreateTable
|
|
18
|
-
CREATE TABLE "DispatchProject" (
|
|
19
|
-
"id" TEXT NOT NULL,
|
|
20
|
-
"name" TEXT NOT NULL,
|
|
21
|
-
"type" TEXT NOT NULL,
|
|
22
|
-
"teams" JSONB,
|
|
23
|
-
"logo" TEXT,
|
|
24
|
-
"status" TEXT NOT NULL DEFAULT 'active',
|
|
25
|
-
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
26
|
-
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
27
|
-
"activatedAt" TIMESTAMP(3),
|
|
28
|
-
"deletedAt" TIMESTAMP(3),
|
|
29
|
-
"userId" TEXT,
|
|
30
|
-
"projectId" TEXT,
|
|
31
|
-
|
|
32
|
-
CONSTRAINT "DispatchProject_pkey" PRIMARY KEY ("id")
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
-- CreateIndex
|
|
36
|
-
CREATE UNIQUE INDEX "DispatchTeam_id_key" ON "DispatchTeam"("id");
|
|
37
|
-
|
|
38
|
-
-- CreateIndex
|
|
39
|
-
CREATE UNIQUE INDEX "DispatchProject_id_key" ON "DispatchProject"("id");
|
|
40
|
-
|
|
41
|
-
-- AddForeignKey
|
|
42
|
-
ALTER TABLE "DispatchTeam" ADD CONSTRAINT "DispatchTeam_leadTechnicianId_fkey" FOREIGN KEY ("leadTechnicianId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
43
|
-
|
|
44
|
-
-- AddForeignKey
|
|
45
|
-
ALTER TABLE "DispatchTeam" ADD CONSTRAINT "DispatchTeam_firstTechnicianId_fkey" FOREIGN KEY ("firstTechnicianId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
46
|
-
|
|
47
|
-
-- AddForeignKey
|
|
48
|
-
ALTER TABLE "DispatchTeam" ADD CONSTRAINT "DispatchTeam_secondTechnicianId_fkey" FOREIGN KEY ("secondTechnicianId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
49
|
-
|
|
50
|
-
-- AddForeignKey
|
|
51
|
-
ALTER TABLE "DispatchTeam" ADD CONSTRAINT "DispatchTeam_otherTechnicianId_fkey" FOREIGN KEY ("otherTechnicianId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
52
|
-
|
|
53
|
-
-- AddForeignKey
|
|
54
|
-
ALTER TABLE "DispatchProject" ADD CONSTRAINT "DispatchProject_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
55
|
-
|
|
56
|
-
-- AddForeignKey
|
|
57
|
-
ALTER TABLE "DispatchProject" ADD CONSTRAINT "DispatchProject_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|