Commit 2d6285a3 by Augusto

small features for user, inspection and inspection-photos

parent ffe7ce06
ALTER TABLE "Inspection" ADD COLUMN "partnerId" integer NOT NULL;--> statement-breakpoint
ALTER TABLE "Inspection" ADD CONSTRAINT "Inspection_partnerId_Partner_id_fk" FOREIGN KEY ("partnerId") REFERENCES "public"."Partner"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "Inspection_partnerId_idx" ON "Inspection" USING btree ("partnerId");
\ No newline at end of file
ALTER TABLE "InspectionPhoto" ADD COLUMN "isAnomaly" boolean DEFAULT false NOT NULL;
\ No newline at end of file
ALTER TABLE "User" ADD COLUMN "formationValidation" timestamp;
\ No newline at end of file
ALTER TABLE "Inspection" ADD COLUMN "materialList" json;
\ No newline at end of file
{
"id": "1513f3fb-4efa-4be5-9aeb-5b71b65aa7de",
"prevId": "9bcdebf6-6471-40a9-972e-3e5fdc48930b",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.InspectionPhoto": {
"name": "InspectionPhoto",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"url": {
"name": "url",
"type": "varchar(500)",
"primaryKey": false,
"notNull": true
},
"filename": {
"name": "filename",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"mimeType": {
"name": "mimeType",
"type": "varchar(100)",
"primaryKey": false,
"notNull": true
},
"size": {
"name": "size",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"order": {
"name": "order",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"isPrincipal": {
"name": "isPrincipal",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"isResume": {
"name": "isResume",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"inspectionId": {
"name": "inspectionId",
"type": "integer",
"primaryKey": false,
"notNull": true
}
},
"indexes": {
"InspectionPhoto_inspectionId_idx": {
"name": "InspectionPhoto_inspectionId_idx",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"InspectionPhoto_inspectionId_Inspection_id_fk": {
"name": "InspectionPhoto_inspectionId_Inspection_id_fk",
"tableFrom": "InspectionPhoto",
"tableTo": "Inspection",
"columnsFrom": [
"inspectionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.InspectionQuestion": {
"name": "InspectionQuestion",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"question": {
"name": "question",
"type": "text",
"primaryKey": false,
"notNull": true
},
"orderIndex": {
"name": "orderIndex",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.InspectionResponse": {
"name": "InspectionResponse",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"response": {
"name": "response",
"type": "InspectionResponseOption",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"questionId": {
"name": "questionId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"inspectionId": {
"name": "inspectionId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"InspectionResponse_questionId_idx": {
"name": "InspectionResponse_questionId_idx",
"columns": [
{
"expression": "questionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"InspectionResponse_inspectionId_idx": {
"name": "InspectionResponse_inspectionId_idx",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"InspectionResponse_inspectionId_questionId_key": {
"name": "InspectionResponse_inspectionId_questionId_key",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "questionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"InspectionResponse_questionId_InspectionQuestion_id_fk": {
"name": "InspectionResponse_questionId_InspectionQuestion_id_fk",
"tableFrom": "InspectionResponse",
"tableTo": "InspectionQuestion",
"columnsFrom": [
"questionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"InspectionResponse_inspectionId_Inspection_id_fk": {
"name": "InspectionResponse_inspectionId_Inspection_id_fk",
"tableFrom": "InspectionResponse",
"tableTo": "Inspection",
"columnsFrom": [
"inspectionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Inspection": {
"name": "Inspection",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"date": {
"name": "date",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"deadline": {
"name": "deadline",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"finalComment": {
"name": "finalComment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"finalCommentStatus": {
"name": "finalCommentStatus",
"type": "InspectionStatus",
"typeSchema": "public",
"primaryKey": false,
"notNull": false,
"default": "'PENDING'"
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"createdById": {
"name": "createdById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"updatedById": {
"name": "updatedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"submittedById": {
"name": "submittedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"approvedById": {
"name": "approvedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"status": {
"name": "status",
"type": "InspectionStatus",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'PENDING'"
}
},
"indexes": {
"Inspection_siteId_idx": {
"name": "Inspection_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_partnerId_idx": {
"name": "Inspection_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_createdById_idx": {
"name": "Inspection_createdById_idx",
"columns": [
{
"expression": "createdById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_updatedById_idx": {
"name": "Inspection_updatedById_idx",
"columns": [
{
"expression": "updatedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_submittedById_idx": {
"name": "Inspection_submittedById_idx",
"columns": [
{
"expression": "submittedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_approvedById_idx": {
"name": "Inspection_approvedById_idx",
"columns": [
{
"expression": "approvedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_status_idx": {
"name": "Inspection_status_idx",
"columns": [
{
"expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_finalCommentStatus_idx": {
"name": "Inspection_finalCommentStatus_idx",
"columns": [
{
"expression": "finalCommentStatus",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"Inspection_siteId_Site_id_fk": {
"name": "Inspection_siteId_Site_id_fk",
"tableFrom": "Inspection",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"Inspection_partnerId_Partner_id_fk": {
"name": "Inspection_partnerId_Partner_id_fk",
"tableFrom": "Inspection",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"Inspection_createdById_User_id_fk": {
"name": "Inspection_createdById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"createdById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_updatedById_User_id_fk": {
"name": "Inspection_updatedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"updatedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_submittedById_User_id_fk": {
"name": "Inspection_submittedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"submittedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_approvedById_User_id_fk": {
"name": "Inspection_approvedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"approvedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.PartnerSite": {
"name": "PartnerSite",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"PartnerSite_partnerId_siteId_key": {
"name": "PartnerSite_partnerId_siteId_key",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"PartnerSite_partnerId_idx": {
"name": "PartnerSite_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"PartnerSite_siteId_idx": {
"name": "PartnerSite_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"PartnerSite_partnerId_Partner_id_fk": {
"name": "PartnerSite_partnerId_Partner_id_fk",
"tableFrom": "PartnerSite",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"PartnerSite_siteId_Site_id_fk": {
"name": "PartnerSite_siteId_Site_id_fk",
"tableFrom": "PartnerSite",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Partner": {
"name": "Partner",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"logo": {
"name": "logo",
"type": "varchar(500)",
"primaryKey": false,
"notNull": false
},
"isActive": {
"name": "isActive",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"Partner_name_idx": {
"name": "Partner_name_idx",
"columns": [
{
"expression": "name",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"Partner_name_unique": {
"name": "Partner_name_unique",
"nullsNotDistinct": false,
"columns": [
"name"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.RefreshToken": {
"name": "RefreshToken",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"token": {
"name": "token",
"type": "varchar(500)",
"primaryKey": false,
"notNull": true
},
"userId": {
"name": "userId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"expiresAt": {
"name": "expiresAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"RefreshToken_token_idx": {
"name": "RefreshToken_token_idx",
"columns": [
{
"expression": "token",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"RefreshToken_userId_idx": {
"name": "RefreshToken_userId_idx",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"RefreshToken_userId_User_id_fk": {
"name": "RefreshToken_userId_User_id_fk",
"tableFrom": "RefreshToken",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"RefreshToken_token_unique": {
"name": "RefreshToken_token_unique",
"nullsNotDistinct": false,
"columns": [
"token"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Site": {
"name": "Site",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"siteCode": {
"name": "siteCode",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"siteName": {
"name": "siteName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"latitude": {
"name": "latitude",
"type": "double precision",
"primaryKey": false,
"notNull": true
},
"longitude": {
"name": "longitude",
"type": "double precision",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"createdById": {
"name": "createdById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"updatedById": {
"name": "updatedById",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"Site_siteCode_idx": {
"name": "Site_siteCode_idx",
"columns": [
{
"expression": "siteCode",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"Site_createdById_User_id_fk": {
"name": "Site_createdById_User_id_fk",
"tableFrom": "Site",
"tableTo": "User",
"columnsFrom": [
"createdById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Site_updatedById_User_id_fk": {
"name": "Site_updatedById_User_id_fk",
"tableFrom": "Site",
"tableTo": "User",
"columnsFrom": [
"updatedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"Site_siteCode_unique": {
"name": "Site_siteCode_unique",
"nullsNotDistinct": false,
"columns": [
"siteCode"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.spatial_ref_sys": {
"name": "spatial_ref_sys",
"schema": "",
"columns": {
"srid": {
"name": "srid",
"type": "integer",
"primaryKey": true,
"notNull": true
},
"auth_name": {
"name": "auth_name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": false
},
"auth_srid": {
"name": "auth_srid",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"srtext": {
"name": "srtext",
"type": "varchar(2048)",
"primaryKey": false,
"notNull": false
},
"proj4text": {
"name": "proj4text",
"type": "varchar(2048)",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.TelecommunicationStationIdentification": {
"name": "TelecommunicationStationIdentification",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"stationIdentifier": {
"name": "stationIdentifier",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"serialNumber": {
"name": "serialNumber",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"isFirstCertification": {
"name": "isFirstCertification",
"type": "boolean",
"primaryKey": false,
"notNull": true
},
"modelReference": {
"name": "modelReference",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"TelecommunicationStationIdentification_siteId_idx": {
"name": "TelecommunicationStationIdentification_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"TelecommunicationStationIdentification_stationIdentifier_idx": {
"name": "TelecommunicationStationIdentification_stationIdentifier_idx",
"columns": [
{
"expression": "stationIdentifier",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"TelecommunicationStationIdentification_siteId_Site_id_fk": {
"name": "TelecommunicationStationIdentification_siteId_Site_id_fk",
"tableFrom": "TelecommunicationStationIdentification",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"TelecommunicationStationIdentification_siteId_unique": {
"name": "TelecommunicationStationIdentification_siteId_unique",
"nullsNotDistinct": false,
"columns": [
"siteId"
]
},
"TelecommunicationStationIdentification_stationIdentifier_unique": {
"name": "TelecommunicationStationIdentification_stationIdentifier_unique",
"nullsNotDistinct": false,
"columns": [
"stationIdentifier"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.UserSite": {
"name": "UserSite",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userId": {
"name": "userId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"UserSite_userId_siteId_key": {
"name": "UserSite_userId_siteId_key",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"UserSite_userId_idx": {
"name": "UserSite_userId_idx",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"UserSite_siteId_idx": {
"name": "UserSite_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"UserSite_userId_User_id_fk": {
"name": "UserSite_userId_User_id_fk",
"tableFrom": "UserSite",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"UserSite_siteId_Site_id_fk": {
"name": "UserSite_siteId_Site_id_fk",
"tableFrom": "UserSite",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.User": {
"name": "User",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"email": {
"name": "email",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"password": {
"name": "password",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"role": {
"name": "role",
"type": "Role",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'VIEWER'"
},
"signature": {
"name": "signature",
"type": "varchar(500)",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"resetToken": {
"name": "resetToken",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"resetTokenExpiry": {
"name": "resetTokenExpiry",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"isActive": {
"name": "isActive",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"User_email_idx": {
"name": "User_email_idx",
"columns": [
{
"expression": "email",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"User_role_idx": {
"name": "User_role_idx",
"columns": [
{
"expression": "role",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"User_partnerId_idx": {
"name": "User_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"User_partnerId_Partner_id_fk": {
"name": "User_partnerId_Partner_id_fk",
"tableFrom": "User",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"User_email_unique": {
"name": "User_email_unique",
"nullsNotDistinct": false,
"columns": [
"email"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {
"public.CompanyName": {
"name": "CompanyName",
"schema": "public",
"values": [
"VODAFONE",
"MEO",
"NOS",
"DIGI"
]
},
"public.InspectionResponseOption": {
"name": "InspectionResponseOption",
"schema": "public",
"values": [
"YES",
"NO",
"NA"
]
},
"public.InspectionStatus": {
"name": "InspectionStatus",
"schema": "public",
"values": [
"PENDING",
"IN_PROGRESS",
"COMPLETED",
"CANCELLED",
"APPROVING",
"REJECTED",
"APPROVED"
]
},
"public.Role": {
"name": "Role",
"schema": "public",
"values": [
"SUPERADMIN",
"ADMIN",
"MANAGER",
"PARTNER",
"OPERATOR",
"VIEWER"
]
}
},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
\ No newline at end of file
{
"id": "f5bce799-8e8d-4e58-a677-df19a00d11e2",
"prevId": "1513f3fb-4efa-4be5-9aeb-5b71b65aa7de",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.InspectionPhoto": {
"name": "InspectionPhoto",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"url": {
"name": "url",
"type": "varchar(500)",
"primaryKey": false,
"notNull": true
},
"filename": {
"name": "filename",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"mimeType": {
"name": "mimeType",
"type": "varchar(100)",
"primaryKey": false,
"notNull": true
},
"size": {
"name": "size",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"order": {
"name": "order",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"isPrincipal": {
"name": "isPrincipal",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"isResume": {
"name": "isResume",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"isAnomaly": {
"name": "isAnomaly",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"inspectionId": {
"name": "inspectionId",
"type": "integer",
"primaryKey": false,
"notNull": true
}
},
"indexes": {
"InspectionPhoto_inspectionId_idx": {
"name": "InspectionPhoto_inspectionId_idx",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"InspectionPhoto_inspectionId_Inspection_id_fk": {
"name": "InspectionPhoto_inspectionId_Inspection_id_fk",
"tableFrom": "InspectionPhoto",
"tableTo": "Inspection",
"columnsFrom": [
"inspectionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.InspectionQuestion": {
"name": "InspectionQuestion",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"question": {
"name": "question",
"type": "text",
"primaryKey": false,
"notNull": true
},
"orderIndex": {
"name": "orderIndex",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.InspectionResponse": {
"name": "InspectionResponse",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"response": {
"name": "response",
"type": "InspectionResponseOption",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"questionId": {
"name": "questionId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"inspectionId": {
"name": "inspectionId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"InspectionResponse_questionId_idx": {
"name": "InspectionResponse_questionId_idx",
"columns": [
{
"expression": "questionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"InspectionResponse_inspectionId_idx": {
"name": "InspectionResponse_inspectionId_idx",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"InspectionResponse_inspectionId_questionId_key": {
"name": "InspectionResponse_inspectionId_questionId_key",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "questionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"InspectionResponse_questionId_InspectionQuestion_id_fk": {
"name": "InspectionResponse_questionId_InspectionQuestion_id_fk",
"tableFrom": "InspectionResponse",
"tableTo": "InspectionQuestion",
"columnsFrom": [
"questionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"InspectionResponse_inspectionId_Inspection_id_fk": {
"name": "InspectionResponse_inspectionId_Inspection_id_fk",
"tableFrom": "InspectionResponse",
"tableTo": "Inspection",
"columnsFrom": [
"inspectionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Inspection": {
"name": "Inspection",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"date": {
"name": "date",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"deadline": {
"name": "deadline",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"finalComment": {
"name": "finalComment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"finalCommentStatus": {
"name": "finalCommentStatus",
"type": "InspectionStatus",
"typeSchema": "public",
"primaryKey": false,
"notNull": false,
"default": "'PENDING'"
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"createdById": {
"name": "createdById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"updatedById": {
"name": "updatedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"submittedById": {
"name": "submittedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"approvedById": {
"name": "approvedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"status": {
"name": "status",
"type": "InspectionStatus",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'PENDING'"
}
},
"indexes": {
"Inspection_siteId_idx": {
"name": "Inspection_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_partnerId_idx": {
"name": "Inspection_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_createdById_idx": {
"name": "Inspection_createdById_idx",
"columns": [
{
"expression": "createdById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_updatedById_idx": {
"name": "Inspection_updatedById_idx",
"columns": [
{
"expression": "updatedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_submittedById_idx": {
"name": "Inspection_submittedById_idx",
"columns": [
{
"expression": "submittedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_approvedById_idx": {
"name": "Inspection_approvedById_idx",
"columns": [
{
"expression": "approvedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_status_idx": {
"name": "Inspection_status_idx",
"columns": [
{
"expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_finalCommentStatus_idx": {
"name": "Inspection_finalCommentStatus_idx",
"columns": [
{
"expression": "finalCommentStatus",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"Inspection_siteId_Site_id_fk": {
"name": "Inspection_siteId_Site_id_fk",
"tableFrom": "Inspection",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"Inspection_partnerId_Partner_id_fk": {
"name": "Inspection_partnerId_Partner_id_fk",
"tableFrom": "Inspection",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"Inspection_createdById_User_id_fk": {
"name": "Inspection_createdById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"createdById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_updatedById_User_id_fk": {
"name": "Inspection_updatedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"updatedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_submittedById_User_id_fk": {
"name": "Inspection_submittedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"submittedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_approvedById_User_id_fk": {
"name": "Inspection_approvedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"approvedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.PartnerSite": {
"name": "PartnerSite",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"PartnerSite_partnerId_siteId_key": {
"name": "PartnerSite_partnerId_siteId_key",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"PartnerSite_partnerId_idx": {
"name": "PartnerSite_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"PartnerSite_siteId_idx": {
"name": "PartnerSite_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"PartnerSite_partnerId_Partner_id_fk": {
"name": "PartnerSite_partnerId_Partner_id_fk",
"tableFrom": "PartnerSite",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"PartnerSite_siteId_Site_id_fk": {
"name": "PartnerSite_siteId_Site_id_fk",
"tableFrom": "PartnerSite",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Partner": {
"name": "Partner",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"logo": {
"name": "logo",
"type": "varchar(500)",
"primaryKey": false,
"notNull": false
},
"isActive": {
"name": "isActive",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"Partner_name_idx": {
"name": "Partner_name_idx",
"columns": [
{
"expression": "name",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"Partner_name_unique": {
"name": "Partner_name_unique",
"nullsNotDistinct": false,
"columns": [
"name"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.RefreshToken": {
"name": "RefreshToken",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"token": {
"name": "token",
"type": "varchar(500)",
"primaryKey": false,
"notNull": true
},
"userId": {
"name": "userId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"expiresAt": {
"name": "expiresAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"RefreshToken_token_idx": {
"name": "RefreshToken_token_idx",
"columns": [
{
"expression": "token",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"RefreshToken_userId_idx": {
"name": "RefreshToken_userId_idx",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"RefreshToken_userId_User_id_fk": {
"name": "RefreshToken_userId_User_id_fk",
"tableFrom": "RefreshToken",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"RefreshToken_token_unique": {
"name": "RefreshToken_token_unique",
"nullsNotDistinct": false,
"columns": [
"token"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Site": {
"name": "Site",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"siteCode": {
"name": "siteCode",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"siteName": {
"name": "siteName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"latitude": {
"name": "latitude",
"type": "double precision",
"primaryKey": false,
"notNull": true
},
"longitude": {
"name": "longitude",
"type": "double precision",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"createdById": {
"name": "createdById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"updatedById": {
"name": "updatedById",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"Site_siteCode_idx": {
"name": "Site_siteCode_idx",
"columns": [
{
"expression": "siteCode",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"Site_createdById_User_id_fk": {
"name": "Site_createdById_User_id_fk",
"tableFrom": "Site",
"tableTo": "User",
"columnsFrom": [
"createdById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Site_updatedById_User_id_fk": {
"name": "Site_updatedById_User_id_fk",
"tableFrom": "Site",
"tableTo": "User",
"columnsFrom": [
"updatedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"Site_siteCode_unique": {
"name": "Site_siteCode_unique",
"nullsNotDistinct": false,
"columns": [
"siteCode"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.spatial_ref_sys": {
"name": "spatial_ref_sys",
"schema": "",
"columns": {
"srid": {
"name": "srid",
"type": "integer",
"primaryKey": true,
"notNull": true
},
"auth_name": {
"name": "auth_name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": false
},
"auth_srid": {
"name": "auth_srid",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"srtext": {
"name": "srtext",
"type": "varchar(2048)",
"primaryKey": false,
"notNull": false
},
"proj4text": {
"name": "proj4text",
"type": "varchar(2048)",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.TelecommunicationStationIdentification": {
"name": "TelecommunicationStationIdentification",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"stationIdentifier": {
"name": "stationIdentifier",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"serialNumber": {
"name": "serialNumber",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"isFirstCertification": {
"name": "isFirstCertification",
"type": "boolean",
"primaryKey": false,
"notNull": true
},
"modelReference": {
"name": "modelReference",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"TelecommunicationStationIdentification_siteId_idx": {
"name": "TelecommunicationStationIdentification_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"TelecommunicationStationIdentification_stationIdentifier_idx": {
"name": "TelecommunicationStationIdentification_stationIdentifier_idx",
"columns": [
{
"expression": "stationIdentifier",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"TelecommunicationStationIdentification_siteId_Site_id_fk": {
"name": "TelecommunicationStationIdentification_siteId_Site_id_fk",
"tableFrom": "TelecommunicationStationIdentification",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"TelecommunicationStationIdentification_siteId_unique": {
"name": "TelecommunicationStationIdentification_siteId_unique",
"nullsNotDistinct": false,
"columns": [
"siteId"
]
},
"TelecommunicationStationIdentification_stationIdentifier_unique": {
"name": "TelecommunicationStationIdentification_stationIdentifier_unique",
"nullsNotDistinct": false,
"columns": [
"stationIdentifier"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.UserSite": {
"name": "UserSite",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userId": {
"name": "userId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"UserSite_userId_siteId_key": {
"name": "UserSite_userId_siteId_key",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"UserSite_userId_idx": {
"name": "UserSite_userId_idx",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"UserSite_siteId_idx": {
"name": "UserSite_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"UserSite_userId_User_id_fk": {
"name": "UserSite_userId_User_id_fk",
"tableFrom": "UserSite",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"UserSite_siteId_Site_id_fk": {
"name": "UserSite_siteId_Site_id_fk",
"tableFrom": "UserSite",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.User": {
"name": "User",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"email": {
"name": "email",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"password": {
"name": "password",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"role": {
"name": "role",
"type": "Role",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'VIEWER'"
},
"signature": {
"name": "signature",
"type": "varchar(500)",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"resetToken": {
"name": "resetToken",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"resetTokenExpiry": {
"name": "resetTokenExpiry",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"isActive": {
"name": "isActive",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"User_email_idx": {
"name": "User_email_idx",
"columns": [
{
"expression": "email",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"User_role_idx": {
"name": "User_role_idx",
"columns": [
{
"expression": "role",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"User_partnerId_idx": {
"name": "User_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"User_partnerId_Partner_id_fk": {
"name": "User_partnerId_Partner_id_fk",
"tableFrom": "User",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"User_email_unique": {
"name": "User_email_unique",
"nullsNotDistinct": false,
"columns": [
"email"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {
"public.CompanyName": {
"name": "CompanyName",
"schema": "public",
"values": [
"VODAFONE",
"MEO",
"NOS",
"DIGI"
]
},
"public.InspectionResponseOption": {
"name": "InspectionResponseOption",
"schema": "public",
"values": [
"YES",
"NO",
"NA"
]
},
"public.InspectionStatus": {
"name": "InspectionStatus",
"schema": "public",
"values": [
"PENDING",
"IN_PROGRESS",
"COMPLETED",
"CANCELLED",
"APPROVING",
"REJECTED",
"APPROVED"
]
},
"public.Role": {
"name": "Role",
"schema": "public",
"values": [
"SUPERADMIN",
"ADMIN",
"MANAGER",
"PARTNER",
"OPERATOR",
"VIEWER"
]
}
},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
\ No newline at end of file
{
"id": "6d8a6c2d-2822-4b58-89b8-0f759d16c3e8",
"prevId": "f5bce799-8e8d-4e58-a677-df19a00d11e2",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.InspectionPhoto": {
"name": "InspectionPhoto",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"url": {
"name": "url",
"type": "varchar(500)",
"primaryKey": false,
"notNull": true
},
"filename": {
"name": "filename",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"mimeType": {
"name": "mimeType",
"type": "varchar(100)",
"primaryKey": false,
"notNull": true
},
"size": {
"name": "size",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"order": {
"name": "order",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"isPrincipal": {
"name": "isPrincipal",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"isResume": {
"name": "isResume",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"isAnomaly": {
"name": "isAnomaly",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"inspectionId": {
"name": "inspectionId",
"type": "integer",
"primaryKey": false,
"notNull": true
}
},
"indexes": {
"InspectionPhoto_inspectionId_idx": {
"name": "InspectionPhoto_inspectionId_idx",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"InspectionPhoto_inspectionId_Inspection_id_fk": {
"name": "InspectionPhoto_inspectionId_Inspection_id_fk",
"tableFrom": "InspectionPhoto",
"tableTo": "Inspection",
"columnsFrom": [
"inspectionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.InspectionQuestion": {
"name": "InspectionQuestion",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"question": {
"name": "question",
"type": "text",
"primaryKey": false,
"notNull": true
},
"orderIndex": {
"name": "orderIndex",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.InspectionResponse": {
"name": "InspectionResponse",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"response": {
"name": "response",
"type": "InspectionResponseOption",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"questionId": {
"name": "questionId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"inspectionId": {
"name": "inspectionId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"InspectionResponse_questionId_idx": {
"name": "InspectionResponse_questionId_idx",
"columns": [
{
"expression": "questionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"InspectionResponse_inspectionId_idx": {
"name": "InspectionResponse_inspectionId_idx",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"InspectionResponse_inspectionId_questionId_key": {
"name": "InspectionResponse_inspectionId_questionId_key",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "questionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"InspectionResponse_questionId_InspectionQuestion_id_fk": {
"name": "InspectionResponse_questionId_InspectionQuestion_id_fk",
"tableFrom": "InspectionResponse",
"tableTo": "InspectionQuestion",
"columnsFrom": [
"questionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"InspectionResponse_inspectionId_Inspection_id_fk": {
"name": "InspectionResponse_inspectionId_Inspection_id_fk",
"tableFrom": "InspectionResponse",
"tableTo": "Inspection",
"columnsFrom": [
"inspectionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Inspection": {
"name": "Inspection",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"date": {
"name": "date",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"deadline": {
"name": "deadline",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"finalComment": {
"name": "finalComment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"finalCommentStatus": {
"name": "finalCommentStatus",
"type": "InspectionStatus",
"typeSchema": "public",
"primaryKey": false,
"notNull": false,
"default": "'PENDING'"
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"createdById": {
"name": "createdById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"updatedById": {
"name": "updatedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"submittedById": {
"name": "submittedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"approvedById": {
"name": "approvedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"status": {
"name": "status",
"type": "InspectionStatus",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'PENDING'"
}
},
"indexes": {
"Inspection_siteId_idx": {
"name": "Inspection_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_partnerId_idx": {
"name": "Inspection_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_createdById_idx": {
"name": "Inspection_createdById_idx",
"columns": [
{
"expression": "createdById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_updatedById_idx": {
"name": "Inspection_updatedById_idx",
"columns": [
{
"expression": "updatedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_submittedById_idx": {
"name": "Inspection_submittedById_idx",
"columns": [
{
"expression": "submittedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_approvedById_idx": {
"name": "Inspection_approvedById_idx",
"columns": [
{
"expression": "approvedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_status_idx": {
"name": "Inspection_status_idx",
"columns": [
{
"expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_finalCommentStatus_idx": {
"name": "Inspection_finalCommentStatus_idx",
"columns": [
{
"expression": "finalCommentStatus",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"Inspection_siteId_Site_id_fk": {
"name": "Inspection_siteId_Site_id_fk",
"tableFrom": "Inspection",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"Inspection_partnerId_Partner_id_fk": {
"name": "Inspection_partnerId_Partner_id_fk",
"tableFrom": "Inspection",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"Inspection_createdById_User_id_fk": {
"name": "Inspection_createdById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"createdById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_updatedById_User_id_fk": {
"name": "Inspection_updatedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"updatedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_submittedById_User_id_fk": {
"name": "Inspection_submittedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"submittedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_approvedById_User_id_fk": {
"name": "Inspection_approvedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"approvedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.PartnerSite": {
"name": "PartnerSite",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"PartnerSite_partnerId_siteId_key": {
"name": "PartnerSite_partnerId_siteId_key",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"PartnerSite_partnerId_idx": {
"name": "PartnerSite_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"PartnerSite_siteId_idx": {
"name": "PartnerSite_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"PartnerSite_partnerId_Partner_id_fk": {
"name": "PartnerSite_partnerId_Partner_id_fk",
"tableFrom": "PartnerSite",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"PartnerSite_siteId_Site_id_fk": {
"name": "PartnerSite_siteId_Site_id_fk",
"tableFrom": "PartnerSite",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Partner": {
"name": "Partner",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"logo": {
"name": "logo",
"type": "varchar(500)",
"primaryKey": false,
"notNull": false
},
"isActive": {
"name": "isActive",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"Partner_name_idx": {
"name": "Partner_name_idx",
"columns": [
{
"expression": "name",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"Partner_name_unique": {
"name": "Partner_name_unique",
"nullsNotDistinct": false,
"columns": [
"name"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.RefreshToken": {
"name": "RefreshToken",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"token": {
"name": "token",
"type": "varchar(500)",
"primaryKey": false,
"notNull": true
},
"userId": {
"name": "userId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"expiresAt": {
"name": "expiresAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"RefreshToken_token_idx": {
"name": "RefreshToken_token_idx",
"columns": [
{
"expression": "token",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"RefreshToken_userId_idx": {
"name": "RefreshToken_userId_idx",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"RefreshToken_userId_User_id_fk": {
"name": "RefreshToken_userId_User_id_fk",
"tableFrom": "RefreshToken",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"RefreshToken_token_unique": {
"name": "RefreshToken_token_unique",
"nullsNotDistinct": false,
"columns": [
"token"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Site": {
"name": "Site",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"siteCode": {
"name": "siteCode",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"siteName": {
"name": "siteName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"latitude": {
"name": "latitude",
"type": "double precision",
"primaryKey": false,
"notNull": true
},
"longitude": {
"name": "longitude",
"type": "double precision",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"createdById": {
"name": "createdById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"updatedById": {
"name": "updatedById",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"Site_siteCode_idx": {
"name": "Site_siteCode_idx",
"columns": [
{
"expression": "siteCode",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"Site_createdById_User_id_fk": {
"name": "Site_createdById_User_id_fk",
"tableFrom": "Site",
"tableTo": "User",
"columnsFrom": [
"createdById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Site_updatedById_User_id_fk": {
"name": "Site_updatedById_User_id_fk",
"tableFrom": "Site",
"tableTo": "User",
"columnsFrom": [
"updatedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"Site_siteCode_unique": {
"name": "Site_siteCode_unique",
"nullsNotDistinct": false,
"columns": [
"siteCode"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.spatial_ref_sys": {
"name": "spatial_ref_sys",
"schema": "",
"columns": {
"srid": {
"name": "srid",
"type": "integer",
"primaryKey": true,
"notNull": true
},
"auth_name": {
"name": "auth_name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": false
},
"auth_srid": {
"name": "auth_srid",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"srtext": {
"name": "srtext",
"type": "varchar(2048)",
"primaryKey": false,
"notNull": false
},
"proj4text": {
"name": "proj4text",
"type": "varchar(2048)",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.TelecommunicationStationIdentification": {
"name": "TelecommunicationStationIdentification",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"stationIdentifier": {
"name": "stationIdentifier",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"serialNumber": {
"name": "serialNumber",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"isFirstCertification": {
"name": "isFirstCertification",
"type": "boolean",
"primaryKey": false,
"notNull": true
},
"modelReference": {
"name": "modelReference",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"TelecommunicationStationIdentification_siteId_idx": {
"name": "TelecommunicationStationIdentification_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"TelecommunicationStationIdentification_stationIdentifier_idx": {
"name": "TelecommunicationStationIdentification_stationIdentifier_idx",
"columns": [
{
"expression": "stationIdentifier",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"TelecommunicationStationIdentification_siteId_Site_id_fk": {
"name": "TelecommunicationStationIdentification_siteId_Site_id_fk",
"tableFrom": "TelecommunicationStationIdentification",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"TelecommunicationStationIdentification_siteId_unique": {
"name": "TelecommunicationStationIdentification_siteId_unique",
"nullsNotDistinct": false,
"columns": [
"siteId"
]
},
"TelecommunicationStationIdentification_stationIdentifier_unique": {
"name": "TelecommunicationStationIdentification_stationIdentifier_unique",
"nullsNotDistinct": false,
"columns": [
"stationIdentifier"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.UserSite": {
"name": "UserSite",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userId": {
"name": "userId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"UserSite_userId_siteId_key": {
"name": "UserSite_userId_siteId_key",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"UserSite_userId_idx": {
"name": "UserSite_userId_idx",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"UserSite_siteId_idx": {
"name": "UserSite_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"UserSite_userId_User_id_fk": {
"name": "UserSite_userId_User_id_fk",
"tableFrom": "UserSite",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"UserSite_siteId_Site_id_fk": {
"name": "UserSite_siteId_Site_id_fk",
"tableFrom": "UserSite",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.User": {
"name": "User",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"email": {
"name": "email",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"password": {
"name": "password",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"role": {
"name": "role",
"type": "Role",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'VIEWER'"
},
"signature": {
"name": "signature",
"type": "varchar(500)",
"primaryKey": false,
"notNull": false
},
"formationValidation": {
"name": "formationValidation",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"resetToken": {
"name": "resetToken",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"resetTokenExpiry": {
"name": "resetTokenExpiry",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"isActive": {
"name": "isActive",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"User_email_idx": {
"name": "User_email_idx",
"columns": [
{
"expression": "email",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"User_role_idx": {
"name": "User_role_idx",
"columns": [
{
"expression": "role",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"User_partnerId_idx": {
"name": "User_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"User_partnerId_Partner_id_fk": {
"name": "User_partnerId_Partner_id_fk",
"tableFrom": "User",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"User_email_unique": {
"name": "User_email_unique",
"nullsNotDistinct": false,
"columns": [
"email"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {
"public.CompanyName": {
"name": "CompanyName",
"schema": "public",
"values": [
"VODAFONE",
"MEO",
"NOS",
"DIGI"
]
},
"public.InspectionResponseOption": {
"name": "InspectionResponseOption",
"schema": "public",
"values": [
"YES",
"NO",
"NA"
]
},
"public.InspectionStatus": {
"name": "InspectionStatus",
"schema": "public",
"values": [
"PENDING",
"IN_PROGRESS",
"COMPLETED",
"CANCELLED",
"APPROVING",
"REJECTED",
"APPROVED"
]
},
"public.Role": {
"name": "Role",
"schema": "public",
"values": [
"SUPERADMIN",
"ADMIN",
"MANAGER",
"PARTNER",
"OPERATOR",
"VIEWER"
]
}
},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
\ No newline at end of file
{
"id": "9ab6985c-0cbd-4bcb-ba2a-936c3d810bb6",
"prevId": "6d8a6c2d-2822-4b58-89b8-0f759d16c3e8",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.InspectionPhoto": {
"name": "InspectionPhoto",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"url": {
"name": "url",
"type": "varchar(500)",
"primaryKey": false,
"notNull": true
},
"filename": {
"name": "filename",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"mimeType": {
"name": "mimeType",
"type": "varchar(100)",
"primaryKey": false,
"notNull": true
},
"size": {
"name": "size",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"order": {
"name": "order",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"isPrincipal": {
"name": "isPrincipal",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"isResume": {
"name": "isResume",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"isAnomaly": {
"name": "isAnomaly",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"inspectionId": {
"name": "inspectionId",
"type": "integer",
"primaryKey": false,
"notNull": true
}
},
"indexes": {
"InspectionPhoto_inspectionId_idx": {
"name": "InspectionPhoto_inspectionId_idx",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"InspectionPhoto_inspectionId_Inspection_id_fk": {
"name": "InspectionPhoto_inspectionId_Inspection_id_fk",
"tableFrom": "InspectionPhoto",
"tableTo": "Inspection",
"columnsFrom": [
"inspectionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.InspectionQuestion": {
"name": "InspectionQuestion",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"question": {
"name": "question",
"type": "text",
"primaryKey": false,
"notNull": true
},
"orderIndex": {
"name": "orderIndex",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.InspectionResponse": {
"name": "InspectionResponse",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"response": {
"name": "response",
"type": "InspectionResponseOption",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"questionId": {
"name": "questionId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"inspectionId": {
"name": "inspectionId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"InspectionResponse_questionId_idx": {
"name": "InspectionResponse_questionId_idx",
"columns": [
{
"expression": "questionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"InspectionResponse_inspectionId_idx": {
"name": "InspectionResponse_inspectionId_idx",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"InspectionResponse_inspectionId_questionId_key": {
"name": "InspectionResponse_inspectionId_questionId_key",
"columns": [
{
"expression": "inspectionId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "questionId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"InspectionResponse_questionId_InspectionQuestion_id_fk": {
"name": "InspectionResponse_questionId_InspectionQuestion_id_fk",
"tableFrom": "InspectionResponse",
"tableTo": "InspectionQuestion",
"columnsFrom": [
"questionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"InspectionResponse_inspectionId_Inspection_id_fk": {
"name": "InspectionResponse_inspectionId_Inspection_id_fk",
"tableFrom": "InspectionResponse",
"tableTo": "Inspection",
"columnsFrom": [
"inspectionId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Inspection": {
"name": "Inspection",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"date": {
"name": "date",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"deadline": {
"name": "deadline",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"finalComment": {
"name": "finalComment",
"type": "text",
"primaryKey": false,
"notNull": false
},
"finalCommentStatus": {
"name": "finalCommentStatus",
"type": "InspectionStatus",
"typeSchema": "public",
"primaryKey": false,
"notNull": false,
"default": "'PENDING'"
},
"materialList": {
"name": "materialList",
"type": "json",
"primaryKey": false,
"notNull": false
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"createdById": {
"name": "createdById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"updatedById": {
"name": "updatedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"submittedById": {
"name": "submittedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"approvedById": {
"name": "approvedById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"status": {
"name": "status",
"type": "InspectionStatus",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'PENDING'"
}
},
"indexes": {
"Inspection_siteId_idx": {
"name": "Inspection_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_partnerId_idx": {
"name": "Inspection_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_createdById_idx": {
"name": "Inspection_createdById_idx",
"columns": [
{
"expression": "createdById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_updatedById_idx": {
"name": "Inspection_updatedById_idx",
"columns": [
{
"expression": "updatedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_submittedById_idx": {
"name": "Inspection_submittedById_idx",
"columns": [
{
"expression": "submittedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_approvedById_idx": {
"name": "Inspection_approvedById_idx",
"columns": [
{
"expression": "approvedById",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_status_idx": {
"name": "Inspection_status_idx",
"columns": [
{
"expression": "status",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"Inspection_finalCommentStatus_idx": {
"name": "Inspection_finalCommentStatus_idx",
"columns": [
{
"expression": "finalCommentStatus",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"Inspection_siteId_Site_id_fk": {
"name": "Inspection_siteId_Site_id_fk",
"tableFrom": "Inspection",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"Inspection_partnerId_Partner_id_fk": {
"name": "Inspection_partnerId_Partner_id_fk",
"tableFrom": "Inspection",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"Inspection_createdById_User_id_fk": {
"name": "Inspection_createdById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"createdById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_updatedById_User_id_fk": {
"name": "Inspection_updatedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"updatedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_submittedById_User_id_fk": {
"name": "Inspection_submittedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"submittedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Inspection_approvedById_User_id_fk": {
"name": "Inspection_approvedById_User_id_fk",
"tableFrom": "Inspection",
"tableTo": "User",
"columnsFrom": [
"approvedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.PartnerSite": {
"name": "PartnerSite",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"PartnerSite_partnerId_siteId_key": {
"name": "PartnerSite_partnerId_siteId_key",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"PartnerSite_partnerId_idx": {
"name": "PartnerSite_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"PartnerSite_siteId_idx": {
"name": "PartnerSite_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"PartnerSite_partnerId_Partner_id_fk": {
"name": "PartnerSite_partnerId_Partner_id_fk",
"tableFrom": "PartnerSite",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"PartnerSite_siteId_Site_id_fk": {
"name": "PartnerSite_siteId_Site_id_fk",
"tableFrom": "PartnerSite",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Partner": {
"name": "Partner",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"logo": {
"name": "logo",
"type": "varchar(500)",
"primaryKey": false,
"notNull": false
},
"isActive": {
"name": "isActive",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"Partner_name_idx": {
"name": "Partner_name_idx",
"columns": [
{
"expression": "name",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"Partner_name_unique": {
"name": "Partner_name_unique",
"nullsNotDistinct": false,
"columns": [
"name"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.RefreshToken": {
"name": "RefreshToken",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"token": {
"name": "token",
"type": "varchar(500)",
"primaryKey": false,
"notNull": true
},
"userId": {
"name": "userId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"expiresAt": {
"name": "expiresAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"RefreshToken_token_idx": {
"name": "RefreshToken_token_idx",
"columns": [
{
"expression": "token",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"RefreshToken_userId_idx": {
"name": "RefreshToken_userId_idx",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"RefreshToken_userId_User_id_fk": {
"name": "RefreshToken_userId_User_id_fk",
"tableFrom": "RefreshToken",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"RefreshToken_token_unique": {
"name": "RefreshToken_token_unique",
"nullsNotDistinct": false,
"columns": [
"token"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.Site": {
"name": "Site",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"siteCode": {
"name": "siteCode",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"siteName": {
"name": "siteName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"latitude": {
"name": "latitude",
"type": "double precision",
"primaryKey": false,
"notNull": true
},
"longitude": {
"name": "longitude",
"type": "double precision",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"createdById": {
"name": "createdById",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"updatedById": {
"name": "updatedById",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"Site_siteCode_idx": {
"name": "Site_siteCode_idx",
"columns": [
{
"expression": "siteCode",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"Site_createdById_User_id_fk": {
"name": "Site_createdById_User_id_fk",
"tableFrom": "Site",
"tableTo": "User",
"columnsFrom": [
"createdById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"Site_updatedById_User_id_fk": {
"name": "Site_updatedById_User_id_fk",
"tableFrom": "Site",
"tableTo": "User",
"columnsFrom": [
"updatedById"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"Site_siteCode_unique": {
"name": "Site_siteCode_unique",
"nullsNotDistinct": false,
"columns": [
"siteCode"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.spatial_ref_sys": {
"name": "spatial_ref_sys",
"schema": "",
"columns": {
"srid": {
"name": "srid",
"type": "integer",
"primaryKey": true,
"notNull": true
},
"auth_name": {
"name": "auth_name",
"type": "varchar(256)",
"primaryKey": false,
"notNull": false
},
"auth_srid": {
"name": "auth_srid",
"type": "integer",
"primaryKey": false,
"notNull": false
},
"srtext": {
"name": "srtext",
"type": "varchar(2048)",
"primaryKey": false,
"notNull": false
},
"proj4text": {
"name": "proj4text",
"type": "varchar(2048)",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.TelecommunicationStationIdentification": {
"name": "TelecommunicationStationIdentification",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"stationIdentifier": {
"name": "stationIdentifier",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"serialNumber": {
"name": "serialNumber",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"isFirstCertification": {
"name": "isFirstCertification",
"type": "boolean",
"primaryKey": false,
"notNull": true
},
"modelReference": {
"name": "modelReference",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"TelecommunicationStationIdentification_siteId_idx": {
"name": "TelecommunicationStationIdentification_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"TelecommunicationStationIdentification_stationIdentifier_idx": {
"name": "TelecommunicationStationIdentification_stationIdentifier_idx",
"columns": [
{
"expression": "stationIdentifier",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"TelecommunicationStationIdentification_siteId_Site_id_fk": {
"name": "TelecommunicationStationIdentification_siteId_Site_id_fk",
"tableFrom": "TelecommunicationStationIdentification",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"TelecommunicationStationIdentification_siteId_unique": {
"name": "TelecommunicationStationIdentification_siteId_unique",
"nullsNotDistinct": false,
"columns": [
"siteId"
]
},
"TelecommunicationStationIdentification_stationIdentifier_unique": {
"name": "TelecommunicationStationIdentification_stationIdentifier_unique",
"nullsNotDistinct": false,
"columns": [
"stationIdentifier"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.UserSite": {
"name": "UserSite",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"userId": {
"name": "userId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"siteId": {
"name": "siteId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {
"UserSite_userId_siteId_key": {
"name": "UserSite_userId_siteId_key",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
},
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": true,
"concurrently": false,
"method": "btree",
"with": {}
},
"UserSite_userId_idx": {
"name": "UserSite_userId_idx",
"columns": [
{
"expression": "userId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"UserSite_siteId_idx": {
"name": "UserSite_siteId_idx",
"columns": [
{
"expression": "siteId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"UserSite_userId_User_id_fk": {
"name": "UserSite_userId_User_id_fk",
"tableFrom": "UserSite",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
},
"UserSite_siteId_Site_id_fk": {
"name": "UserSite_siteId_Site_id_fk",
"tableFrom": "UserSite",
"tableTo": "Site",
"columnsFrom": [
"siteId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.User": {
"name": "User",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"email": {
"name": "email",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"password": {
"name": "password",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"role": {
"name": "role",
"type": "Role",
"typeSchema": "public",
"primaryKey": false,
"notNull": true,
"default": "'VIEWER'"
},
"signature": {
"name": "signature",
"type": "varchar(500)",
"primaryKey": false,
"notNull": false
},
"formationValidation": {
"name": "formationValidation",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"resetToken": {
"name": "resetToken",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"resetTokenExpiry": {
"name": "resetTokenExpiry",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"isActive": {
"name": "isActive",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"partnerId": {
"name": "partnerId",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"User_email_idx": {
"name": "User_email_idx",
"columns": [
{
"expression": "email",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"User_role_idx": {
"name": "User_role_idx",
"columns": [
{
"expression": "role",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"User_partnerId_idx": {
"name": "User_partnerId_idx",
"columns": [
{
"expression": "partnerId",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"User_partnerId_Partner_id_fk": {
"name": "User_partnerId_Partner_id_fk",
"tableFrom": "User",
"tableTo": "Partner",
"columnsFrom": [
"partnerId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"User_email_unique": {
"name": "User_email_unique",
"nullsNotDistinct": false,
"columns": [
"email"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {
"public.CompanyName": {
"name": "CompanyName",
"schema": "public",
"values": [
"VODAFONE",
"MEO",
"NOS",
"DIGI"
]
},
"public.InspectionResponseOption": {
"name": "InspectionResponseOption",
"schema": "public",
"values": [
"YES",
"NO",
"NA"
]
},
"public.InspectionStatus": {
"name": "InspectionStatus",
"schema": "public",
"values": [
"PENDING",
"IN_PROGRESS",
"COMPLETED",
"CANCELLED",
"APPROVING",
"REJECTED",
"APPROVED"
]
},
"public.Role": {
"name": "Role",
"schema": "public",
"values": [
"SUPERADMIN",
"ADMIN",
"MANAGER",
"PARTNER",
"OPERATOR",
"VIEWER"
]
}
},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
\ No newline at end of file
......@@ -64,6 +64,34 @@
"when": 1759738883201,
"tag": "0008_adorable_quentin_quire",
"breakpoints": true
},
{
"idx": 9,
"version": "7",
"when": 1759825456628,
"tag": "0009_quiet_krista_starr",
"breakpoints": true
},
{
"idx": 10,
"version": "7",
"when": 1759914221257,
"tag": "0010_curly_doomsday",
"breakpoints": true
},
{
"idx": 11,
"version": "7",
"when": 1759914481385,
"tag": "0011_solid_hammerhead",
"breakpoints": true
},
{
"idx": 12,
"version": "7",
"when": 1759914965328,
"tag": "0012_nervous_havok",
"breakpoints": true
}
]
}
\ No newline at end of file
import { relations } from "drizzle-orm/relations";
import { user, refreshToken, site, partner, userSite, inspectionQuestion, inspectionResponse, inspection, inspectionPhoto, telecommunicationStationIdentification } from "./schema";
export const refreshTokenRelations = relations(refreshToken, ({one}) => ({
user: one(user, {
fields: [refreshToken.userId],
references: [user.id]
}),
}));
export const userRelations = relations(user, ({one, many}) => ({
refreshTokens: many(refreshToken),
sites_createdById: many(site, {
relationName: "site_createdById_user_id"
}),
sites_updatedById: many(site, {
relationName: "site_updatedById_user_id"
}),
partner: one(partner, {
fields: [user.partnerId],
references: [partner.id]
}),
userSites: many(userSite),
inspections_createdById: many(inspection, {
relationName: "inspection_createdById_user_id"
}),
inspections_updatedById: many(inspection, {
relationName: "inspection_updatedById_user_id"
}),
}));
export const siteRelations = relations(site, ({one, many}) => ({
user_createdById: one(user, {
fields: [site.createdById],
references: [user.id],
relationName: "site_createdById_user_id"
}),
user_updatedById: one(user, {
fields: [site.updatedById],
references: [user.id],
relationName: "site_updatedById_user_id"
}),
userSites: many(userSite),
telecommunicationStationIdentifications: many(telecommunicationStationIdentification),
inspections: many(inspection),
}));
export const partnerRelations = relations(partner, ({many}) => ({
users: many(user),
}));
export const userSiteRelations = relations(userSite, ({one}) => ({
user: one(user, {
fields: [userSite.userId],
references: [user.id]
}),
site: one(site, {
fields: [userSite.siteId],
references: [site.id]
}),
}));
export const inspectionResponseRelations = relations(inspectionResponse, ({one}) => ({
inspectionQuestion: one(inspectionQuestion, {
fields: [inspectionResponse.questionId],
references: [inspectionQuestion.id]
}),
inspection: one(inspection, {
fields: [inspectionResponse.inspectionId],
references: [inspection.id]
}),
}));
export const inspectionQuestionRelations = relations(inspectionQuestion, ({many}) => ({
inspectionResponses: many(inspectionResponse),
}));
export const inspectionRelations = relations(inspection, ({one, many}) => ({
inspectionResponses: many(inspectionResponse),
inspectionPhotos: many(inspectionPhoto),
site: one(site, {
fields: [inspection.siteId],
references: [site.id]
}),
user_createdById: one(user, {
fields: [inspection.createdById],
references: [user.id],
relationName: "inspection_createdById_user_id"
}),
user_updatedById: one(user, {
fields: [inspection.updatedById],
references: [user.id],
relationName: "inspection_updatedById_user_id"
}),
}));
export const inspectionPhotoRelations = relations(inspectionPhoto, ({one}) => ({
inspection: one(inspection, {
fields: [inspectionPhoto.inspectionId],
references: [inspection.id]
}),
}));
export const telecommunicationStationIdentificationRelations = relations(telecommunicationStationIdentification, ({one}) => ({
site: one(site, {
fields: [telecommunicationStationIdentification.siteId],
references: [site.id]
}),
}));
\ No newline at end of file
import {
pgTable,
check,
integer,
varchar,
index,
uniqueIndex,
foreignKey,
serial,
text,
timestamp,
doublePrecision,
boolean,
pgView,
pgEnum,
} from 'drizzle-orm/pg-core';
import { sql } from 'drizzle-orm';
export const companyName = pgEnum('CompanyName', [
'VODAFONE',
'MEO',
'NOS',
'DIGI',
]);
export const finalCommentStatus = pgEnum('FinalCommentStatus', [
'PENDING',
'VALIDATED',
'REJECTED',
]);
export const inspectionResponseOption = pgEnum('InspectionResponseOption', [
'YES',
'NO',
'NA',
]);
export const inspectionStatus = pgEnum('InspectionStatus', [
'PENDING',
'IN_PROGRESS',
'COMPLETED',
'CANCELLED',
'APPROVING',
'REJECTED',
'APPROVED',
]);
export const role = pgEnum('Role', [
'SUPERADMIN',
'ADMIN',
'MANAGER',
'PARTNER',
'OPERATOR',
'VIEWER',
]);
export const spatialRefSys = pgTable(
'spatial_ref_sys',
{
srid: integer().primaryKey().notNull(),
authName: varchar('auth_name', { length: 256 }),
authSrid: integer('auth_srid'),
srtext: varchar({ length: 2048 }),
proj4Text: varchar({ length: 2048 }),
},
(table) => [
check('spatial_ref_sys_srid_check', sql`(srid > 0) AND (srid <= 998999)`),
],
);
export const refreshToken = pgTable(
'RefreshToken',
{
id: serial().primaryKey().notNull(),
token: text().notNull(),
userId: integer().notNull(),
expiresAt: timestamp({ precision: 3, mode: 'string' }).notNull(),
createdAt: timestamp({ precision: 3, mode: 'string' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
},
(table) => [
index('RefreshToken_token_idx').using(
'btree',
table.token.asc().nullsLast().op('text_ops'),
),
uniqueIndex('RefreshToken_token_key').using(
'btree',
table.token.asc().nullsLast().op('text_ops'),
),
index('RefreshToken_userId_idx').using(
'btree',
table.userId.asc().nullsLast().op('int4_ops'),
),
foreignKey({
columns: [table.userId],
foreignColumns: [user.id],
name: 'RefreshToken_userId_fkey',
})
.onUpdate('cascade')
.onDelete('cascade'),
],
);
export const site = pgTable(
'Site',
{
id: serial().primaryKey().notNull(),
siteCode: text().notNull(),
siteName: text().notNull(),
latitude: doublePrecision().notNull(),
longitude: doublePrecision().notNull(),
createdAt: timestamp({ precision: 3, mode: 'string' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp({ precision: 3, mode: 'string' }).notNull(),
createdById: integer(),
updatedById: integer(),
},
(table) => [
index('Site_siteCode_idx').using(
'btree',
table.siteCode.asc().nullsLast().op('text_ops'),
),
uniqueIndex('Site_siteCode_key').using(
'btree',
table.siteCode.asc().nullsLast().op('text_ops'),
),
foreignKey({
columns: [table.createdById],
foreignColumns: [user.id],
name: 'Site_createdById_fkey',
})
.onUpdate('cascade')
.onDelete('set null'),
foreignKey({
columns: [table.updatedById],
foreignColumns: [user.id],
name: 'Site_updatedById_fkey',
})
.onUpdate('cascade')
.onDelete('set null'),
],
);
export const user = pgTable(
'User',
{
id: serial().primaryKey().notNull(),
email: text().notNull(),
name: text().notNull(),
password: text().notNull(),
role: role().default('VIEWER').notNull(),
createdAt: timestamp({ precision: 3, mode: 'string' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp({ precision: 3, mode: 'string' }).notNull(),
resetToken: text(),
resetTokenExpiry: timestamp({ precision: 3, mode: 'string' }),
isActive: boolean().default(false).notNull(),
partnerId: integer(),
},
(table) => [
index('User_email_idx').using(
'btree',
table.email.asc().nullsLast().op('text_ops'),
),
uniqueIndex('User_email_key').using(
'btree',
table.email.asc().nullsLast().op('text_ops'),
),
index('User_partnerId_idx').using(
'btree',
table.partnerId.asc().nullsLast().op('int4_ops'),
),
index('User_role_idx').using(
'btree',
table.role.asc().nullsLast().op('enum_ops'),
),
foreignKey({
columns: [table.partnerId],
foreignColumns: [partner.id],
name: 'User_partnerId_fkey',
})
.onUpdate('cascade')
.onDelete('set null'),
],
);
export const userSite = pgTable(
'UserSite',
{
id: serial().primaryKey().notNull(),
userId: integer().notNull(),
siteId: integer().notNull(),
createdAt: timestamp({ precision: 3, mode: 'string' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp({ precision: 3, mode: 'string' }).notNull(),
},
(table) => [
index('UserSite_siteId_idx').using(
'btree',
table.siteId.asc().nullsLast().op('int4_ops'),
),
index('UserSite_userId_idx').using(
'btree',
table.userId.asc().nullsLast().op('int4_ops'),
),
uniqueIndex('UserSite_userId_siteId_key').using(
'btree',
table.userId.asc().nullsLast().op('int4_ops'),
table.siteId.asc().nullsLast().op('int4_ops'),
),
foreignKey({
columns: [table.userId],
foreignColumns: [user.id],
name: 'UserSite_userId_fkey',
})
.onUpdate('cascade')
.onDelete('cascade'),
foreignKey({
columns: [table.siteId],
foreignColumns: [site.id],
name: 'UserSite_siteId_fkey',
})
.onUpdate('cascade')
.onDelete('cascade'),
],
);
export const inspectionQuestion = pgTable('InspectionQuestion', {
id: serial().primaryKey().notNull(),
question: text().notNull(),
orderIndex: integer().notNull(),
createdAt: timestamp({ precision: 3, mode: 'string' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp({ precision: 3, mode: 'string' }).notNull(),
});
export const inspectionResponse = pgTable(
'InspectionResponse',
{
id: serial().primaryKey().notNull(),
response: inspectionResponseOption().notNull(),
comment: text(),
questionId: integer().notNull(),
inspectionId: integer().notNull(),
createdAt: timestamp({ precision: 3, mode: 'string' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp({ precision: 3, mode: 'string' }).notNull(),
},
(table) => [
index('InspectionResponse_inspectionId_idx').using(
'btree',
table.inspectionId.asc().nullsLast().op('int4_ops'),
),
uniqueIndex('InspectionResponse_inspectionId_questionId_key').using(
'btree',
table.inspectionId.asc().nullsLast().op('int4_ops'),
table.questionId.asc().nullsLast().op('int4_ops'),
),
index('InspectionResponse_questionId_idx').using(
'btree',
table.questionId.asc().nullsLast().op('int4_ops'),
),
foreignKey({
columns: [table.questionId],
foreignColumns: [inspectionQuestion.id],
name: 'InspectionResponse_questionId_fkey',
})
.onUpdate('cascade')
.onDelete('cascade'),
foreignKey({
columns: [table.inspectionId],
foreignColumns: [inspection.id],
name: 'InspectionResponse_inspectionId_fkey',
})
.onUpdate('cascade')
.onDelete('cascade'),
],
);
export const inspectionPhoto = pgTable(
'InspectionPhoto',
{
id: serial().primaryKey().notNull(),
url: text().notNull(),
filename: text().notNull(),
mimeType: text().notNull(),
size: integer().notNull(),
createdAt: timestamp({ precision: 3, mode: 'string' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp({ precision: 3, mode: 'string' }).notNull(),
inspectionId: integer().notNull(),
description: text(),
},
(table) => [
index('InspectionPhoto_inspectionId_idx').using(
'btree',
table.inspectionId.asc().nullsLast().op('int4_ops'),
),
foreignKey({
columns: [table.inspectionId],
foreignColumns: [inspection.id],
name: 'InspectionPhoto_inspectionId_fkey',
})
.onUpdate('cascade')
.onDelete('cascade'),
],
);
export const partner = pgTable(
'Partner',
{
id: serial().primaryKey().notNull(),
name: text().notNull(),
description: text(),
isActive: boolean().default(true).notNull(),
createdAt: timestamp({ precision: 3, mode: 'string' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp({ precision: 3, mode: 'string' }).notNull(),
},
(table) => [
index('Partner_name_idx').using(
'btree',
table.name.asc().nullsLast().op('text_ops'),
),
uniqueIndex('Partner_name_key').using(
'btree',
table.name.asc().nullsLast().op('text_ops'),
),
],
);
export const telecommunicationStationIdentification = pgTable(
'TelecommunicationStationIdentification',
{
id: serial().primaryKey().notNull(),
siteId: integer().notNull(),
stationIdentifier: text().notNull(),
serialNumber: text().notNull(),
isFirstCertification: boolean().notNull(),
modelReference: text().notNull(),
createdAt: timestamp({ precision: 3, mode: 'string' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp({ precision: 3, mode: 'string' }).notNull(),
},
(table) => [
index('TelecommunicationStationIdentification_siteId_idx').using(
'btree',
table.siteId.asc().nullsLast().op('int4_ops'),
),
uniqueIndex('TelecommunicationStationIdentification_siteId_key').using(
'btree',
table.siteId.asc().nullsLast().op('int4_ops'),
),
index('TelecommunicationStationIdentification_stationIdentifier_idx').using(
'btree',
table.stationIdentifier.asc().nullsLast().op('text_ops'),
),
uniqueIndex(
'TelecommunicationStationIdentification_stationIdentifier_key',
).using('btree', table.stationIdentifier.asc().nullsLast().op('text_ops')),
foreignKey({
columns: [table.siteId],
foreignColumns: [site.id],
name: 'TelecommunicationStationIdentification_siteId_fkey',
})
.onUpdate('cascade')
.onDelete('cascade'),
],
);
export const partnerSite = pgTable('PartnerSite', {
id: serial().primaryKey().notNull(),
partnerId: integer().notNull(),
siteId: integer().notNull(),
createdAt: timestamp({ mode: 'string' }).defaultNow().notNull(),
updatedAt: timestamp({ mode: 'string' }).defaultNow().notNull(),
});
export const inspection = pgTable(
'Inspection',
{
id: serial().primaryKey().notNull(),
date: timestamp({ precision: 3, mode: 'string' }).notNull(),
comment: text(),
siteId: integer().notNull(),
createdAt: timestamp({ precision: 3, mode: 'string' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp({ precision: 3, mode: 'string' }).notNull(),
createdById: integer(),
updatedById: integer(),
status: inspectionStatus().default('PENDING').notNull(),
finalComment: text(),
finalCommentStatus: finalCommentStatus().default('PENDING'),
deadline: timestamp({ mode: 'string' }),
},
(table) => [
index('Inspection_createdById_idx').using(
'btree',
table.createdById.asc().nullsLast().op('int4_ops'),
),
index('Inspection_finalCommentStatus_idx').using(
'btree',
table.finalCommentStatus.asc().nullsLast().op('enum_ops'),
),
index('Inspection_siteId_idx').using(
'btree',
table.siteId.asc().nullsLast().op('int4_ops'),
),
index('Inspection_status_idx').using(
'btree',
table.status.asc().nullsLast().op('enum_ops'),
),
index('Inspection_updatedById_idx').using(
'btree',
table.updatedById.asc().nullsLast().op('int4_ops'),
),
foreignKey({
columns: [table.siteId],
foreignColumns: [site.id],
name: 'Inspection_siteId_fkey',
})
.onUpdate('cascade')
.onDelete('cascade'),
foreignKey({
columns: [table.createdById],
foreignColumns: [user.id],
name: 'Inspection_createdById_fkey',
})
.onUpdate('cascade')
.onDelete('set null'),
foreignKey({
columns: [table.updatedById],
foreignColumns: [user.id],
name: 'Inspection_updatedById_fkey',
})
.onUpdate('cascade')
.onDelete('set null'),
],
);
export const geographyColumns = pgView('geography_columns', {
// TODO: failed to parse database type 'name'
fTableCatalog: text('f_table_catalog'),
// TODO: failed to parse database type 'name'
fTableSchema: text('f_table_schema'),
// TODO: failed to parse database type 'name'
fTableName: text('f_table_name'),
// TODO: failed to parse database type 'name'
fGeographyColumn: text('f_geography_column'),
coordDimension: integer('coord_dimension'),
srid: integer(),
type: text(),
}).as(
sql`SELECT current_database() AS f_table_catalog, n.nspname AS f_table_schema, c.relname AS f_table_name, a.attname AS f_geography_column, postgis_typmod_dims(a.atttypmod) AS coord_dimension, postgis_typmod_srid(a.atttypmod) AS srid, postgis_typmod_type(a.atttypmod) AS type FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n WHERE t.typname = 'geography'::name AND a.attisdropped = false AND a.atttypid = t.oid AND a.attrelid = c.oid AND c.relnamespace = n.oid AND (c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'm'::"char", 'f'::"char", 'p'::"char"])) AND NOT pg_is_other_temp_schema(c.relnamespace) AND has_table_privilege(c.oid, 'SELECT'::text)`,
);
export const geometryColumns = pgView('geometry_columns', {
fTableCatalog: varchar('f_table_catalog', { length: 256 }),
// TODO: failed to parse database type 'name'
fTableSchema: text('f_table_schema'),
// TODO: failed to parse database type 'name'
fTableName: text('f_table_name'),
// TODO: failed to parse database type 'name'
fGeometryColumn: text('f_geometry_column'),
coordDimension: integer('coord_dimension'),
srid: integer(),
type: varchar({ length: 30 }),
}).as(
sql`SELECT current_database()::character varying(256) AS f_table_catalog, n.nspname AS f_table_schema, c.relname AS f_table_name, a.attname AS f_geometry_column, COALESCE(postgis_typmod_dims(a.atttypmod), sn.ndims, 2) AS coord_dimension, COALESCE(NULLIF(postgis_typmod_srid(a.atttypmod), 0), sr.srid, 0) AS srid, replace(replace(COALESCE(NULLIF(upper(postgis_typmod_type(a.atttypmod)), 'GEOMETRY'::text), st.type, 'GEOMETRY'::text), 'ZM'::text, ''::text), 'Z'::text, ''::text)::character varying(30) AS type FROM pg_class c JOIN pg_attribute a ON a.attrelid = c.oid AND NOT a.attisdropped JOIN pg_namespace n ON c.relnamespace = n.oid JOIN pg_type t ON a.atttypid = t.oid LEFT JOIN ( SELECT s.connamespace, s.conrelid, s.conkey, (regexp_match(s.consrc, 'geometrytype(w+)s*=s*(w+)'::text, 'i'::text))[1] AS type FROM ( SELECT pg_constraint.connamespace, pg_constraint.conrelid, pg_constraint.conkey, pg_get_constraintdef(pg_constraint.oid) AS consrc FROM pg_constraint) s WHERE s.consrc ~* 'geometrytype(w+)s*=s*w+'::text) st ON st.connamespace = n.oid AND st.conrelid = c.oid AND (a.attnum = ANY (st.conkey)) LEFT JOIN ( SELECT s.connamespace, s.conrelid, s.conkey, (regexp_match(s.consrc, 'ndims(w+)s*=s*(d+)'::text, 'i'::text))[1]::integer AS ndims FROM ( SELECT pg_constraint.connamespace, pg_constraint.conrelid, pg_constraint.conkey, pg_get_constraintdef(pg_constraint.oid) AS consrc FROM pg_constraint) s WHERE s.consrc ~* 'ndims(w+)s*=s*d+'::text) sn ON sn.connamespace = n.oid AND sn.conrelid = c.oid AND (a.attnum = ANY (sn.conkey)) LEFT JOIN ( SELECT s.connamespace, s.conrelid, s.conkey, (regexp_match(s.consrc, 'srid(w+)s*=s*(d+)'::text, 'i'::text))[1]::integer AS srid FROM ( SELECT pg_constraint.connamespace, pg_constraint.conrelid, pg_constraint.conkey, pg_get_constraintdef(pg_constraint.oid) AS consrc FROM pg_constraint) s WHERE s.consrc ~* 'srid(w+)s*=s*d+'::text) sr ON sr.connamespace = n.oid AND sr.conrelid = c.oid AND (a.attnum = ANY (sr.conkey)) WHERE (c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'm'::"char", 'f'::"char", 'p'::"char"])) AND NOT c.relname = 'raster_columns'::name AND t.typname = 'geometry'::name AND NOT pg_is_other_temp_schema(c.relnamespace) AND has_table_privilege(c.oid, 'SELECT'::text)`,
);
-- Migration to add partnerId to inspections table
-- This migration handles existing data by populating partnerId from current partner-site associations
-- Step 1: Add the column as nullable first
ALTER TABLE "Inspection" ADD COLUMN "partnerId" integer;
-- Step 2: Populate existing inspections with partnerId from current partner-site associations
UPDATE "Inspection"
SET "partnerId" = (
SELECT ps."partnerId"
FROM "PartnerSite" ps
WHERE ps."siteId" = "Inspection"."siteId"
LIMIT 1
)
WHERE "partnerId" IS NULL;
-- Step 3: For any inspections that still don't have a partnerId (sites without partners),
-- we need to either delete them or assign a default partner
-- Let's check if there are any such inspections first
-- If there are inspections without partners, we'll need to handle them
-- Step 4: Check for any remaining NULL values and handle them
-- Option 1: Delete inspections without partners (if that's acceptable)
-- DELETE FROM "Inspection" WHERE "partnerId" IS NULL;
-- Option 2: Assign a default partner (you'll need to create one if it doesn't exist)
-- First, let's create a default partner if it doesn't exist
INSERT INTO "Partner" ("name", "description", "isActive", "createdAt", "updatedAt")
SELECT 'Default Partner', 'Default partner for historical inspections', true, NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM "Partner" WHERE "name" = 'Default Partner');
-- Then assign this default partner to any remaining inspections without partners
UPDATE "Inspection"
SET "partnerId" = (SELECT id FROM "Partner" WHERE "name" = 'Default Partner' LIMIT 1)
WHERE "partnerId" IS NULL;
-- Step 5: Now we can safely make the column NOT NULL
ALTER TABLE "Inspection" ALTER COLUMN "partnerId" SET NOT NULL;
-- Step 6: Add foreign key constraint
ALTER TABLE "Inspection" ADD CONSTRAINT "Inspection_partnerId_Partner_id_fk"
FOREIGN KEY ("partnerId") REFERENCES "public"."Partner"("id") ON DELETE cascade ON UPDATE no action;
-- Step 7: Create index
CREATE INDEX "Inspection_partnerId_idx" ON "Inspection" USING btree ("partnerId");
......@@ -10,6 +10,7 @@ import {
pgEnum,
index,
uniqueIndex,
json,
} from 'drizzle-orm/pg-core';
import { relations } from 'drizzle-orm';
......@@ -56,6 +57,7 @@ export const users = pgTable(
password: varchar('password', { length: 255 }).notNull(),
role: roleEnum('role').notNull().default('VIEWER'),
signature: varchar('signature', { length: 500 }),
formationValidation: timestamp('formationValidation'),
createdAt: timestamp('createdAt').notNull().defaultNow(),
updatedAt: timestamp('updatedAt').notNull().defaultNow(),
resetToken: varchar('resetToken', { length: 255 }),
......@@ -185,9 +187,13 @@ export const inspections = pgTable(
finalComment: text('finalComment'),
finalCommentStatus:
inspectionStatusEnum('finalCommentStatus').default('PENDING'),
materialList: json('materialList'),
siteId: integer('siteId')
.notNull()
.references(() => sites.id, { onDelete: 'cascade' }),
partnerId: integer('partnerId')
.notNull()
.references(() => partners.id, { onDelete: 'cascade' }),
createdAt: timestamp('createdAt').notNull().defaultNow(),
updatedAt: timestamp('updatedAt').notNull().defaultNow(),
createdById: integer('createdById').references(() => users.id),
......@@ -198,6 +204,7 @@ export const inspections = pgTable(
},
(table) => ({
siteIdx: index('Inspection_siteId_idx').on(table.siteId),
partnerIdx: index('Inspection_partnerId_idx').on(table.partnerId),
createdByIdx: index('Inspection_createdById_idx').on(table.createdById),
updatedByIdx: index('Inspection_updatedById_idx').on(table.updatedById),
submittedByIdx: index('Inspection_submittedById_idx').on(
......@@ -252,6 +259,7 @@ export const inspectionPhotos = pgTable(
order: integer('order').notNull().default(0),
isPrincipal: boolean('isPrincipal').notNull().default(false),
isResume: boolean('isResume').notNull().default(false),
isAnomaly: boolean('isAnomaly').notNull().default(false),
createdAt: timestamp('createdAt').notNull().defaultNow(),
updatedAt: timestamp('updatedAt').notNull().defaultNow(),
inspectionId: integer('inspectionId')
......@@ -317,6 +325,7 @@ export const usersRelations = relations(users, ({ one, many }) => ({
export const partnersRelations = relations(partners, ({ many }) => ({
users: many(users),
sites: many(partnerSites),
inspections: many(inspections),
}));
export const refreshTokensRelations = relations(refreshTokens, ({ one }) => ({
......@@ -379,6 +388,10 @@ export const inspectionsRelations = relations(inspections, ({ one, many }) => ({
fields: [inspections.siteId],
references: [sites.id],
}),
partner: one(partners, {
fields: [inspections.partnerId],
references: [partners.id],
}),
createdBy: one(users, {
fields: [inspections.createdById],
references: [users.id],
......
......@@ -64,4 +64,13 @@ export class CreateInspectionPhotoDto {
@IsOptional()
@IsBoolean()
isResume?: boolean;
@ApiPropertyOptional({
description: 'Whether this photo represents an anomaly in the inspection',
example: false,
type: Boolean,
})
@IsOptional()
@IsBoolean()
isAnomaly?: boolean;
}
......@@ -68,6 +68,13 @@ export class InspectionPhotoResponseDto {
isResume: boolean;
@ApiProperty({
description: 'Whether this photo represents an anomaly in the inspection',
example: false,
type: Boolean,
})
isAnomaly: boolean;
@ApiProperty({
description: 'ID of the inspection this photo belongs to',
example: 1,
type: Number,
......
......@@ -47,4 +47,13 @@ export class UpdateInspectionPhotoDto {
@IsOptional()
@IsBoolean()
isResume?: boolean;
@ApiPropertyOptional({
description: 'Whether this photo represents an anomaly in the inspection',
example: true,
type: Boolean,
})
@IsOptional()
@IsBoolean()
isAnomaly?: boolean;
}
......@@ -82,6 +82,12 @@ export class InspectionPhotosController {
example: 'Front view of the site entrance',
description: 'Optional description for the photo',
},
isAnomaly: {
type: 'boolean',
example: false,
description:
'Whether this photo represents an anomaly in the inspection',
},
photo: {
type: 'string',
format: 'binary',
......
......@@ -79,6 +79,7 @@ export class InspectionPhotosService {
order: dto.order || 0,
isPrincipal: dto.isPrincipal || false,
isResume: dto.isResume || false,
isAnomaly: dto.isAnomaly || false,
inspectionId: dto.inspectionId,
createdAt: now,
updatedAt: now,
......@@ -241,6 +242,7 @@ export class InspectionPhotosService {
order: photo.order,
isPrincipal: photo.isPrincipal,
isResume: photo.isResume,
isAnomaly: photo.isAnomaly,
inspectionId: photo.inspectionId,
createdAt: photo.createdAt,
updatedAt: photo.updatedAt,
......
......@@ -5,6 +5,7 @@ import {
IsOptional,
IsString,
ValidateNested,
IsObject,
} from 'class-validator';
import { Type } from 'class-transformer';
import { InspectionResponseOption } from './inspection-response-option.enum';
......@@ -78,6 +79,36 @@ export class CreateInspectionDto {
@IsOptional()
finalComment?: string;
@ApiPropertyOptional({
description:
'Material list data as JSON object - can contain various material information',
example: {
materials: [
{
id: 'MAT001',
name: 'Cable RG-6',
quantity: 50,
unit: 'meters',
condition: 'good',
},
{
id: 'MAT002',
name: 'Connector BNC',
quantity: 20,
unit: 'pieces',
condition: 'excellent',
},
],
totalItems: 2,
lastUpdated: '2025-01-15T10:30:00Z',
},
type: 'object',
additionalProperties: true,
})
@IsObject()
@IsOptional()
materialList?: any;
@ApiProperty({
description: 'Responses to inspection questions',
type: [CreateInspectionResponseDto],
......
......@@ -6,3 +6,4 @@ export * from './inspection-response-option.enum';
export * from './start-inspection.dto';
export * from './update-final-comment.dto';
export * from './update-inspection-status.dto';
export * from './update-material-list.dto';
......@@ -239,4 +239,51 @@ export class InspectionDto {
isArray: true,
})
photos: InspectionPhotoDto[];
@ApiPropertyOptional({
description:
'Material list data as JSON object - can contain various material information',
example: {
materials: [
{
id: 'MAT001',
name: 'Cable RG-6',
quantity: 50,
unit: 'meters',
condition: 'good',
},
{
id: 'MAT002',
name: 'Connector BNC',
quantity: 20,
unit: 'pieces',
condition: 'excellent',
},
],
totalItems: 2,
lastUpdated: '2025-01-15T10:30:00Z',
},
type: 'object',
additionalProperties: true,
})
materialList?: any;
@ApiPropertyOptional({
description: 'Partner information at the time of inspection',
type: 'object',
properties: {
id: { type: 'number', example: 1 },
name: { type: 'string', example: 'Partner Company' },
description: { type: 'string', example: 'Partner description' },
logo: { type: 'string', example: '/uploads/logos/partner_logo.png' },
isActive: { type: 'boolean', example: true },
},
})
partner?: {
id: number;
name: string;
description?: string;
logo?: string;
isActive: boolean;
};
}
import { IsObject, IsOptional } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
export class UpdateMaterialListDto {
@ApiPropertyOptional({
description:
'Material list data as JSON object - can contain various material information',
example: {
materials: [
{
id: 'MAT001',
name: 'Cable RG-6',
quantity: 50,
unit: 'meters',
condition: 'good',
},
{
id: 'MAT002',
name: 'Connector BNC',
quantity: 20,
unit: 'pieces',
condition: 'excellent',
},
],
totalItems: 2,
lastUpdated: '2025-01-15T10:30:00Z',
},
type: 'object',
additionalProperties: true,
})
@IsObject()
@IsOptional()
materialList?: any;
}
......@@ -36,6 +36,7 @@ import { GenerateInspectionDto } from './dto/generate-inspection.dto';
import { UpdateInspectionStatusDto } from './dto/update-inspection-status.dto';
import { StartInspectionDto } from './dto/start-inspection.dto';
import { UpdateFinalCommentDto } from './dto/update-final-comment.dto';
import { UpdateMaterialListDto } from './dto/update-material-list.dto';
import { multerConfig } from '../../common/multer/multer.config';
import {
ApiTags,
......@@ -632,6 +633,83 @@ export class InspectionController {
);
}
@Patch(':id/material-list')
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMIN, Role.MANAGER, Role.OPERATOR, Role.PARTNER, Role.SUPERADMIN)
@ApiOperation({
summary: 'Update the material list of an inspection',
description:
'Updates the material list of an inspection with JSON data containing various material information.',
})
@ApiResponse({
status: 200,
description: 'The inspection material list has been successfully updated.',
schema: {
type: 'object',
properties: {
id: { type: 'number', example: 1 },
date: { type: 'string', format: 'date-time' },
deadline: { type: 'string', format: 'date-time', nullable: true },
comment: { type: 'string', nullable: true },
finalComment: { type: 'string', nullable: true },
finalCommentStatus: {
type: 'string',
enum: [
'PENDING',
'IN_PROGRESS',
'COMPLETED',
'CANCELLED',
'APPROVING',
'REJECTED',
'APPROVED',
],
},
materialList: { type: 'object', nullable: true },
siteId: { type: 'number' },
status: {
type: 'string',
enum: [
'PENDING',
'IN_PROGRESS',
'COMPLETED',
'CANCELLED',
'APPROVING',
'REJECTED',
'APPROVED',
],
},
createdAt: { type: 'string', format: 'date-time' },
updatedAt: { type: 'string', format: 'date-time' },
submittedBy: { type: 'object', nullable: true },
approvedBy: { type: 'object', nullable: true },
partner: { type: 'object', nullable: true },
responses: { type: 'array', items: { type: 'object' } },
photos: { type: 'array', items: { type: 'object' } },
},
},
})
@ApiParam({
name: 'id',
description: 'The ID of the inspection to update',
type: 'number',
example: 1,
})
@ApiBody({
type: UpdateMaterialListDto,
description: 'Material list data to update',
})
async updateMaterialList(
@Param('id', ParseIntPipe) id: number,
@Body() updateMaterialListDto: UpdateMaterialListDto,
@Req() req,
) {
return this.inspectionService.updateMaterialList(
id,
updateMaterialListDto,
req.user.id,
);
}
@Patch(':id/final-comment/validate')
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.PARTNER)
......
......@@ -41,6 +41,7 @@ import {
InspectionPhotoDto,
} from './dto/inspection-response.dto';
import { InspectionResponseOption } from './dto/inspection-response-option.enum';
import { UpdateMaterialListDto } from './dto/update-material-list.dto';
import { saveInspectionPhotos } from './inspection.utils';
@Injectable()
......@@ -55,17 +56,28 @@ export class InspectionService {
userId: number,
files?: Express.Multer.File[],
): Promise<InspectionDto> {
// Check if site exists
const siteList = await this.databaseService.db
.select()
// Check if site exists and get its associated partner
const siteWithPartner = await this.databaseService.db
.select({
siteId: sites.id,
partnerId: partnerSites.partnerId,
})
.from(sites)
.leftJoin(partnerSites, eq(partnerSites.siteId, sites.id))
.where(eq(sites.id, dto.siteId))
.limit(1);
if (siteList.length === 0) {
if (siteWithPartner.length === 0) {
throw new NotFoundException(`Site with ID ${dto.siteId} not found`);
}
const site = siteWithPartner[0];
if (!site.partnerId) {
throw new NotFoundException(
`No partner associated with site ${dto.siteId}`,
);
}
// Create inspection record
const now = new Date();
const [inspection] = await this.databaseService.db
......@@ -74,7 +86,9 @@ export class InspectionService {
date: new Date(dto.date),
comment: dto.comment,
finalComment: dto.finalComment,
materialList: dto.materialList,
siteId: dto.siteId,
partnerId: site.partnerId, // Store the partner ID at the time of inspection
createdById: userId,
createdAt: now,
updatedAt: now,
......@@ -199,6 +213,7 @@ export class InspectionService {
deadline: new Date(dto.deadline),
comment: dto.comment || null,
siteId: dto.siteId,
partnerId: partnerId, // Store the partner ID at the time of inspection
createdById: userId,
createdAt: now,
updatedAt: now,
......@@ -324,8 +339,30 @@ export class InspectionService {
async findInspectionById(id: number): Promise<InspectionDto> {
const inspectionList = await this.databaseService.db
.select()
.select({
id: inspections.id,
date: inspections.date,
deadline: inspections.deadline,
comment: inspections.comment,
finalComment: inspections.finalComment,
finalCommentStatus: inspections.finalCommentStatus,
materialList: inspections.materialList,
siteId: inspections.siteId,
partnerId: inspections.partnerId,
status: inspections.status,
createdAt: inspections.createdAt,
updatedAt: inspections.updatedAt,
createdById: inspections.createdById,
updatedById: inspections.updatedById,
submittedById: inspections.submittedById,
approvedById: inspections.approvedById,
partnerName: partners.name,
partnerDescription: partners.description,
partnerLogo: partners.logo,
partnerIsActive: partners.isActive,
})
.from(inspections)
.leftJoin(partners, eq(partners.id, inspections.partnerId))
.where(eq(inspections.id, id))
.limit(1);
......@@ -471,6 +508,18 @@ export class InspectionService {
const nextDeadline = new Date(deadlineDate);
nextDeadline.setFullYear(nextDeadline.getFullYear() + 1);
// Get the partnerId for this site
const partnerSiteList = await this.databaseService.db
.select({ partnerId: partnerSites.partnerId })
.from(partnerSites)
.where(eq(partnerSites.siteId, inspectionData.inspection.siteId))
.limit(1);
if (partnerSiteList.length === 0) {
// Skip this site if no partner is associated
continue;
}
// Create new inspection with next deadline
const [newInspection] = await this.databaseService.db
.insert(inspections)
......@@ -479,6 +528,7 @@ export class InspectionService {
deadline: nextDeadline,
comment: null,
siteId: inspectionData.inspection.siteId,
partnerId: partnerSiteList[0].partnerId,
createdById: userId,
createdAt: now,
updatedAt: now,
......@@ -824,6 +874,40 @@ export class InspectionService {
return this.mapToInspectionDto(updatedInspection);
}
async updateMaterialList(
id: number,
dto: UpdateMaterialListDto,
userId: number,
): Promise<InspectionDto> {
// Check if inspection exists
const existingInspection = await this.databaseService.db
.select()
.from(inspections)
.where(eq(inspections.id, id))
.limit(1);
if (existingInspection.length === 0) {
throw new NotFoundException(`Inspection with ID ${id} not found`);
}
// Update the materialList
const [updatedInspection] = await this.databaseService.db
.update(inspections)
.set({
materialList: dto.materialList,
updatedAt: new Date(),
updatedById: userId,
})
.where(eq(inspections.id, id))
.returning();
if (!updatedInspection) {
throw new NotFoundException(`Inspection with ID ${id} not found`);
}
return this.mapToInspectionDto(updatedInspection);
}
async validateFinalComment(
id: number,
action: 'validate' | 'reject',
......@@ -977,12 +1061,22 @@ export class InspectionService {
comment: inspection.comment,
finalComment: inspection.finalComment,
finalCommentStatus: inspection.finalCommentStatus,
materialList: inspection.materialList,
siteId: inspection.siteId,
status: inspection.status,
createdAt: inspection.createdAt,
updatedAt: inspection.updatedAt,
submittedBy: submittedBy || null,
approvedBy: approvedBy || null,
partner: inspection.partnerId
? {
id: inspection.partnerId,
name: inspection.partnerName,
description: inspection.partnerDescription,
logo: inspection.partnerLogo,
isActive: inspection.partnerIsActive,
}
: undefined,
responses: responses.map((response) => ({
id: response.id,
response: response.response,
......
......@@ -88,4 +88,15 @@ export class FindSitesDto {
@IsOptional()
@IsEnum(inspectionStatusEnum.enumValues)
inspectionStatus?: (typeof inspectionStatusEnum.enumValues)[number];
@ApiProperty({
required: false,
type: Number,
description: 'Filter sites by partner ID',
example: 1,
})
@IsOptional()
@Type(() => Number)
@IsInt()
partnerId?: number;
}
......@@ -89,7 +89,7 @@ export class SitesController {
@ApiOperation({
summary: 'Get all sites for list view (with pagination)',
description:
'Returns paginated sites with applied filters and ordering. You can filter by siteCode, siteName, address, city, state, country, and inspectionStatus (PENDING, IN_PROGRESS, COMPLETED, CANCELLED, APPROVING, REJECTED, APPROVED).',
'Returns paginated sites with applied filters and ordering. You can filter by siteCode, siteName, address, city, state, country, partnerId, and inspectionStatus (PENDING, IN_PROGRESS, COMPLETED, CANCELLED, APPROVING, REJECTED, APPROVED).',
})
@ApiResponse({
status: 200,
......@@ -116,7 +116,9 @@ export class SitesController {
},
})
async findAll(@Query() findSitesDto: FindSitesDto, @Request() req) {
const partnerId =
// For PARTNER and OPERATOR roles, use their partnerId as default
// But allow query parameter to override it
const userPartnerId =
req.user.role === Role.PARTNER || req.user.role === Role.OPERATOR
? req.user.partnerId
: null;
......@@ -124,7 +126,7 @@ export class SitesController {
// Debug logging to help identify the issue
if (
(req.user.role === Role.PARTNER || req.user.role === Role.OPERATOR) &&
!partnerId
!userPartnerId
) {
console.log(
'⚠️ User with role',
......@@ -134,7 +136,7 @@ export class SitesController {
);
}
return this.sitesService.findAll(findSitesDto, partnerId);
return this.sitesService.findAll(findSitesDto, userPartnerId);
}
@Get('code/:siteCode')
......
......@@ -205,14 +205,22 @@ export class SitesService {
const siteWhereCondition =
siteConditions.length > 0 ? and(...siteConditions) : undefined;
// Determine which partnerId to use: query parameter takes precedence over user's partnerId
const effectivePartnerId = findSitesDto?.partnerId || partnerId;
// Get total count with partner filtering if needed
let countQuery;
if (partnerId) {
if (effectivePartnerId) {
countQuery = this.databaseService.db
.select({ totalCount: count() })
.from(sites)
.leftJoin(partnerSites, eq(partnerSites.siteId, sites.id))
.where(and(siteWhereCondition, eq(partnerSites.partnerId, partnerId)));
.where(
and(
siteWhereCondition,
eq(partnerSites.partnerId, effectivePartnerId),
),
);
} else {
countQuery = this.databaseService.db
.select({ totalCount: count() })
......@@ -260,8 +268,11 @@ export class SitesService {
.leftJoin(partners, eq(partners.id, partnerSites.partnerId))
.where(
and(
partnerId
? and(siteWhereCondition, eq(partnerSites.partnerId, partnerId))
effectivePartnerId
? and(
siteWhereCondition,
eq(partnerSites.partnerId, effectivePartnerId),
)
: siteWhereCondition,
// Apply inspection status filter in WHERE clause to exclude null values
findSitesDto?.inspectionStatus
......
......@@ -6,6 +6,7 @@ import {
IsString,
MinLength,
IsOptional,
IsDate,
} from 'class-validator';
import { roleEnum } from '../../../database/schema';
......@@ -53,4 +54,14 @@ export class CreateUserDto {
@IsOptional()
@IsString()
signature?: string;
@ApiProperty({
description:
"Formation validation date - when the user's formation validation expires",
example: '2024-12-31T23:59:59.000Z',
required: false,
})
@IsOptional()
@IsDate()
formationValidation?: Date;
}
import { ApiProperty } from '@nestjs/swagger';
import { IsOptional, IsString, MinLength, IsDate } from 'class-validator';
export class UpdateProfileDto {
@ApiProperty({
description: 'The name of the user',
example: 'John Doe',
required: false,
})
@IsOptional()
@IsString()
name?: string;
@ApiProperty({
description: 'The email of the user',
example: 'john.doe@example.com',
required: false,
})
@IsOptional()
@IsString()
email?: string;
@ApiProperty({
description: 'The password of the user',
example: 'newpassword123',
minLength: 8,
required: false,
})
@IsOptional()
@IsString()
@MinLength(8)
password?: string;
@ApiProperty({
description: 'URL to the user signature image',
example: '/uploads/signatures/user123_signature.png',
required: false,
})
@IsOptional()
@IsString()
signature?: string;
@ApiProperty({
description:
"Formation validation date - when the user's formation validation expires",
example: '2024-12-31T23:59:59.000Z',
required: false,
})
@IsOptional()
@IsDate()
formationValidation?: Date;
}
......@@ -25,4 +25,14 @@ export class UpdateUserDto extends PartialType(CreateUserDto) {
@IsOptional()
@IsString()
signature?: string;
@ApiProperty({
description:
"Formation validation date - when the user's formation validation expires",
example: '2024-12-31T23:59:59.000Z',
required: false,
})
@IsOptional()
@IsDate()
formationValidation?: Date;
}
......@@ -16,6 +16,7 @@ import { FileInterceptor } from '@nestjs/platform-express';
import { UsersService } from './users.service';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { UpdateProfileDto } from './dto/update-profile.dto';
import { FindUsersDto, UserOrderBy } from './dto/find-users.dto';
import {
ApiTags,
......@@ -62,6 +63,16 @@ export class UsersController {
return this.usersService.create(createUserDto);
}
@Get('me')
@ApiOperation({ summary: 'Get current user info' })
@ApiResponse({
status: 200,
description: 'Return current user information.',
})
getCurrentUser(@User() user: any) {
return user;
}
@Get()
@Roles(
Role.ADMIN,
......@@ -148,18 +159,65 @@ export class UsersController {
}
@Patch(':id')
@Roles(Role.SUPERADMIN, Role.ADMIN)
@ApiOperation({ summary: 'Update a user' })
@Roles(
Role.SUPERADMIN,
Role.ADMIN,
Role.MANAGER,
Role.PARTNER,
Role.OPERATOR,
Role.VIEWER,
)
@ApiOperation({ summary: 'Update a user (Admin only or own profile)' })
@ApiResponse({
status: 200,
description: 'The user has been successfully updated.',
})
@ApiResponse({ status: 404, description: 'User not found.' })
@ApiResponse({
status: 403,
description:
'Forbidden - Can only update own profile or admin access required.',
})
update(
@Param('id', ParseIntPipe) id: number,
@Body() updateUserDto: UpdateUserDto,
@User('id') currentUserId: number,
@User('role') currentUserRole: string,
) {
return this.usersService.update(
id,
updateUserDto,
currentUserId,
currentUserRole,
);
}
@Patch('profile')
@Roles(
Role.SUPERADMIN,
Role.ADMIN,
Role.MANAGER,
Role.PARTNER,
Role.OPERATOR,
Role.VIEWER,
)
@ApiOperation({ summary: 'Update own profile' })
@ApiResponse({
status: 200,
description: 'The profile has been successfully updated.',
})
@ApiResponse({ status: 404, description: 'User not found.' })
updateProfile(
@User('id') userId: number,
@Body() updateProfileDto: UpdateProfileDto,
@User('role') currentUserRole: string,
) {
return this.usersService.update(id, updateUserDto);
return this.usersService.update(
userId,
updateProfileDto,
userId,
currentUserRole,
);
}
@Delete(':id')
......@@ -262,6 +320,8 @@ export class UsersController {
async uploadUserSignature(
@Param('id', ParseIntPipe) id: number,
@UploadedFile() file: Express.Multer.File,
@User('id') currentUserId: number,
@User('role') currentUserRole: string,
) {
try {
if (!file) {
......@@ -272,7 +332,12 @@ export class UsersController {
const signatureUrl = await saveUserSignature(file, id);
// Update the user with the signature URL
await this.usersService.update(id, { signature: signatureUrl });
await this.usersService.update(
id,
{ signature: signatureUrl },
currentUserId,
currentUserRole,
);
return {
message: 'Signature uploaded successfully',
......
......@@ -45,6 +45,7 @@ export class UsersService {
name: users.name,
role: users.role,
isActive: users.isActive,
formationValidation: users.formationValidation,
createdAt: users.createdAt,
updatedAt: users.updatedAt,
});
......@@ -144,6 +145,7 @@ export class UsersService {
role: users.role,
signature: users.signature,
isActive: users.isActive,
formationValidation: users.formationValidation,
createdAt: users.createdAt,
updatedAt: users.updatedAt,
partnerId: users.partnerId,
......@@ -175,6 +177,7 @@ export class UsersService {
role: users.role,
signature: users.signature,
isActive: users.isActive,
formationValidation: users.formationValidation,
createdAt: users.createdAt,
updatedAt: users.updatedAt,
partnerId: users.partnerId,
......@@ -190,7 +193,23 @@ export class UsersService {
return userList[0];
}
async update(id: number, updateUserDto: UpdateUserDto) {
async update(
id: number,
updateUserDto: UpdateUserDto,
currentUserId?: number,
currentUserRole?: string,
) {
// Check authorization: users can only update their own profile unless they are admin/superadmin
if (currentUserId && currentUserRole) {
const isAdmin =
currentUserRole === 'SUPERADMIN' || currentUserRole === 'ADMIN';
const isOwnProfile = currentUserId === id;
if (!isAdmin && !isOwnProfile) {
throw new ForbiddenException('You can only update your own profile');
}
}
const data: any = { ...updateUserDto };
if (updateUserDto.password) {
......@@ -208,6 +227,7 @@ export class UsersService {
name: users.name,
role: users.role,
isActive: users.isActive,
formationValidation: users.formationValidation,
createdAt: users.createdAt,
updatedAt: users.updatedAt,
partnerId: users.partnerId,
......@@ -284,6 +304,7 @@ export class UsersService {
name: users.name,
role: users.role,
isActive: users.isActive,
formationValidation: users.formationValidation,
createdAt: users.createdAt,
updatedAt: users.updatedAt,
partnerId: users.partnerId,
......@@ -318,6 +339,7 @@ export class UsersService {
name: users.name,
role: users.role,
isActive: users.isActive,
formationValidation: users.formationValidation,
createdAt: users.createdAt,
updatedAt: users.updatedAt,
partnerId: users.partnerId,
......@@ -341,6 +363,7 @@ export class UsersService {
name: users.name,
role: users.role,
isActive: users.isActive,
formationValidation: users.formationValidation,
createdAt: users.createdAt,
updatedAt: users.updatedAt,
partnerId: users.partnerId,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment