add a migration file
This commit is contained in:
parent
ac529a7ceb
commit
59aaf734dc
@ -0,0 +1,71 @@
|
||||
/*
|
||||
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;
|
Loading…
x
Reference in New Issue
Block a user