From cc65e0dd648c63b552d8b799f7a0629fa1d6e8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allen=20Zhang=20=28=E5=BC=A0=E6=B6=9B=29?= Date: Sun, 7 Apr 2024 21:13:47 +0800 Subject: [PATCH] upd --- .../20240311091628_update_usage/migration.sql | 33 ---------- .../20240311091844_update_name/migration.sql | 53 ---------------- .../20240407111734_upd/migration.sql | 56 ----------------- .../migration.sql | 61 +++++++++---------- packages/canyon-backend/prisma/schema.prisma | 12 ++-- 5 files changed, 34 insertions(+), 181 deletions(-) delete mode 100644 packages/canyon-backend/prisma/migrations/20240311091628_update_usage/migration.sql delete mode 100644 packages/canyon-backend/prisma/migrations/20240311091844_update_name/migration.sql delete mode 100644 packages/canyon-backend/prisma/migrations/20240407111734_upd/migration.sql rename packages/canyon-backend/prisma/migrations/{20240306090115_init => 20240407130953_upd}/migration.sql (63%) diff --git a/packages/canyon-backend/prisma/migrations/20240311091628_update_usage/migration.sql b/packages/canyon-backend/prisma/migrations/20240311091628_update_usage/migration.sql deleted file mode 100644 index f742491a..00000000 --- a/packages/canyon-backend/prisma/migrations/20240311091628_update_usage/migration.sql +++ /dev/null @@ -1,33 +0,0 @@ --- CreateEnum -CREATE TYPE "OrganizationMemberRole" AS ENUM ('OWNER', 'ADMIN', 'DEVELOPER', 'VIEWER'); - --- CreateTable -CREATE TABLE "Organization" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - - CONSTRAINT "Organization_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "OrganizationMember" ( - "id" TEXT NOT NULL, - "role" "OrganizationMemberRole" NOT NULL, - "user_id" INTEGER NOT NULL, - "team_id" TEXT NOT NULL, - - CONSTRAINT "OrganizationMember_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Usage" ( - "id" TEXT NOT NULL, - "project_id" TEXT NOT NULL, - "sha" TEXT NOT NULL, - "coverage_id" TEXT NOT NULL, - "reporter" INTEGER NOT NULL, - "size" INTEGER NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Usage_pkey" PRIMARY KEY ("id") -); diff --git a/packages/canyon-backend/prisma/migrations/20240311091844_update_name/migration.sql b/packages/canyon-backend/prisma/migrations/20240311091844_update_name/migration.sql deleted file mode 100644 index 91b43325..00000000 --- a/packages/canyon-backend/prisma/migrations/20240311091844_update_name/migration.sql +++ /dev/null @@ -1,53 +0,0 @@ -/* - Warnings: - - - You are about to drop the `Organization` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `OrganizationMember` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Usage` table. If the table is not empty, all the data it contains will be lost. - -*/ --- CreateEnum -CREATE TYPE "organization_member_role" AS ENUM ('OWNER', 'ADMIN', 'DEVELOPER', 'VIEWER'); - --- DropTable -DROP TABLE "Organization"; - --- DropTable -DROP TABLE "OrganizationMember"; - --- DropTable -DROP TABLE "Usage"; - --- DropEnum -DROP TYPE "OrganizationMemberRole"; - --- CreateTable -CREATE TABLE "organization" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - - CONSTRAINT "organization_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "organization_member" ( - "id" TEXT NOT NULL, - "role" "organization_member_role" NOT NULL, - "user_id" INTEGER NOT NULL, - "team_id" TEXT NOT NULL, - - CONSTRAINT "organization_member_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "usage" ( - "id" TEXT NOT NULL, - "project_id" TEXT NOT NULL, - "sha" TEXT NOT NULL, - "coverage_id" TEXT NOT NULL, - "reporter" INTEGER NOT NULL, - "size" INTEGER NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "usage_pkey" PRIMARY KEY ("id") -); diff --git a/packages/canyon-backend/prisma/migrations/20240407111734_upd/migration.sql b/packages/canyon-backend/prisma/migrations/20240407111734_upd/migration.sql deleted file mode 100644 index aee3ded6..00000000 --- a/packages/canyon-backend/prisma/migrations/20240407111734_upd/migration.sql +++ /dev/null @@ -1,56 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `children` on the `coverage` table. All the data in the column will be lost. - - You are about to drop the column `consumer` on the `coverage` table. All the data in the column will be lost. - - You are about to drop the column `tags` on the `coverage` table. All the data in the column will be lost. - - You are about to drop the `organization` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `organization_member` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `summary` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `usage` table. If the table is not empty, all the data it contains will be lost. - - Added the required column `cov_origin` to the `coverage` table without a default value. This is not possible if the table is not empty. - - Added the required column `provider` to the `coverage` table without a default value. This is not possible if the table is not empty. - - Added the required column `summary` to the `coverage` table without a default value. This is not possible if the table is not empty. - - Added the required column `tag` to the `coverage` table without a default value. This is not possible if the table is not empty. - - Made the column `key` on table `coverage` required. This step will fail if there are existing NULL values in that column. - - Made the column `instrument_cwd` on table `coverage` required. This step will fail if there are existing NULL values in that column. - - Changed the type of `relation_id` on the `coverage` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. - -*/ --- AlterTable -ALTER TABLE "coverage" DROP COLUMN "children", -DROP COLUMN "consumer", -DROP COLUMN "tags", -ADD COLUMN "cov_origin" TEXT NOT NULL, -ADD COLUMN "provider" TEXT NOT NULL, -ADD COLUMN "summary" JSONB NOT NULL, -ADD COLUMN "tag" JSONB NOT NULL, -ALTER COLUMN "key" SET NOT NULL, -ALTER COLUMN "instrument_cwd" SET NOT NULL, -ALTER COLUMN "reporter" SET DATA TYPE TEXT, -DROP COLUMN "relation_id", -ADD COLUMN "relation_id" JSONB NOT NULL; - --- DropTable -DROP TABLE "organization"; - --- DropTable -DROP TABLE "organization_member"; - --- DropTable -DROP TABLE "summary"; - --- DropTable -DROP TABLE "usage"; - --- DropEnum -DROP TYPE "organization_member_role"; - --- CreateTable -CREATE TABLE "coveragedata" ( - "id" TEXT NOT NULL, - "compresseddata" TEXT NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "coveragedata_pkey" PRIMARY KEY ("id") -); diff --git a/packages/canyon-backend/prisma/migrations/20240306090115_init/migration.sql b/packages/canyon-backend/prisma/migrations/20240407130953_upd/migration.sql similarity index 63% rename from packages/canyon-backend/prisma/migrations/20240306090115_init/migration.sql rename to packages/canyon-backend/prisma/migrations/20240407130953_upd/migration.sql index 2af59b76..17a0e448 100644 --- a/packages/canyon-backend/prisma/migrations/20240306090115_init/migration.sql +++ b/packages/canyon-backend/prisma/migrations/20240407130953_upd/migration.sql @@ -1,5 +1,5 @@ -- CreateTable -CREATE TABLE "user" ( +CREATE TABLE "user_0407" ( "id" INTEGER NOT NULL, "username" TEXT NOT NULL, "password" TEXT NOT NULL, @@ -10,33 +10,43 @@ CREATE TABLE "user" ( "email" TEXT NOT NULL, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - CONSTRAINT "user_pkey" PRIMARY KEY ("id") + CONSTRAINT "user_0407_pkey" PRIMARY KEY ("id") ); -- CreateTable -CREATE TABLE "coverage" ( +CREATE TABLE "coverage_0407" ( "id" TEXT NOT NULL, - "key" TEXT, + "key" TEXT NOT NULL, "sha" TEXT NOT NULL, "branch" TEXT NOT NULL, "compare_target" TEXT NOT NULL, + "provider" TEXT NOT NULL, "project_id" TEXT NOT NULL, - "instrument_cwd" TEXT, - "reporter" INTEGER NOT NULL, + "instrument_cwd" TEXT NOT NULL, + "reporter" TEXT NOT NULL, "report_id" TEXT NOT NULL, "cov_type" TEXT NOT NULL, - "relation_id" TEXT NOT NULL, + "cov_origin" TEXT NOT NULL, + "relation_id" JSONB NOT NULL, + "summary" JSONB NOT NULL, + "tag" JSONB NOT NULL, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "consumer" INTEGER NOT NULL, - "children" TEXT[], - "tags" JSONB[], - CONSTRAINT "coverage_pkey" PRIMARY KEY ("id") + CONSTRAINT "coverage_0407_pkey" PRIMARY KEY ("id") ); -- CreateTable -CREATE TABLE "project" ( +CREATE TABLE "coveragedata_0407" ( + "id" TEXT NOT NULL, + "compresseddata" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "coveragedata_0407_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "project_0407" ( "id" TEXT NOT NULL, "name" TEXT NOT NULL, "path_with_namespace" TEXT NOT NULL, @@ -47,44 +57,29 @@ CREATE TABLE "project" ( "default_branch" TEXT NOT NULL, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - CONSTRAINT "project_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "summary" ( - "id" TEXT NOT NULL, - "total" INTEGER NOT NULL, - "covered" INTEGER NOT NULL, - "skipped" INTEGER NOT NULL, - "metric_type" TEXT NOT NULL, - "cov_type" TEXT NOT NULL, - "report_id" TEXT NOT NULL, - "sha" TEXT NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "summary_pkey" PRIMARY KEY ("id") + CONSTRAINT "project_0407_pkey" PRIMARY KEY ("id") ); -- CreateTable -CREATE TABLE "codechange" ( +CREATE TABLE "codechange_0407" ( "id" TEXT NOT NULL, "project_id" TEXT NOT NULL, "compare_target" TEXT NOT NULL, - "sha" TEXT NOT NULL, + "sha_0407" TEXT NOT NULL, "path" TEXT NOT NULL, "additions" INTEGER[], "deletions" INTEGER[], "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - CONSTRAINT "codechange_pkey" PRIMARY KEY ("id") + CONSTRAINT "codechange_0407_pkey" PRIMARY KEY ("id") ); -- CreateTable -CREATE TABLE "distributedlock" ( +CREATE TABLE "distributedlock_0407" ( "lockName" TEXT NOT NULL, "isLocked" BOOLEAN NOT NULL DEFAULT false, "lockTimestamp" TIMESTAMP(3), "lockExpiration" TIMESTAMP(3), - CONSTRAINT "distributedlock_pkey" PRIMARY KEY ("lockName") + CONSTRAINT "distributedlock_0407_pkey" PRIMARY KEY ("lockName") ); diff --git a/packages/canyon-backend/prisma/schema.prisma b/packages/canyon-backend/prisma/schema.prisma index fd448c14..08054f4e 100755 --- a/packages/canyon-backend/prisma/schema.prisma +++ b/packages/canyon-backend/prisma/schema.prisma @@ -19,7 +19,7 @@ model User { email String createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3) - @@map("user") + @@map("user_0407") } model Coverage { @@ -41,7 +41,7 @@ model Coverage { createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3) updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(3) - @@map("coverage") + @@map("coverage_0407") } model CoverageData { @@ -49,7 +49,7 @@ model CoverageData { compresseddata String createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3) - @@map("coveragedata") + @@map("coveragedata_0407") } model Project { @@ -63,7 +63,7 @@ model Project { defaultBranch String @map("default_branch") createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3) - @@map("project") + @@map("project_0407") } model Codechange { @@ -82,7 +82,7 @@ model Codechange { createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3) - @@map("codechange") + @@map("codechange_0407") } model Distributedlock { @@ -91,5 +91,5 @@ model Distributedlock { lockTimestamp DateTime? lockExpiration DateTime? - @@map("distributedlock") + @@map("distributedlock_0407") }