Skip to content

Commit

Permalink
🥭 UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
HeeManSu committed Jul 12, 2024
1 parent 8ccb4d5 commit 7cd0966
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 56 deletions.
93 changes: 93 additions & 0 deletions prisma/migrations/20240712133537_changed/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Warnings:
- The primary key for the `customers` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `issues` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `organization_people` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `organizations` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `sprints` table will be changed. If it partially fails, the table could be left without primary key constraint.
*/
-- DropForeignKey
ALTER TABLE "customers" DROP CONSTRAINT "customers_organizationId_fkey";

-- DropForeignKey
ALTER TABLE "issues" DROP CONSTRAINT "issues_customerId_fkey";

-- DropForeignKey
ALTER TABLE "issues" DROP CONSTRAINT "issues_organizationId_fkey";

-- DropForeignKey
ALTER TABLE "issues" DROP CONSTRAINT "issues_sprintId_fkey";

-- DropForeignKey
ALTER TABLE "issues" DROP CONSTRAINT "issues_team_memberId_fkey";

-- DropForeignKey
ALTER TABLE "organization_people" DROP CONSTRAINT "organization_people_organizationId_fkey";

-- DropForeignKey
ALTER TABLE "sprints" DROP CONSTRAINT "sprints_organizationId_fkey";

-- AlterTable
ALTER TABLE "customers" DROP CONSTRAINT "customers_pkey",
ALTER COLUMN "customer_id" DROP DEFAULT,
ALTER COLUMN "customer_id" SET DATA TYPE TEXT,
ALTER COLUMN "organizationId" SET DATA TYPE TEXT,
ADD CONSTRAINT "customers_pkey" PRIMARY KEY ("customer_id");
DROP SEQUENCE "customers_customer_id_seq";

-- AlterTable
ALTER TABLE "issues" DROP CONSTRAINT "issues_pkey",
ALTER COLUMN "issue_id" DROP DEFAULT,
ALTER COLUMN "issue_id" SET DATA TYPE TEXT,
ALTER COLUMN "customerId" SET DATA TYPE TEXT,
ALTER COLUMN "team_memberId" SET DATA TYPE TEXT,
ALTER COLUMN "organizationId" SET DATA TYPE TEXT,
ALTER COLUMN "sprintId" SET DATA TYPE TEXT,
ADD CONSTRAINT "issues_pkey" PRIMARY KEY ("issue_id");
DROP SEQUENCE "issues_issue_id_seq";

-- AlterTable
ALTER TABLE "organization_people" DROP CONSTRAINT "organization_people_pkey",
ALTER COLUMN "team_member_id" DROP DEFAULT,
ALTER COLUMN "team_member_id" SET DATA TYPE TEXT,
ALTER COLUMN "organizationId" SET DATA TYPE TEXT,
ADD CONSTRAINT "organization_people_pkey" PRIMARY KEY ("team_member_id");
DROP SEQUENCE "organization_people_team_member_id_seq";

-- AlterTable
ALTER TABLE "organizations" DROP CONSTRAINT "organizations_pkey",
ALTER COLUMN "organization_id" DROP DEFAULT,
ALTER COLUMN "organization_id" SET DATA TYPE TEXT,
ADD CONSTRAINT "organizations_pkey" PRIMARY KEY ("organization_id");
DROP SEQUENCE "organizations_organization_id_seq";

-- AlterTable
ALTER TABLE "sprints" DROP CONSTRAINT "sprints_pkey",
ALTER COLUMN "sprint_id" DROP DEFAULT,
ALTER COLUMN "sprint_id" SET DATA TYPE TEXT,
ALTER COLUMN "organizationId" SET DATA TYPE TEXT,
ADD CONSTRAINT "sprints_pkey" PRIMARY KEY ("sprint_id");
DROP SEQUENCE "sprints_sprint_id_seq";

-- AddForeignKey
ALTER TABLE "organization_people" ADD CONSTRAINT "organization_people_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organizations"("organization_id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "customers" ADD CONSTRAINT "customers_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organizations"("organization_id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "issues" ADD CONSTRAINT "issues_customerId_fkey" FOREIGN KEY ("customerId") REFERENCES "customers"("customer_id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "issues" ADD CONSTRAINT "issues_team_memberId_fkey" FOREIGN KEY ("team_memberId") REFERENCES "organization_people"("team_member_id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "issues" ADD CONSTRAINT "issues_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organizations"("organization_id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "issues" ADD CONSTRAINT "issues_sprintId_fkey" FOREIGN KEY ("sprintId") REFERENCES "sprints"("sprint_id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "sprints" ADD CONSTRAINT "sprints_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "organizations"("organization_id") ON DELETE RESTRICT ON UPDATE CASCADE;
102 changes: 46 additions & 56 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -8,73 +8,78 @@ datasource db {
}

model Organization {
organization_id Int @id @default(autoincrement())
organization_id String @id @default(uuid())
name String
customers Customer[]
Issue Issue[]
organization_peoples Organization_People[]
Issue Issue[]
Sprints Sprint[]
Sprints Sprint[]
@@map("organizations")
}

model Organization_People {
team_member_id Int @id @default(autoincrement())
email String @unique
team_member_id String @id @default(uuid())
email String @unique
name String
role Role @default(member)
organizationId Int
role Role @default(member)
organizationId String
Issue Issue[]
organization Organization @relation(fields: [organizationId], references: [organization_id])
Issue Issue[]
@@map("organization_people")
}

enum Role {
admin
member
}

model Customer {
customer_id Int @id @default(autoincrement())
name String
phone Int? @unique
email String @unique
organizationId Int
customer_id String @id @default(uuid())
phone Int? @unique
email String @unique
organizationId String
name String
organization Organization @relation(fields: [organizationId], references: [organization_id])
issues Issue[]
issues Issue[]
@@map("customers")
}

model Issue {
issue_id Int @id @default(autoincrement())
title String
description String?
state State? @default(todo)
priority Priority? @default(low)
created_at DateTime @default(now())
updated_at DateTime @updatedAt
deleted_at DateTime?
customerId Int
customer Customer @relation(fields: [customerId], references: [customer_id])
issue_id String @id @default(uuid())
title String
description String?
state State? @default(todo)
priority Priority? @default(low)
created_at DateTime @default(now())
updated_at DateTime @updatedAt
deleted_at DateTime?
customerId String
team_memberId String
organizationId String
sprintId String?
customer Customer @relation(fields: [customerId], references: [customer_id])
organization Organization @relation(fields: [organizationId], references: [organization_id])
sprint Sprint? @relation(fields: [sprintId], references: [sprint_id])
team_member Organization_People @relation(fields: [team_memberId], references: [team_member_id])
team_memberId Int
team_member Organization_People @relation(fields: [team_memberId], references: [team_member_id])
@@map("issues")
}

organizationId Int
model Sprint {
sprint_id String @id @default(uuid())
name String
description String?
start_date DateTime
end_date DateTime
status SprintStatus
organizationId String
issue Issue[]
organization Organization @relation(fields: [organizationId], references: [organization_id])
sprintId Int?
sprint Sprint? @relation(fields: [sprintId], references: [sprint_id])
@@map("sprints")
}

@@map("issues")
enum Role {
admin
member
}

enum State {
Expand All @@ -90,21 +95,6 @@ enum Priority {
medium
}

model Sprint {
sprint_id Int @id @default(autoincrement())
name String
description String?
start_date DateTime
end_date DateTime
status SprintStatus
organizationId Int
organization Organization @relation(fields: [organizationId], references: [organization_id])
issue Issue[]
@@map("sprints")
}

enum SprintStatus {
ongoing
upcoming
Expand Down

0 comments on commit 7cd0966

Please sign in to comment.