From 42437b6883a23d501a26db27ea0bae6571aa9790 Mon Sep 17 00:00:00 2001 From: Rohit Kumar Saini Date: Thu, 7 Mar 2024 23:13:07 +0530 Subject: [PATCH 1/2] fix(github-ids): update all github id's data types to BigInt in schema --- .../migration.sql | 35 +++++++++++++++++++ prisma/schema.prisma | 18 +++++----- 2 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 prisma/migrations/20240307174047_update_github_id_datatype_to_bigint/migration.sql diff --git a/prisma/migrations/20240307174047_update_github_id_datatype_to_bigint/migration.sql b/prisma/migrations/20240307174047_update_github_id_datatype_to_bigint/migration.sql new file mode 100644 index 0000000..ddfb0e2 --- /dev/null +++ b/prisma/migrations/20240307174047_update_github_id_datatype_to_bigint/migration.sql @@ -0,0 +1,35 @@ +-- DropForeignKey +ALTER TABLE "milestones" DROP CONSTRAINT "milestones_githubRepoId_fkey"; + +-- DropForeignKey +ALTER TABLE "synced_issues" DROP CONSTRAINT "synced_issues_githubRepoId_fkey"; + +-- DropForeignKey +ALTER TABLE "syncs" DROP CONSTRAINT "syncs_githubRepoId_fkey"; + +-- AlterTable +ALTER TABLE "github_repos" ALTER COLUMN "repoId" SET DATA TYPE BIGINT; + +-- AlterTable +ALTER TABLE "milestones" ALTER COLUMN "githubRepoId" SET DATA TYPE BIGINT; + +-- AlterTable +ALTER TABLE "synced_issues" ALTER COLUMN "githubIssueNumber" SET DATA TYPE BIGINT, +ALTER COLUMN "githubIssueId" SET DATA TYPE BIGINT, +ALTER COLUMN "githubRepoId" SET DATA TYPE BIGINT; + +-- AlterTable +ALTER TABLE "syncs" ALTER COLUMN "githubUserId" SET DATA TYPE BIGINT, +ALTER COLUMN "githubRepoId" SET DATA TYPE BIGINT; + +-- AlterTable +ALTER TABLE "users" ALTER COLUMN "githubUserId" SET DATA TYPE BIGINT; + +-- AddForeignKey +ALTER TABLE "synced_issues" ADD CONSTRAINT "synced_issues_githubRepoId_fkey" FOREIGN KEY ("githubRepoId") REFERENCES "github_repos"("repoId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "syncs" ADD CONSTRAINT "syncs_githubRepoId_fkey" FOREIGN KEY ("githubRepoId") REFERENCES "github_repos"("repoId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "milestones" ADD CONSTRAINT "milestones_githubRepoId_fkey" FOREIGN KEY ("githubRepoId") REFERENCES "github_repos"("repoId") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 7c4e70f..1bbbfab 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -4,23 +4,23 @@ datasource db { } generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" binaryTargets = ["native", "linux-musl"] } model SyncedIssue { id String @id @default(cuid()) - githubIssueNumber Int + githubIssueNumber BigInt linearIssueNumber Int - githubIssueId Int + githubIssueId BigInt linearIssueId String linearTeamId String LinearTeam LinearTeam @relation(fields: [linearTeamId], references: [teamId]) - githubRepoId Int + githubRepoId BigInt GitHubRepo GitHubRepo @relation(fields: [githubRepoId], references: [repoId]) @@map("synced_issues") @@ -49,7 +49,7 @@ model LinearTeam { model GitHubRepo { id String @id @default(cuid()) - repoId Int @unique + repoId BigInt @unique repoName String webhookSecret String @@ -65,11 +65,11 @@ model GitHubRepo { model Sync { id String @id @default(cuid()) - githubUserId Int + githubUserId BigInt linearUserId String GitHubRepo GitHubRepo @relation(fields: [githubRepoId], references: [repoId]) - githubRepoId Int + githubRepoId BigInt githubApiKey String githubApiKeyIV String @@ -85,7 +85,7 @@ model Sync { model User { id String @id @default(cuid()) - githubUserId Int + githubUserId BigInt githubUsername String githubEmail String? @@ -104,7 +104,7 @@ model Milestone { cycleId String GitHubRepo GitHubRepo @relation(fields: [githubRepoId], references: [repoId]) - githubRepoId Int + githubRepoId BigInt LinearTeam LinearTeam @relation(fields: [linearTeamId], references: [teamId]) linearTeamId String From c86c5a6b70836b6f4e19e42995f937e0f5654b51 Mon Sep 17 00:00:00 2001 From: Rohit Kumar Saini Date: Thu, 7 Mar 2024 23:57:57 +0530 Subject: [PATCH 2/2] fix(github-id-datatype): remove migration file --- .../migration.sql | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100644 prisma/migrations/20240307174047_update_github_id_datatype_to_bigint/migration.sql diff --git a/prisma/migrations/20240307174047_update_github_id_datatype_to_bigint/migration.sql b/prisma/migrations/20240307174047_update_github_id_datatype_to_bigint/migration.sql deleted file mode 100644 index ddfb0e2..0000000 --- a/prisma/migrations/20240307174047_update_github_id_datatype_to_bigint/migration.sql +++ /dev/null @@ -1,35 +0,0 @@ --- DropForeignKey -ALTER TABLE "milestones" DROP CONSTRAINT "milestones_githubRepoId_fkey"; - --- DropForeignKey -ALTER TABLE "synced_issues" DROP CONSTRAINT "synced_issues_githubRepoId_fkey"; - --- DropForeignKey -ALTER TABLE "syncs" DROP CONSTRAINT "syncs_githubRepoId_fkey"; - --- AlterTable -ALTER TABLE "github_repos" ALTER COLUMN "repoId" SET DATA TYPE BIGINT; - --- AlterTable -ALTER TABLE "milestones" ALTER COLUMN "githubRepoId" SET DATA TYPE BIGINT; - --- AlterTable -ALTER TABLE "synced_issues" ALTER COLUMN "githubIssueNumber" SET DATA TYPE BIGINT, -ALTER COLUMN "githubIssueId" SET DATA TYPE BIGINT, -ALTER COLUMN "githubRepoId" SET DATA TYPE BIGINT; - --- AlterTable -ALTER TABLE "syncs" ALTER COLUMN "githubUserId" SET DATA TYPE BIGINT, -ALTER COLUMN "githubRepoId" SET DATA TYPE BIGINT; - --- AlterTable -ALTER TABLE "users" ALTER COLUMN "githubUserId" SET DATA TYPE BIGINT; - --- AddForeignKey -ALTER TABLE "synced_issues" ADD CONSTRAINT "synced_issues_githubRepoId_fkey" FOREIGN KEY ("githubRepoId") REFERENCES "github_repos"("repoId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "syncs" ADD CONSTRAINT "syncs_githubRepoId_fkey" FOREIGN KEY ("githubRepoId") REFERENCES "github_repos"("repoId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "milestones" ADD CONSTRAINT "milestones_githubRepoId_fkey" FOREIGN KEY ("githubRepoId") REFERENCES "github_repos"("repoId") ON DELETE RESTRICT ON UPDATE CASCADE;