Merge branch 'dev' into staging

This commit is contained in:
Vins 2023-09-26 15:03:03 +02:00
commit feefd9ba05
21 changed files with 212 additions and 811 deletions

View File

@ -1,14 +0,0 @@
/*
Warnings:
- You are about to alter the column `roles_uid` on the `users` table. The data in that column could be lost. The data in that column will be cast from `Text` to `VarChar(255)`.
*/
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_roles_uid_fkey";
-- AlterTable
ALTER TABLE "users" ALTER COLUMN "roles_uid" SET DATA TYPE VARCHAR(255);
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_roles_uid_fkey" FOREIGN KEY ("roles_uid") REFERENCES "roles"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,37 +0,0 @@
/*
Warnings:
- You are about to drop the column `office_role_has_rules_uid` on the `rules` table. All the data in the column will be lost.
- You are about to drop the column `role_has_rules_uid` on the `rules` table. All the data in the column will be lost.
- Added the required column `office_uid` to the `office_role_has_rules` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "rules" DROP CONSTRAINT "rules_office_role_has_rules_uid_fkey";
-- DropForeignKey
ALTER TABLE "rules" DROP CONSTRAINT "rules_role_has_rules_uid_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_roles_uid_fkey";
-- AlterTable
ALTER TABLE "office_role_has_rules" ADD COLUMN "office_uid" VARCHAR(255) NOT NULL;
-- AlterTable
ALTER TABLE "rules" DROP COLUMN "office_role_has_rules_uid",
DROP COLUMN "role_has_rules_uid",
ADD COLUMN "officesRolesHasRulesUid" TEXT,
ADD COLUMN "rolesHasRulesUid" TEXT;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_roles_uid_fkey" FOREIGN KEY ("roles_uid") REFERENCES "roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "rules" ADD CONSTRAINT "rules_rolesHasRulesUid_fkey" FOREIGN KEY ("rolesHasRulesUid") REFERENCES "role_has_rules"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "rules" ADD CONSTRAINT "rules_officesRolesHasRulesUid_fkey" FOREIGN KEY ("officesRolesHasRulesUid") REFERENCES "office_role_has_rules"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "office_role_has_rules" ADD CONSTRAINT "office_role_has_rules_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,24 +0,0 @@
/*
Warnings:
- You are about to drop the column `officesRolesHasRulesUid` on the `rules` table. All the data in the column will be lost.
- You are about to drop the column `rolesHasRulesUid` on the `rules` table. All the data in the column will be lost.
*/
-- DropForeignKey
ALTER TABLE "rules" DROP CONSTRAINT "rules_officesRolesHasRulesUid_fkey";
-- DropForeignKey
ALTER TABLE "rules" DROP CONSTRAINT "rules_rolesHasRulesUid_fkey";
-- AlterTable
ALTER TABLE "rules" DROP COLUMN "officesRolesHasRulesUid",
DROP COLUMN "rolesHasRulesUid",
ADD COLUMN "office_role_has_rules_uid" TEXT,
ADD COLUMN "role_has_rules_uid" TEXT;
-- AddForeignKey
ALTER TABLE "rules" ADD CONSTRAINT "rules_role_has_rules_uid_fkey" FOREIGN KEY ("role_has_rules_uid") REFERENCES "role_has_rules"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "rules" ADD CONSTRAINT "rules_office_role_has_rules_uid_fkey" FOREIGN KEY ("office_role_has_rules_uid") REFERENCES "office_role_has_rules"("uid") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -1,12 +0,0 @@
/*
Warnings:
- You are about to drop the column `rule_uid` on the `office_role_has_rules` table. All the data in the column will be lost.
- You are about to drop the column `rule_uid` on the `role_has_rules` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "office_role_has_rules" DROP COLUMN "rule_uid";
-- AlterTable
ALTER TABLE "role_has_rules" DROP COLUMN "rule_uid";

View File

@ -1,30 +0,0 @@
/*
Warnings:
- You are about to drop the column `office_role_has_rules_uid` on the `rules` table. All the data in the column will be lost.
- You are about to drop the column `role_has_rules_uid` on the `rules` table. All the data in the column will be lost.
- Added the required column `rule_uid` to the `office_role_has_rules` table without a default value. This is not possible if the table is not empty.
- Added the required column `rule_uid` to the `role_has_rules` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "rules" DROP CONSTRAINT "rules_office_role_has_rules_uid_fkey";
-- DropForeignKey
ALTER TABLE "rules" DROP CONSTRAINT "rules_role_has_rules_uid_fkey";
-- AlterTable
ALTER TABLE "office_role_has_rules" ADD COLUMN "rule_uid" VARCHAR(255) NOT NULL;
-- AlterTable
ALTER TABLE "role_has_rules" ADD COLUMN "rule_uid" VARCHAR(255) NOT NULL;
-- AlterTable
ALTER TABLE "rules" DROP COLUMN "office_role_has_rules_uid",
DROP COLUMN "role_has_rules_uid";
-- AddForeignKey
ALTER TABLE "role_has_rules" ADD CONSTRAINT "role_has_rules_rule_uid_fkey" FOREIGN KEY ("rule_uid") REFERENCES "rules"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "office_role_has_rules" ADD CONSTRAINT "office_role_has_rules_rule_uid_fkey" FOREIGN KEY ("rule_uid") REFERENCES "rules"("uid") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,86 +0,0 @@
/*
Warnings:
- You are about to drop the `office_role_has_rules` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `role_has_rules` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "office_role_has_rules" DROP CONSTRAINT "office_role_has_rules_office_uid_fkey";
-- DropForeignKey
ALTER TABLE "office_role_has_rules" DROP CONSTRAINT "office_role_has_rules_role_uid_fkey";
-- DropForeignKey
ALTER TABLE "office_role_has_rules" DROP CONSTRAINT "office_role_has_rules_rule_uid_fkey";
-- DropForeignKey
ALTER TABLE "role_has_rules" DROP CONSTRAINT "role_has_rules_role_uid_fkey";
-- DropForeignKey
ALTER TABLE "role_has_rules" DROP CONSTRAINT "role_has_rules_rule_uid_fkey";
-- AlterTable
ALTER TABLE "users" ADD COLUMN "office_role_uid" VARCHAR(255);
-- DropTable
DROP TABLE "office_role_has_rules";
-- DropTable
DROP TABLE "role_has_rules";
-- CreateTable
CREATE TABLE "office_roles" (
"uid" TEXT NOT NULL,
"name" VARCHAR(255) NOT NULL,
"office_uid" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
CONSTRAINT "office_roles_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "_RolesHasRules" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "_OfficeRolesHasRules" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "office_roles_uid_key" ON "office_roles"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "_RolesHasRules_AB_unique" ON "_RolesHasRules"("A", "B");
-- CreateIndex
CREATE INDEX "_RolesHasRules_B_index" ON "_RolesHasRules"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_OfficeRolesHasRules_AB_unique" ON "_OfficeRolesHasRules"("A", "B");
-- CreateIndex
CREATE INDEX "_OfficeRolesHasRules_B_index" ON "_OfficeRolesHasRules"("B");
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_office_role_uid_fkey" FOREIGN KEY ("office_role_uid") REFERENCES "office_roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "office_roles" ADD CONSTRAINT "office_roles_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_RolesHasRules" ADD CONSTRAINT "_RolesHasRules_A_fkey" FOREIGN KEY ("A") REFERENCES "roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_RolesHasRules" ADD CONSTRAINT "_RolesHasRules_B_fkey" FOREIGN KEY ("B") REFERENCES "rules"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_OfficeRolesHasRules" ADD CONSTRAINT "_OfficeRolesHasRules_A_fkey" FOREIGN KEY ("A") REFERENCES "office_roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_OfficeRolesHasRules" ADD CONSTRAINT "_OfficeRolesHasRules_B_fkey" FOREIGN KEY ("B") REFERENCES "rules"("uid") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,144 +0,0 @@
/*
Warnings:
- You are about to drop the `deed_has_document_types` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `deed_type_has_document_types` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `office_folder_has_customers` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `office_folder_has_stakeholder` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `user_has_notifications` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "deed_has_document_types" DROP CONSTRAINT "deed_has_document_types_deed_uid_fkey";
-- DropForeignKey
ALTER TABLE "deed_has_document_types" DROP CONSTRAINT "deed_has_document_types_document_type_uid_fkey";
-- DropForeignKey
ALTER TABLE "deed_type_has_document_types" DROP CONSTRAINT "deed_type_has_document_types_deed_type_uid_fkey";
-- DropForeignKey
ALTER TABLE "deed_type_has_document_types" DROP CONSTRAINT "deed_type_has_document_types_document_type_uid_fkey";
-- DropForeignKey
ALTER TABLE "office_folder_has_customers" DROP CONSTRAINT "office_folder_has_customers_customer_uid_fkey";
-- DropForeignKey
ALTER TABLE "office_folder_has_customers" DROP CONSTRAINT "office_folder_has_customers_office_folder_uid_fkey";
-- DropForeignKey
ALTER TABLE "office_folder_has_stakeholder" DROP CONSTRAINT "office_folder_has_stakeholder_office_folder_uid_fkey";
-- DropForeignKey
ALTER TABLE "office_folder_has_stakeholder" DROP CONSTRAINT "office_folder_has_stakeholder_user_stakeholder_uid_fkey";
-- DropForeignKey
ALTER TABLE "user_has_notifications" DROP CONSTRAINT "user_has_notifications_notification_uid_fkey";
-- DropForeignKey
ALTER TABLE "user_has_notifications" DROP CONSTRAINT "user_has_notifications_user_uid_fkey";
-- DropTable
DROP TABLE "deed_has_document_types";
-- DropTable
DROP TABLE "deed_type_has_document_types";
-- DropTable
DROP TABLE "office_folder_has_customers";
-- DropTable
DROP TABLE "office_folder_has_stakeholder";
-- DropTable
DROP TABLE "user_has_notifications";
-- CreateTable
CREATE TABLE "_OfficeFolderHasCustomers" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "_UserHasNotifications" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "_OfficeFolderHasStakeholders" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "_DeedHasDocumentTypes" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "_DeedTypeHasDocumentTypes" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "_OfficeFolderHasCustomers_AB_unique" ON "_OfficeFolderHasCustomers"("A", "B");
-- CreateIndex
CREATE INDEX "_OfficeFolderHasCustomers_B_index" ON "_OfficeFolderHasCustomers"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_UserHasNotifications_AB_unique" ON "_UserHasNotifications"("A", "B");
-- CreateIndex
CREATE INDEX "_UserHasNotifications_B_index" ON "_UserHasNotifications"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_OfficeFolderHasStakeholders_AB_unique" ON "_OfficeFolderHasStakeholders"("A", "B");
-- CreateIndex
CREATE INDEX "_OfficeFolderHasStakeholders_B_index" ON "_OfficeFolderHasStakeholders"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_DeedHasDocumentTypes_AB_unique" ON "_DeedHasDocumentTypes"("A", "B");
-- CreateIndex
CREATE INDEX "_DeedHasDocumentTypes_B_index" ON "_DeedHasDocumentTypes"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_DeedTypeHasDocumentTypes_AB_unique" ON "_DeedTypeHasDocumentTypes"("A", "B");
-- CreateIndex
CREATE INDEX "_DeedTypeHasDocumentTypes_B_index" ON "_DeedTypeHasDocumentTypes"("B");
-- AddForeignKey
ALTER TABLE "_OfficeFolderHasCustomers" ADD CONSTRAINT "_OfficeFolderHasCustomers_A_fkey" FOREIGN KEY ("A") REFERENCES "customers"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_OfficeFolderHasCustomers" ADD CONSTRAINT "_OfficeFolderHasCustomers_B_fkey" FOREIGN KEY ("B") REFERENCES "office_folders"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_UserHasNotifications" ADD CONSTRAINT "_UserHasNotifications_A_fkey" FOREIGN KEY ("A") REFERENCES "notifications"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_UserHasNotifications" ADD CONSTRAINT "_UserHasNotifications_B_fkey" FOREIGN KEY ("B") REFERENCES "users"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_OfficeFolderHasStakeholders" ADD CONSTRAINT "_OfficeFolderHasStakeholders_A_fkey" FOREIGN KEY ("A") REFERENCES "office_folders"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_OfficeFolderHasStakeholders" ADD CONSTRAINT "_OfficeFolderHasStakeholders_B_fkey" FOREIGN KEY ("B") REFERENCES "users"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_DeedHasDocumentTypes" ADD CONSTRAINT "_DeedHasDocumentTypes_A_fkey" FOREIGN KEY ("A") REFERENCES "deed"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_DeedHasDocumentTypes" ADD CONSTRAINT "_DeedHasDocumentTypes_B_fkey" FOREIGN KEY ("B") REFERENCES "document_types"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_DeedTypeHasDocumentTypes" ADD CONSTRAINT "_DeedTypeHasDocumentTypes_A_fkey" FOREIGN KEY ("A") REFERENCES "deed_types"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_DeedTypeHasDocumentTypes" ADD CONSTRAINT "_DeedTypeHasDocumentTypes_B_fkey" FOREIGN KEY ("B") REFERENCES "document_types"("uid") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,23 +0,0 @@
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_contact_uid_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_office_role_uid_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_office_uid_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_roles_uid_fkey";
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_contact_uid_fkey" FOREIGN KEY ("contact_uid") REFERENCES "contacts"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_roles_uid_fkey" FOREIGN KEY ("roles_uid") REFERENCES "roles"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_office_role_uid_fkey" FOREIGN KEY ("office_role_uid") REFERENCES "office_roles"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,15 +0,0 @@
/*
Warnings:
- A unique constraint covering the columns `[idNot,uid]` on the table `users` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[contact_uid,uid]` on the table `users` will be added. If there are existing duplicate values, this will fail.
*/
-- DropIndex
DROP INDEX "users_idNot_key";
-- CreateIndex
CREATE UNIQUE INDEX "users_idNot_uid_key" ON "users"("idNot", "uid");
-- CreateIndex
CREATE UNIQUE INDEX "users_contact_uid_uid_key" ON "users"("contact_uid", "uid");

View File

@ -1,14 +0,0 @@
/*
Warnings:
- A unique constraint covering the columns `[idNot]` on the table `users` will be added. If there are existing duplicate values, this will fail.
*/
-- DropIndex
DROP INDEX "users_contact_uid_uid_key";
-- DropIndex
DROP INDEX "users_idNot_uid_key";
-- CreateIndex
CREATE UNIQUE INDEX "users_idNot_key" ON "users"("idNot");

View File

@ -1,43 +0,0 @@
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_contact_uid_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_office_role_uid_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_office_uid_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_roles_uid_fkey";
-- CreateTable
CREATE TABLE "email" (
"uid" TEXT NOT NULL,
"templateName" VARCHAR(255) NOT NULL,
"from" VARCHAR(255),
"to" VARCHAR(255) NOT NULL,
"subject" VARCHAR(255) NOT NULL,
"templateVariables" JSON NOT NULL DEFAULT '{}',
"cc" VARCHAR(255)[],
"cci" VARCHAR(255)[],
"sentAt" TIMESTAMP(3),
"nbTrySend" INTEGER DEFAULT 0,
"lastTrySendDate" TIMESTAMP(3),
CONSTRAINT "email_pkey" PRIMARY KEY ("uid")
);
-- CreateIndex
CREATE UNIQUE INDEX "email_uid_key" ON "email"("uid");
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_contact_uid_fkey" FOREIGN KEY ("contact_uid") REFERENCES "contacts"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_roles_uid_fkey" FOREIGN KEY ("roles_uid") REFERENCES "roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_office_role_uid_fkey" FOREIGN KEY ("office_role_uid") REFERENCES "office_roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,38 +0,0 @@
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_contact_uid_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_office_role_uid_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_office_uid_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_roles_uid_fkey";
-- CreateTable
CREATE TABLE "votes" (
"uid" TEXT NOT NULL,
"user_uid" VARCHAR(255) NOT NULL,
"voters" TEXT[],
CONSTRAINT "votes_pkey" PRIMARY KEY ("uid")
);
-- CreateIndex
CREATE UNIQUE INDEX "votes_uid_key" ON "votes"("uid");
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_contact_uid_fkey" FOREIGN KEY ("contact_uid") REFERENCES "contacts"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_roles_uid_fkey" FOREIGN KEY ("roles_uid") REFERENCES "roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_office_role_uid_fkey" FOREIGN KEY ("office_role_uid") REFERENCES "office_roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "votes" ADD CONSTRAINT "votes_user_uid_fkey" FOREIGN KEY ("user_uid") REFERENCES "users"("uid") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,45 +0,0 @@
/*
Warnings:
- You are about to drop the column `user_uid` on the `votes` table. All the data in the column will be lost.
- You are about to drop the column `voters` on the `votes` table. All the data in the column will be lost.
- Added the required column `appointment_uid` to the `votes` table without a default value. This is not possible if the table is not empty.
- Added the required column `voter_uid` to the `votes` table without a default value. This is not possible if the table is not empty.
*/
-- CreateEnum
CREATE TYPE "EVote" AS ENUM ('NOMINATE', 'DISMISS');
-- CreateEnum
CREATE TYPE "EAppointmentStatus" AS ENUM ('OPEN', 'CLOSED');
-- DropForeignKey
ALTER TABLE "votes" DROP CONSTRAINT "votes_user_uid_fkey";
-- AlterTable
ALTER TABLE "votes" DROP COLUMN "user_uid",
DROP COLUMN "voters",
ADD COLUMN "appointment_uid" VARCHAR(255) NOT NULL,
ADD COLUMN "choice" "EVote" NOT NULL DEFAULT 'NOMINATE',
ADD COLUMN "voter_uid" VARCHAR(255) NOT NULL;
-- CreateTable
CREATE TABLE "appointments" (
"uid" TEXT NOT NULL,
"user_uid" VARCHAR(255) NOT NULL,
"status" "EAppointmentStatus" NOT NULL DEFAULT 'OPEN',
CONSTRAINT "appointments_pkey" PRIMARY KEY ("uid")
);
-- CreateIndex
CREATE UNIQUE INDEX "appointments_uid_key" ON "appointments"("uid");
-- AddForeignKey
ALTER TABLE "appointments" ADD CONSTRAINT "appointments_user_uid_fkey" FOREIGN KEY ("user_uid") REFERENCES "users"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "votes" ADD CONSTRAINT "votes_appointment_uid_fkey" FOREIGN KEY ("appointment_uid") REFERENCES "appointments"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "votes" ADD CONSTRAINT "votes_voter_uid_fkey" FOREIGN KEY ("voter_uid") REFERENCES "users"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,11 +0,0 @@
/*
Warnings:
- You are about to drop the column `choice` on the `votes` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "appointments" ADD COLUMN "choice" "EVote" NOT NULL DEFAULT 'NOMINATE';
-- AlterTable
ALTER TABLE "votes" DROP COLUMN "choice";

View File

@ -1,8 +0,0 @@
/*
Warnings:
- A unique constraint covering the columns `[user_uid,choice,status]` on the table `appointments` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "appointments_user_uid_choice_status_key" ON "appointments"("user_uid", "choice", "status");

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "notifications" ADD COLUMN "status" "ENotificationStatus" NOT NULL DEFAULT 'UNREAD';

View File

@ -1,12 +0,0 @@
/*
Warnings:
- Added the required column `label` to the `roles` table without a default value. This is not possible if the table is not empty.
- Added the required column `label` to the `rules` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "roles" ADD COLUMN "label" VARCHAR(255) NOT NULL;
-- AlterTable
ALTER TABLE "rules" ADD COLUMN "label" VARCHAR(255) NOT NULL;

View File

@ -1,37 +0,0 @@
/*
Warnings:
- You are about to drop the column `status` on the `notifications` table. All the data in the column will be lost.
- You are about to drop the `_UserHasNotifications` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "_UserHasNotifications" DROP CONSTRAINT "_UserHasNotifications_A_fkey";
-- DropForeignKey
ALTER TABLE "_UserHasNotifications" DROP CONSTRAINT "_UserHasNotifications_B_fkey";
-- AlterTable
ALTER TABLE "notifications" DROP COLUMN "status";
-- DropTable
DROP TABLE "_UserHasNotifications";
-- CreateTable
CREATE TABLE "user_notifications" (
"uid" TEXT NOT NULL,
"user_uid" VARCHAR(255) NOT NULL,
"read" BOOLEAN NOT NULL DEFAULT false,
"notification_uid" VARCHAR(255) NOT NULL,
CONSTRAINT "user_notifications_pkey" PRIMARY KEY ("uid")
);
-- CreateIndex
CREATE UNIQUE INDEX "user_notifications_uid_key" ON "user_notifications"("uid");
-- AddForeignKey
ALTER TABLE "user_notifications" ADD CONSTRAINT "user_notifications_user_uid_fkey" FOREIGN KEY ("user_uid") REFERENCES "users"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "user_notifications" ADD CONSTRAINT "user_notifications_notification_uid_fkey" FOREIGN KEY ("notification_uid") REFERENCES "notifications"("uid") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,5 +0,0 @@
-- AlterTable
ALTER TABLE "offices" ADD COLUMN "checked_at" TIMESTAMP(3);
-- AlterTable
ALTER TABLE "users" ADD COLUMN "checked_at" TIMESTAMP(3);

View File

@ -1,71 +0,0 @@
/*
Warnings:
- The values [ANCHORED] on the enum `EDocumentStatus` will be removed. If these variants are still used in the database, this will fail.
- You are about to drop the column `blockchain_anchor_uid` on the `documents` table. All the data in the column will be lost.
- You are about to drop the `blockchain_anchors` table. If the table is not empty, all the data it contains will be lost.
- A unique constraint covering the columns `[folder_anchor_uid]` on the table `office_folders` will be added. If there are existing duplicate values, this will fail.
- Added the required column `hash` to the `files` table without a default value. This is not possible if the table is not empty.
*/
-- CreateEnum
CREATE TYPE "EBlockchainName" AS ENUM ('TEZOS');
-- CreateEnum
CREATE TYPE "EAnchoringStatus" AS ENUM ('QUEUED', 'ATTEMPTING', 'VERIFIED_ON_CHAIN', 'VERIFYING_ON_CHAIN', 'ABANDONED');
-- AlterEnum
BEGIN;
CREATE TYPE "EDocumentStatus_new" AS ENUM ('ASKED', 'DEPOSITED', 'VALIDATED', 'REFUSED');
ALTER TABLE "documents" ALTER COLUMN "document_status" DROP DEFAULT;
ALTER TABLE "document_history" ALTER COLUMN "document_status" DROP DEFAULT;
ALTER TABLE "documents" ALTER COLUMN "document_status" TYPE "EDocumentStatus_new" USING ("document_status"::text::"EDocumentStatus_new");
ALTER TABLE "document_history" ALTER COLUMN "document_status" TYPE "EDocumentStatus_new" USING ("document_status"::text::"EDocumentStatus_new");
ALTER TYPE "EDocumentStatus" RENAME TO "EDocumentStatus_old";
ALTER TYPE "EDocumentStatus_new" RENAME TO "EDocumentStatus";
DROP TYPE "EDocumentStatus_old";
ALTER TABLE "documents" ALTER COLUMN "document_status" SET DEFAULT 'ASKED';
ALTER TABLE "document_history" ALTER COLUMN "document_status" SET DEFAULT 'ASKED';
COMMIT;
-- DropForeignKey
ALTER TABLE "documents" DROP CONSTRAINT "documents_blockchain_anchor_uid_fkey";
-- AlterTable
ALTER TABLE "documents" DROP COLUMN "blockchain_anchor_uid";
-- AlterTable
ALTER TABLE "files" ADD COLUMN "hash" VARCHAR(255) NOT NULL;
-- AlterTable
ALTER TABLE "office_folders" ADD COLUMN "folder_anchor_uid" VARCHAR(255);
-- DropTable
DROP TABLE "blockchain_anchors";
-- CreateTable
CREATE TABLE "office_folder_anchors" (
"uid" TEXT NOT NULL,
"hash_sources" TEXT[],
"root_hash" VARCHAR(255) NOT NULL,
"blockchain" "EBlockchainName" NOT NULL DEFAULT 'TEZOS',
"status" "EAnchoringStatus" NOT NULL DEFAULT 'QUEUED',
"anchor_nb_try" INTEGER NOT NULL DEFAULT 0,
"anchored_at" TIMESTAMP(3),
"tx_id" VARCHAR(255),
"tx_link" VARCHAR(255),
"tx_hash" VARCHAR(255),
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
CONSTRAINT "office_folder_anchors_pkey" PRIMARY KEY ("uid")
);
-- CreateIndex
CREATE UNIQUE INDEX "office_folder_anchors_uid_key" ON "office_folder_anchors"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_folders_folder_anchor_uid_key" ON "office_folders"("folder_anchor_uid");
-- AddForeignKey
ALTER TABLE "office_folders" ADD CONSTRAINT "office_folders_folder_anchor_uid_fkey" FOREIGN KEY ("folder_anchor_uid") REFERENCES "office_folder_anchors"("uid") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -14,7 +14,19 @@ CREATE TYPE "ENotificationStatus" AS ENUM ('READ', 'UNREAD');
CREATE TYPE "ECustomerStatus" AS ENUM ('VALIDATED', 'PENDING', 'ERRONED');
-- CreateEnum
CREATE TYPE "EDocumentStatus" AS ENUM ('ASKED', 'DEPOSITED', 'VALIDATED', 'ANCHORED', 'REFUSED');
CREATE TYPE "EDocumentStatus" AS ENUM ('ASKED', 'DEPOSITED', 'VALIDATED', 'REFUSED');
-- CreateEnum
CREATE TYPE "EVote" AS ENUM ('NOMINATE', 'DISMISS');
-- CreateEnum
CREATE TYPE "EAppointmentStatus" AS ENUM ('OPEN', 'CLOSED');
-- CreateEnum
CREATE TYPE "EBlockchainName" AS ENUM ('TEZOS');
-- CreateEnum
CREATE TYPE "EAnchoringStatus" AS ENUM ('QUEUED', 'ATTEMPTING', 'VERIFIED_ON_CHAIN', 'VERIFYING_ON_CHAIN', 'ABANDONED');
-- CreateTable
CREATE TABLE "addresses" (
@ -50,9 +62,11 @@ CREATE TABLE "users" (
"uid" TEXT NOT NULL,
"idNot" VARCHAR(255) NOT NULL,
"contact_uid" VARCHAR(255) NOT NULL,
"roles_uid" TEXT NOT NULL,
"roles_uid" VARCHAR(255) NOT NULL,
"office_role_uid" VARCHAR(255),
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"checked_at" TIMESTAMP(3),
"office_uid" VARCHAR(255) NOT NULL,
CONSTRAINT "users_pkey" PRIMARY KEY ("uid")
@ -68,6 +82,7 @@ CREATE TABLE "offices" (
"office_status" "EOfficeStatus" NOT NULL DEFAULT 'DESACTIVATED',
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"checked_at" TIMESTAMP(3),
CONSTRAINT "offices_pkey" PRIMARY KEY ("uid")
);
@ -83,18 +98,6 @@ CREATE TABLE "customers" (
CONSTRAINT "customers_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "user_has_notifications" (
"uid" TEXT NOT NULL,
"user_uid" VARCHAR(255) NOT NULL,
"notification_uid" VARCHAR(255) NOT NULL,
"notification_status" "ENotificationStatus" NOT NULL DEFAULT 'UNREAD',
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
CONSTRAINT "user_has_notifications_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "notifications" (
"uid" TEXT NOT NULL,
@ -106,6 +109,16 @@ CREATE TABLE "notifications" (
CONSTRAINT "notifications_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "user_notifications" (
"uid" TEXT NOT NULL,
"user_uid" VARCHAR(255) NOT NULL,
"read" BOOLEAN NOT NULL DEFAULT false,
"notification_uid" VARCHAR(255) NOT NULL,
CONSTRAINT "user_notifications_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "office_folders" (
"uid" TEXT NOT NULL,
@ -118,30 +131,27 @@ CREATE TABLE "office_folders" (
"office_uid" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"folder_anchor_uid" VARCHAR(255),
CONSTRAINT "office_folders_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "office_folder_has_customers" (
CREATE TABLE "office_folder_anchors" (
"uid" TEXT NOT NULL,
"customer_uid" VARCHAR(255) NOT NULL,
"office_folder_uid" VARCHAR(255) NOT NULL,
"hash_sources" TEXT[],
"root_hash" VARCHAR(255) NOT NULL,
"blockchain" "EBlockchainName" NOT NULL DEFAULT 'TEZOS',
"status" "EAnchoringStatus" NOT NULL DEFAULT 'QUEUED',
"anchor_nb_try" INTEGER NOT NULL DEFAULT 0,
"anchored_at" TIMESTAMP(3),
"tx_id" VARCHAR(255),
"tx_link" VARCHAR(255),
"tx_hash" VARCHAR(255),
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
CONSTRAINT "office_folder_has_customers_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "office_folder_has_stakeholder" (
"uid" TEXT NOT NULL,
"office_folder_uid" VARCHAR(255) NOT NULL,
"user_stakeholder_uid" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
CONSTRAINT "office_folder_has_stakeholder_pkey" PRIMARY KEY ("uid")
CONSTRAINT "office_folder_anchors_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
@ -149,7 +159,6 @@ CREATE TABLE "documents" (
"uid" TEXT NOT NULL,
"document_status" "EDocumentStatus" NOT NULL DEFAULT 'ASKED',
"document_type_uid" VARCHAR(255) NOT NULL,
"blockchain_anchor_uid" VARCHAR(255),
"folder_uid" VARCHAR(255) NOT NULL,
"depositor_uid" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
@ -177,6 +186,7 @@ CREATE TABLE "files" (
"file_path" VARCHAR(255) NOT NULL,
"file_name" VARCHAR(255) NOT NULL,
"mimetype" VARCHAR(255) NOT NULL,
"hash" VARCHAR(255) NOT NULL,
"size" INTEGER NOT NULL,
"archived_at" TIMESTAMP(3),
"key" VARCHAR(255),
@ -186,16 +196,6 @@ CREATE TABLE "files" (
CONSTRAINT "files_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "blockchain_anchors" (
"uid" TEXT NOT NULL,
"smartSigJobId" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
CONSTRAINT "blockchain_anchors_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "document_types" (
"uid" TEXT NOT NULL,
@ -210,17 +210,6 @@ CREATE TABLE "document_types" (
CONSTRAINT "document_types_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "deed_has_document_types" (
"uid" TEXT NOT NULL,
"document_type_uid" VARCHAR(255) NOT NULL,
"deed_uid" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
CONSTRAINT "deed_has_document_types_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "deed" (
"uid" TEXT NOT NULL,
@ -244,59 +233,109 @@ CREATE TABLE "deed_types" (
CONSTRAINT "deed_types_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "deed_type_has_document_types" (
"uid" TEXT NOT NULL,
"document_type_uid" VARCHAR(255) NOT NULL,
"deed_type_uid" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
CONSTRAINT "deed_type_has_document_types_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "roles" (
"uid" TEXT NOT NULL,
"name" VARCHAR(255) NOT NULL,
"label" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
CONSTRAINT "roles_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "office_roles" (
"uid" TEXT NOT NULL,
"name" VARCHAR(255) NOT NULL,
"office_uid" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
CONSTRAINT "office_roles_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "rules" (
"uid" TEXT NOT NULL,
"name" VARCHAR(255) NOT NULL,
"label" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"role_has_rules_uid" TEXT,
"office_role_has_rules_uid" TEXT,
CONSTRAINT "rules_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "role_has_rules" (
CREATE TABLE "email" (
"uid" TEXT NOT NULL,
"role_uid" VARCHAR(255) NOT NULL,
"rule_uid" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"templateName" VARCHAR(255) NOT NULL,
"from" VARCHAR(255),
"to" VARCHAR(255) NOT NULL,
"subject" VARCHAR(255) NOT NULL,
"templateVariables" JSON NOT NULL DEFAULT '{}',
"cc" VARCHAR(255)[],
"cci" VARCHAR(255)[],
"sentAt" TIMESTAMP(3),
"nbTrySend" INTEGER DEFAULT 0,
"lastTrySendDate" TIMESTAMP(3),
CONSTRAINT "role_has_rules_pkey" PRIMARY KEY ("uid")
CONSTRAINT "email_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "office_role_has_rules" (
CREATE TABLE "appointments" (
"uid" TEXT NOT NULL,
"role_uid" VARCHAR(255) NOT NULL,
"rule_uid" VARCHAR(255) NOT NULL,
"created_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"user_uid" VARCHAR(255) NOT NULL,
"choice" "EVote" NOT NULL DEFAULT 'NOMINATE',
"status" "EAppointmentStatus" NOT NULL DEFAULT 'OPEN',
CONSTRAINT "office_role_has_rules_pkey" PRIMARY KEY ("uid")
CONSTRAINT "appointments_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "votes" (
"uid" TEXT NOT NULL,
"appointment_uid" VARCHAR(255) NOT NULL,
"voter_uid" VARCHAR(255) NOT NULL,
CONSTRAINT "votes_pkey" PRIMARY KEY ("uid")
);
-- CreateTable
CREATE TABLE "_OfficeFolderHasCustomers" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "_OfficeFolderHasStakeholders" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "_DeedHasDocumentTypes" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "_DeedTypeHasDocumentTypes" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "_RolesHasRules" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "_OfficeRolesHasRules" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);
-- CreateIndex
@ -341,35 +380,26 @@ CREATE UNIQUE INDEX "customers_uid_key" ON "customers"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "customers_contact_uid_key" ON "customers"("contact_uid");
-- CreateIndex
CREATE UNIQUE INDEX "user_has_notifications_uid_key" ON "user_has_notifications"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "user_has_notifications_notification_uid_user_uid_key" ON "user_has_notifications"("notification_uid", "user_uid");
-- CreateIndex
CREATE UNIQUE INDEX "notifications_uid_key" ON "notifications"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "user_notifications_uid_key" ON "user_notifications"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_folders_uid_key" ON "office_folders"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_folders_deed_uid_key" ON "office_folders"("deed_uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_folders_folder_anchor_uid_key" ON "office_folders"("folder_anchor_uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_folders_folder_number_office_uid_key" ON "office_folders"("folder_number", "office_uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_folder_has_customers_uid_key" ON "office_folder_has_customers"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_folder_has_customers_office_folder_uid_customer_uid_key" ON "office_folder_has_customers"("office_folder_uid", "customer_uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_folder_has_stakeholder_uid_key" ON "office_folder_has_stakeholder"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_folder_has_stakeholder_office_folder_uid_user_stakeh_key" ON "office_folder_has_stakeholder"("office_folder_uid", "user_stakeholder_uid");
CREATE UNIQUE INDEX "office_folder_anchors_uid_key" ON "office_folder_anchors"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "documents_uid_key" ON "documents"("uid");
@ -383,24 +413,12 @@ CREATE UNIQUE INDEX "files_uid_key" ON "files"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "files_file_path_key" ON "files"("file_path");
-- CreateIndex
CREATE UNIQUE INDEX "blockchain_anchors_uid_key" ON "blockchain_anchors"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "blockchain_anchors_smartSigJobId_key" ON "blockchain_anchors"("smartSigJobId");
-- CreateIndex
CREATE UNIQUE INDEX "document_types_uid_key" ON "document_types"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "document_types_name_office_uid_key" ON "document_types"("name", "office_uid");
-- CreateIndex
CREATE UNIQUE INDEX "deed_has_document_types_uid_key" ON "deed_has_document_types"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "deed_has_document_types_deed_uid_document_type_uid_key" ON "deed_has_document_types"("deed_uid", "document_type_uid");
-- CreateIndex
CREATE UNIQUE INDEX "deed_uid_key" ON "deed"("uid");
@ -410,23 +428,62 @@ CREATE UNIQUE INDEX "deed_types_uid_key" ON "deed_types"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "deed_types_name_office_uid_key" ON "deed_types"("name", "office_uid");
-- CreateIndex
CREATE UNIQUE INDEX "deed_type_has_document_types_uid_key" ON "deed_type_has_document_types"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "deed_type_has_document_types_deed_type_uid_document_type_ui_key" ON "deed_type_has_document_types"("deed_type_uid", "document_type_uid");
-- CreateIndex
CREATE UNIQUE INDEX "roles_uid_key" ON "roles"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_roles_uid_key" ON "office_roles"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "rules_uid_key" ON "rules"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "role_has_rules_uid_key" ON "role_has_rules"("uid");
CREATE UNIQUE INDEX "email_uid_key" ON "email"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "office_role_has_rules_uid_key" ON "office_role_has_rules"("uid");
CREATE UNIQUE INDEX "appointments_uid_key" ON "appointments"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "appointments_user_uid_choice_status_key" ON "appointments"("user_uid", "choice", "status");
-- CreateIndex
CREATE UNIQUE INDEX "votes_uid_key" ON "votes"("uid");
-- CreateIndex
CREATE UNIQUE INDEX "_OfficeFolderHasCustomers_AB_unique" ON "_OfficeFolderHasCustomers"("A", "B");
-- CreateIndex
CREATE INDEX "_OfficeFolderHasCustomers_B_index" ON "_OfficeFolderHasCustomers"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_OfficeFolderHasStakeholders_AB_unique" ON "_OfficeFolderHasStakeholders"("A", "B");
-- CreateIndex
CREATE INDEX "_OfficeFolderHasStakeholders_B_index" ON "_OfficeFolderHasStakeholders"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_DeedHasDocumentTypes_AB_unique" ON "_DeedHasDocumentTypes"("A", "B");
-- CreateIndex
CREATE INDEX "_DeedHasDocumentTypes_B_index" ON "_DeedHasDocumentTypes"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_DeedTypeHasDocumentTypes_AB_unique" ON "_DeedTypeHasDocumentTypes"("A", "B");
-- CreateIndex
CREATE INDEX "_DeedTypeHasDocumentTypes_B_index" ON "_DeedTypeHasDocumentTypes"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_RolesHasRules_AB_unique" ON "_RolesHasRules"("A", "B");
-- CreateIndex
CREATE INDEX "_RolesHasRules_B_index" ON "_RolesHasRules"("B");
-- CreateIndex
CREATE UNIQUE INDEX "_OfficeRolesHasRules_AB_unique" ON "_OfficeRolesHasRules"("A", "B");
-- CreateIndex
CREATE INDEX "_OfficeRolesHasRules_B_index" ON "_OfficeRolesHasRules"("B");
-- AddForeignKey
ALTER TABLE "contacts" ADD CONSTRAINT "contacts_address_uid_fkey" FOREIGN KEY ("address_uid") REFERENCES "addresses"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
@ -435,7 +492,10 @@ ALTER TABLE "contacts" ADD CONSTRAINT "contacts_address_uid_fkey" FOREIGN KEY ("
ALTER TABLE "users" ADD CONSTRAINT "users_contact_uid_fkey" FOREIGN KEY ("contact_uid") REFERENCES "contacts"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_roles_uid_fkey" FOREIGN KEY ("roles_uid") REFERENCES "roles"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "users" ADD CONSTRAINT "users_roles_uid_fkey" FOREIGN KEY ("roles_uid") REFERENCES "roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_office_role_uid_fkey" FOREIGN KEY ("office_role_uid") REFERENCES "office_roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
@ -447,10 +507,10 @@ ALTER TABLE "offices" ADD CONSTRAINT "offices_address_uid_fkey" FOREIGN KEY ("ad
ALTER TABLE "customers" ADD CONSTRAINT "customers_contact_uid_fkey" FOREIGN KEY ("contact_uid") REFERENCES "contacts"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "user_has_notifications" ADD CONSTRAINT "user_has_notifications_user_uid_fkey" FOREIGN KEY ("user_uid") REFERENCES "users"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "user_notifications" ADD CONSTRAINT "user_notifications_user_uid_fkey" FOREIGN KEY ("user_uid") REFERENCES "users"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "user_has_notifications" ADD CONSTRAINT "user_has_notifications_notification_uid_fkey" FOREIGN KEY ("notification_uid") REFERENCES "notifications"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "user_notifications" ADD CONSTRAINT "user_notifications_notification_uid_fkey" FOREIGN KEY ("notification_uid") REFERENCES "notifications"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "office_folders" ADD CONSTRAINT "office_folders_deed_uid_fkey" FOREIGN KEY ("deed_uid") REFERENCES "deed"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
@ -459,23 +519,11 @@ ALTER TABLE "office_folders" ADD CONSTRAINT "office_folders_deed_uid_fkey" FOREI
ALTER TABLE "office_folders" ADD CONSTRAINT "office_folders_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "office_folder_has_customers" ADD CONSTRAINT "office_folder_has_customers_customer_uid_fkey" FOREIGN KEY ("customer_uid") REFERENCES "customers"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "office_folder_has_customers" ADD CONSTRAINT "office_folder_has_customers_office_folder_uid_fkey" FOREIGN KEY ("office_folder_uid") REFERENCES "office_folders"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "office_folder_has_stakeholder" ADD CONSTRAINT "office_folder_has_stakeholder_office_folder_uid_fkey" FOREIGN KEY ("office_folder_uid") REFERENCES "office_folders"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "office_folder_has_stakeholder" ADD CONSTRAINT "office_folder_has_stakeholder_user_stakeholder_uid_fkey" FOREIGN KEY ("user_stakeholder_uid") REFERENCES "users"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "office_folders" ADD CONSTRAINT "office_folders_folder_anchor_uid_fkey" FOREIGN KEY ("folder_anchor_uid") REFERENCES "office_folder_anchors"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "documents" ADD CONSTRAINT "documents_document_type_uid_fkey" FOREIGN KEY ("document_type_uid") REFERENCES "document_types"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "documents" ADD CONSTRAINT "documents_blockchain_anchor_uid_fkey" FOREIGN KEY ("blockchain_anchor_uid") REFERENCES "blockchain_anchors"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "documents" ADD CONSTRAINT "documents_folder_uid_fkey" FOREIGN KEY ("folder_uid") REFERENCES "office_folders"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
@ -491,12 +539,6 @@ ALTER TABLE "files" ADD CONSTRAINT "files_document_uid_fkey" FOREIGN KEY ("docum
-- AddForeignKey
ALTER TABLE "document_types" ADD CONSTRAINT "document_types_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "deed_has_document_types" ADD CONSTRAINT "deed_has_document_types_document_type_uid_fkey" FOREIGN KEY ("document_type_uid") REFERENCES "document_types"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "deed_has_document_types" ADD CONSTRAINT "deed_has_document_types_deed_uid_fkey" FOREIGN KEY ("deed_uid") REFERENCES "deed"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "deed" ADD CONSTRAINT "deed_deed_type_uid_fkey" FOREIGN KEY ("deed_type_uid") REFERENCES "deed_types"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
@ -504,19 +546,49 @@ ALTER TABLE "deed" ADD CONSTRAINT "deed_deed_type_uid_fkey" FOREIGN KEY ("deed_t
ALTER TABLE "deed_types" ADD CONSTRAINT "deed_types_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "deed_type_has_document_types" ADD CONSTRAINT "deed_type_has_document_types_document_type_uid_fkey" FOREIGN KEY ("document_type_uid") REFERENCES "document_types"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "office_roles" ADD CONSTRAINT "office_roles_office_uid_fkey" FOREIGN KEY ("office_uid") REFERENCES "offices"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "deed_type_has_document_types" ADD CONSTRAINT "deed_type_has_document_types_deed_type_uid_fkey" FOREIGN KEY ("deed_type_uid") REFERENCES "deed_types"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "appointments" ADD CONSTRAINT "appointments_user_uid_fkey" FOREIGN KEY ("user_uid") REFERENCES "users"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "rules" ADD CONSTRAINT "rules_role_has_rules_uid_fkey" FOREIGN KEY ("role_has_rules_uid") REFERENCES "role_has_rules"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE "votes" ADD CONSTRAINT "votes_appointment_uid_fkey" FOREIGN KEY ("appointment_uid") REFERENCES "appointments"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "rules" ADD CONSTRAINT "rules_office_role_has_rules_uid_fkey" FOREIGN KEY ("office_role_has_rules_uid") REFERENCES "office_role_has_rules"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE "votes" ADD CONSTRAINT "votes_voter_uid_fkey" FOREIGN KEY ("voter_uid") REFERENCES "users"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "role_has_rules" ADD CONSTRAINT "role_has_rules_role_uid_fkey" FOREIGN KEY ("role_uid") REFERENCES "roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "_OfficeFolderHasCustomers" ADD CONSTRAINT "_OfficeFolderHasCustomers_A_fkey" FOREIGN KEY ("A") REFERENCES "customers"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "office_role_has_rules" ADD CONSTRAINT "office_role_has_rules_role_uid_fkey" FOREIGN KEY ("role_uid") REFERENCES "roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "_OfficeFolderHasCustomers" ADD CONSTRAINT "_OfficeFolderHasCustomers_B_fkey" FOREIGN KEY ("B") REFERENCES "office_folders"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_OfficeFolderHasStakeholders" ADD CONSTRAINT "_OfficeFolderHasStakeholders_A_fkey" FOREIGN KEY ("A") REFERENCES "office_folders"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_OfficeFolderHasStakeholders" ADD CONSTRAINT "_OfficeFolderHasStakeholders_B_fkey" FOREIGN KEY ("B") REFERENCES "users"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_DeedHasDocumentTypes" ADD CONSTRAINT "_DeedHasDocumentTypes_A_fkey" FOREIGN KEY ("A") REFERENCES "deed"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_DeedHasDocumentTypes" ADD CONSTRAINT "_DeedHasDocumentTypes_B_fkey" FOREIGN KEY ("B") REFERENCES "document_types"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_DeedTypeHasDocumentTypes" ADD CONSTRAINT "_DeedTypeHasDocumentTypes_A_fkey" FOREIGN KEY ("A") REFERENCES "deed_types"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_DeedTypeHasDocumentTypes" ADD CONSTRAINT "_DeedTypeHasDocumentTypes_B_fkey" FOREIGN KEY ("B") REFERENCES "document_types"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_RolesHasRules" ADD CONSTRAINT "_RolesHasRules_A_fkey" FOREIGN KEY ("A") REFERENCES "roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_RolesHasRules" ADD CONSTRAINT "_RolesHasRules_B_fkey" FOREIGN KEY ("B") REFERENCES "rules"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_OfficeRolesHasRules" ADD CONSTRAINT "_OfficeRolesHasRules_A_fkey" FOREIGN KEY ("A") REFERENCES "office_roles"("uid") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "_OfficeRolesHasRules" ADD CONSTRAINT "_OfficeRolesHasRules_B_fkey" FOREIGN KEY ("B") REFERENCES "rules"("uid") ON DELETE CASCADE ON UPDATE CASCADE;