From e357902b8bc53b4f0f2f87497fdaf0f5bc62d364 Mon Sep 17 00:00:00 2001 From: Dev-CasperTheGhost <53900565+Dev-CasperTheGhost@users.noreply.github.com> Date: Tue, 26 Oct 2021 20:06:16 +0200 Subject: [PATCH] :tada: 0.2.0-alpha --- package.json | 2 +- packages/api/package.json | 6 +-- .../migrations/20211024124930_/migration.sql | 20 --------- .../migrations/20211025145727_/migration.sql | 21 ---------- .../migrations/20211025150350_/migration.sql | 17 -------- .../migrations/20211025152858_/migration.sql | 17 -------- .../migrations/20211026055452_/migration.sql | 12 ------ .../migration.sql | 42 ++++++++++++------- packages/client/package.json | 6 +-- packages/config/package.json | 2 +- packages/schemas/package.json | 2 +- yarn.lock | 12 +++--- 12 files changed, 43 insertions(+), 116 deletions(-) delete mode 100644 packages/api/prisma/migrations/20211024124930_/migration.sql delete mode 100644 packages/api/prisma/migrations/20211025145727_/migration.sql delete mode 100644 packages/api/prisma/migrations/20211025150350_/migration.sql delete mode 100644 packages/api/prisma/migrations/20211025152858_/migration.sql delete mode 100644 packages/api/prisma/migrations/20211026055452_/migration.sql rename packages/api/prisma/migrations/{20211024090058_ => 20211026180526_}/migration.sql (94%) diff --git a/package.json b/package.json index 280c906a7..d16df4154 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "snailycad", - "version": "0.1.0-alpha", + "version": "0.2.0-alpha", "packageManager": "yarn@3.0.2", "workspaces": [ "packages/**" diff --git a/packages/api/package.json b/packages/api/package.json index cd08b829d..6d6f1e131 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@snailycad/api", - "version": "0.1.0-alpha", + "version": "0.2.0-alpha", "scripts": { "dev": "prisma migrate dev && prisma generate && nodemon --watch \"src/**/*.ts\" --ignore \"node_modules/**/*\" --exec ts-node src/main.ts", "start": "yarn workspace @snailycad/schemas build && yarn workspace @snailycad/config build && npx prisma migrate deploy && ts-node src/main.ts", @@ -24,8 +24,8 @@ "dependencies": { "@casper124578/utils": "^1.4.0", "@prisma/client": "^3.3.0", - "@snailycad/config": "0.1.0-alpha", - "@snailycad/schemas": "0.1.0-alpha", + "@snailycad/config": "0.2.0-alpha", + "@snailycad/schemas": "0.2.0-alpha", "@tsed/common": "^6.75.7", "@tsed/core": "^6.75.7", "@tsed/di": "^6.75.7", diff --git a/packages/api/prisma/migrations/20211024124930_/migration.sql b/packages/api/prisma/migrations/20211024124930_/migration.sql deleted file mode 100644 index 148760f4e..000000000 --- a/packages/api/prisma/migrations/20211024124930_/migration.sql +++ /dev/null @@ -1,20 +0,0 @@ --- DropForeignKey -ALTER TABLE "PenalCode" DROP CONSTRAINT "PenalCode_recordId_fkey"; - --- CreateTable -CREATE TABLE "_PenalCodeToRecord" ( - "A" TEXT NOT NULL, - "B" TEXT NOT NULL -); - --- CreateIndex -CREATE UNIQUE INDEX "_PenalCodeToRecord_AB_unique" ON "_PenalCodeToRecord"("A", "B"); - --- CreateIndex -CREATE INDEX "_PenalCodeToRecord_B_index" ON "_PenalCodeToRecord"("B"); - --- AddForeignKey -ALTER TABLE "_PenalCodeToRecord" ADD FOREIGN KEY ("A") REFERENCES "PenalCode"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_PenalCodeToRecord" ADD FOREIGN KEY ("B") REFERENCES "Record"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/packages/api/prisma/migrations/20211025145727_/migration.sql b/packages/api/prisma/migrations/20211025145727_/migration.sql deleted file mode 100644 index d87e236e0..000000000 --- a/packages/api/prisma/migrations/20211025145727_/migration.sql +++ /dev/null @@ -1,21 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `assignedStatusCode` on the `MiscCadSettings` table. All the data in the column will be lost. - - You are about to drop the column `onDutyCode` on the `MiscCadSettings` table. All the data in the column will be lost. - -*/ --- AlterEnum --- This migration adds more than one value to an enum. --- With PostgreSQL versions 11 and earlier, this is not possible --- in a single migration. This can be worked around by creating --- multiple migrations, each migration adding only one value to --- the enum. - - -ALTER TYPE "ShouldDoType" ADD VALUE 'SET_ON_DUTY'; -ALTER TYPE "ShouldDoType" ADD VALUE 'SET_ASSIGNED'; - --- AlterTable -ALTER TABLE "MiscCadSettings" DROP COLUMN "assignedStatusCode", -DROP COLUMN "onDutyCode"; diff --git a/packages/api/prisma/migrations/20211025150350_/migration.sql b/packages/api/prisma/migrations/20211025150350_/migration.sql deleted file mode 100644 index c158c26db..000000000 --- a/packages/api/prisma/migrations/20211025150350_/migration.sql +++ /dev/null @@ -1,17 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `status` on the `Officer` table. All the data in the column will be lost. - - You are about to drop the column `status2Id` on the `Officer` table. All the data in the column will be lost. - -*/ --- DropForeignKey -ALTER TABLE "Officer" DROP CONSTRAINT "Officer_status2Id_fkey"; - --- AlterTable -ALTER TABLE "Officer" DROP COLUMN "status", -DROP COLUMN "status2Id", -ADD COLUMN "statusId" TEXT; - --- AddForeignKey -ALTER TABLE "Officer" ADD CONSTRAINT "Officer_statusId_fkey" FOREIGN KEY ("statusId") REFERENCES "StatusValue"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/packages/api/prisma/migrations/20211025152858_/migration.sql b/packages/api/prisma/migrations/20211025152858_/migration.sql deleted file mode 100644 index 299ba8777..000000000 --- a/packages/api/prisma/migrations/20211025152858_/migration.sql +++ /dev/null @@ -1,17 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `status` on the `EmsFdDeputy` table. All the data in the column will be lost. - - You are about to drop the column `status2Id` on the `EmsFdDeputy` table. All the data in the column will be lost. - -*/ --- DropForeignKey -ALTER TABLE "EmsFdDeputy" DROP CONSTRAINT "EmsFdDeputy_status2Id_fkey"; - --- AlterTable -ALTER TABLE "EmsFdDeputy" DROP COLUMN "status", -DROP COLUMN "status2Id", -ADD COLUMN "statusId" TEXT; - --- AddForeignKey -ALTER TABLE "EmsFdDeputy" ADD CONSTRAINT "EmsFdDeputy_statusId_fkey" FOREIGN KEY ("statusId") REFERENCES "StatusValue"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/packages/api/prisma/migrations/20211026055452_/migration.sql b/packages/api/prisma/migrations/20211026055452_/migration.sql deleted file mode 100644 index 123a7a146..000000000 --- a/packages/api/prisma/migrations/20211026055452_/migration.sql +++ /dev/null @@ -1,12 +0,0 @@ --- DropForeignKey -ALTER TABLE "Officer" DROP CONSTRAINT "Officer_citizenId_fkey"; - --- AlterTable -ALTER TABLE "DivisionValue" ADD COLUMN "callsign" TEXT; - --- AlterTable -ALTER TABLE "MiscCadSettings" ADD COLUMN "callsignTemplate" TEXT NOT NULL DEFAULT E'{department}{callsign1} - {callsign2}{division}', -ADD COLUMN "pairedUnitSymbol" VARCHAR(255) NOT NULL DEFAULT E'A'; - --- AddForeignKey -ALTER TABLE "Officer" ADD CONSTRAINT "Officer_citizenId_fkey" FOREIGN KEY ("citizenId") REFERENCES "Citizen"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/packages/api/prisma/migrations/20211024090058_/migration.sql b/packages/api/prisma/migrations/20211026180526_/migration.sql similarity index 94% rename from packages/api/prisma/migrations/20211024090058_/migration.sql rename to packages/api/prisma/migrations/20211026180526_/migration.sql index 9ebf0dfe2..6f6f73090 100644 --- a/packages/api/prisma/migrations/20211024090058_/migration.sql +++ b/packages/api/prisma/migrations/20211026180526_/migration.sql @@ -1,5 +1,5 @@ -- CreateEnum -CREATE TYPE "Rank" AS ENUM ('OWNER', 'ADMIN', 'MODERATOR', 'USER'); +CREATE TYPE "Rank" AS ENUM ('OWNER', 'ADMIN', 'USER'); -- CreateEnum CREATE TYPE "WhitelistStatus" AS ENUM ('ACCEPTED', 'PENDING', 'DECLINED'); @@ -17,7 +17,7 @@ CREATE TYPE "StatusEnum" AS ENUM ('ON_DUTY', 'OFF_DUTY'); CREATE TYPE "WhatPages" AS ENUM ('DISPATCH', 'EMS_FD', 'LEO'); -- CreateEnum -CREATE TYPE "ShouldDoType" AS ENUM ('SET_OFF_DUTY', 'SET_STATUS'); +CREATE TYPE "ShouldDoType" AS ENUM ('SET_OFF_DUTY', 'SET_ON_DUTY', 'SET_ASSIGNED', 'SET_STATUS'); -- CreateEnum CREATE TYPE "BoloType" AS ENUM ('VEHICLE', 'PERSON', 'OTHER'); @@ -59,8 +59,8 @@ CREATE TABLE "MiscCadSettings" ( "maxCitizensPerUser" INTEGER, "maxPlateLength" INTEGER NOT NULL DEFAULT 8, "maxBusinessesPerCitizen" INTEGER, - "assignedStatusCode" TEXT NOT NULL DEFAULT E'10-97', - "onDutyCode" TEXT NOT NULL DEFAULT E'10-8', + "callsignTemplate" TEXT NOT NULL DEFAULT E'{department}{callsign1} - {callsign2}{division}', + "pairedUnitSymbol" VARCHAR(255) NOT NULL DEFAULT E'A', CONSTRAINT "MiscCadSettings_pkey" PRIMARY KEY ("id") ); @@ -180,6 +180,7 @@ CREATE TABLE "DivisionValue" ( "id" TEXT NOT NULL, "valueId" TEXT NOT NULL, "departmentId" TEXT, + "callsign" TEXT, CONSTRAINT "DivisionValue_pkey" PRIMARY KEY ("id") ); @@ -290,8 +291,7 @@ CREATE TABLE "Officer" ( "callsign" VARCHAR(255) NOT NULL, "divisionId" TEXT NOT NULL, "rankId" TEXT, - "status" "StatusEnum" NOT NULL DEFAULT E'OFF_DUTY', - "status2Id" TEXT, + "statusId" TEXT, "suspended" BOOLEAN NOT NULL DEFAULT false, "badgeNumber" INTEGER, "citizenId" TEXT, @@ -394,8 +394,7 @@ CREATE TABLE "EmsFdDeputy" ( "callsign" VARCHAR(255) NOT NULL, "divisionId" TEXT NOT NULL, "rankId" TEXT, - "status" "StatusEnum" NOT NULL DEFAULT E'OFF_DUTY', - "status2Id" TEXT, + "statusId" TEXT, "suspended" BOOLEAN NOT NULL DEFAULT false, "badgeNumber" INTEGER, "citizenId" TEXT, @@ -416,6 +415,12 @@ CREATE TABLE "TruckLog" ( CONSTRAINT "TruckLog_pkey" PRIMARY KEY ("id") ); +-- CreateTable +CREATE TABLE "_PenalCodeToRecord" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL +); + -- CreateIndex CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); @@ -428,6 +433,12 @@ CREATE UNIQUE INDEX "RegisteredVehicle_plate_key" ON "RegisteredVehicle"("plate" -- CreateIndex CREATE UNIQUE INDEX "Weapon_serialNumber_key" ON "Weapon"("serialNumber"); +-- CreateIndex +CREATE UNIQUE INDEX "_PenalCodeToRecord_AB_unique" ON "_PenalCodeToRecord"("A", "B"); + +-- CreateIndex +CREATE INDEX "_PenalCodeToRecord_B_index" ON "_PenalCodeToRecord"("B"); + -- AddForeignKey ALTER TABLE "cad" ADD CONSTRAINT "cad_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; @@ -485,9 +496,6 @@ ALTER TABLE "MedicalRecord" ADD CONSTRAINT "MedicalRecord_userId_fkey" FOREIGN K -- AddForeignKey ALTER TABLE "MedicalRecord" ADD CONSTRAINT "MedicalRecord_citizenId_fkey" FOREIGN KEY ("citizenId") REFERENCES "Citizen"("id") ON DELETE RESTRICT ON UPDATE CASCADE; --- AddForeignKey -ALTER TABLE "PenalCode" ADD CONSTRAINT "PenalCode_recordId_fkey" FOREIGN KEY ("recordId") REFERENCES "Record"("id") ON DELETE SET NULL ON UPDATE CASCADE; - -- AddForeignKey ALTER TABLE "DivisionValue" ADD CONSTRAINT "DivisionValue_valueId_fkey" FOREIGN KEY ("valueId") REFERENCES "Value"("id") ON DELETE CASCADE ON UPDATE CASCADE; @@ -561,10 +569,10 @@ ALTER TABLE "Officer" ADD CONSTRAINT "Officer_divisionId_fkey" FOREIGN KEY ("div ALTER TABLE "Officer" ADD CONSTRAINT "Officer_rankId_fkey" FOREIGN KEY ("rankId") REFERENCES "Value"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "Officer" ADD CONSTRAINT "Officer_status2Id_fkey" FOREIGN KEY ("status2Id") REFERENCES "StatusValue"("id") ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE "Officer" ADD CONSTRAINT "Officer_statusId_fkey" FOREIGN KEY ("statusId") REFERENCES "StatusValue"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "Officer" ADD CONSTRAINT "Officer_citizenId_fkey" FOREIGN KEY ("citizenId") REFERENCES "Citizen"("id") ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE "Officer" ADD CONSTRAINT "Officer_citizenId_fkey" FOREIGN KEY ("citizenId") REFERENCES "Citizen"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Officer" ADD CONSTRAINT "Officer_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; @@ -612,7 +620,7 @@ ALTER TABLE "EmsFdDeputy" ADD CONSTRAINT "EmsFdDeputy_divisionId_fkey" FOREIGN K ALTER TABLE "EmsFdDeputy" ADD CONSTRAINT "EmsFdDeputy_rankId_fkey" FOREIGN KEY ("rankId") REFERENCES "Value"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "EmsFdDeputy" ADD CONSTRAINT "EmsFdDeputy_status2Id_fkey" FOREIGN KEY ("status2Id") REFERENCES "StatusValue"("id") ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE "EmsFdDeputy" ADD CONSTRAINT "EmsFdDeputy_statusId_fkey" FOREIGN KEY ("statusId") REFERENCES "StatusValue"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "EmsFdDeputy" ADD CONSTRAINT "EmsFdDeputy_citizenId_fkey" FOREIGN KEY ("citizenId") REFERENCES "Citizen"("id") ON DELETE CASCADE ON UPDATE CASCADE; @@ -628,3 +636,9 @@ ALTER TABLE "TruckLog" ADD CONSTRAINT "TruckLog_userId_fkey" FOREIGN KEY ("userI -- AddForeignKey ALTER TABLE "TruckLog" ADD CONSTRAINT "TruckLog_vehicleId_fkey" FOREIGN KEY ("vehicleId") REFERENCES "RegisteredVehicle"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PenalCodeToRecord" ADD FOREIGN KEY ("A") REFERENCES "PenalCode"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PenalCodeToRecord" ADD FOREIGN KEY ("B") REFERENCES "Record"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/packages/client/package.json b/packages/client/package.json index fa3df7bf3..a6ba56de9 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@snailycad/client", - "version": "0.1.0-alpha", + "version": "0.2.0-alpha", "scripts": { "dev": "next dev", "build": "next build", @@ -12,8 +12,8 @@ "@casper124578/use-socket.io": "2.0.0", "@casper124578/utils": "^1.4.0", "@headlessui/react": "^1.4.1", - "@snailycad/config": "0.1.0-alpha", - "@snailycad/schemas": "0.1.0-alpha", + "@snailycad/config": "0.2.0-alpha", + "@snailycad/schemas": "0.2.0-alpha", "axios": "^0.24.0", "date-fns": "^2.25.0", "formik": "^2.2.9", diff --git a/packages/config/package.json b/packages/config/package.json index 987475d08..390f05224 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@snailycad/config", - "version": "0.1.0-alpha", + "version": "0.2.0-alpha", "main": "./dist/index.js", "scripts": { "build": "tsc" diff --git a/packages/schemas/package.json b/packages/schemas/package.json index 0d4954a9f..712613ffd 100644 --- a/packages/schemas/package.json +++ b/packages/schemas/package.json @@ -1,6 +1,6 @@ { "name": "@snailycad/schemas", - "version": "0.1.0-alpha", + "version": "0.2.0-alpha", "main": "./dist/index.js", "scripts": { "build": "tsc" diff --git a/yarn.lock b/yarn.lock index 87f5f40f7..b736b3715 100644 --- a/yarn.lock +++ b/yarn.lock @@ -664,8 +664,8 @@ __metadata: dependencies: "@casper124578/utils": ^1.4.0 "@prisma/client": ^3.3.0 - "@snailycad/config": 0.1.0-alpha - "@snailycad/schemas": 0.1.0-alpha + "@snailycad/config": 0.2.0-alpha + "@snailycad/schemas": 0.2.0-alpha "@tsed/common": ^6.75.7 "@tsed/core": ^6.75.7 "@tsed/di": ^6.75.7 @@ -711,8 +711,8 @@ __metadata: "@casper124578/use-socket.io": 2.0.0 "@casper124578/utils": ^1.4.0 "@headlessui/react": ^1.4.1 - "@snailycad/config": 0.1.0-alpha - "@snailycad/schemas": 0.1.0-alpha + "@snailycad/config": 0.2.0-alpha + "@snailycad/schemas": 0.2.0-alpha "@types/react": ^17.0.33 "@types/react-dom": ^17.0.10 autoprefixer: ^10.3.7 @@ -739,7 +739,7 @@ __metadata: languageName: unknown linkType: soft -"@snailycad/config@0.1.0-alpha, @snailycad/config@workspace:packages/config": +"@snailycad/config@0.2.0-alpha, @snailycad/config@workspace:packages/config": version: 0.0.0-use.local resolution: "@snailycad/config@workspace:packages/config" dependencies: @@ -748,7 +748,7 @@ __metadata: languageName: unknown linkType: soft -"@snailycad/schemas@0.1.0-alpha, @snailycad/schemas@workspace:packages/schemas": +"@snailycad/schemas@0.2.0-alpha, @snailycad/schemas@workspace:packages/schemas": version: 0.0.0-use.local resolution: "@snailycad/schemas@workspace:packages/schemas" dependencies: