From 8a51fe7d238080e30288b9574c9eae52fd7a6ab7 Mon Sep 17 00:00:00 2001 From: bkellam Date: Sat, 20 Sep 2025 16:27:15 -0700 Subject: [PATCH] fix migrations --- .../migration.sql | 2 - .../migration.sql | 3 +- packages/db/prisma/schema.prisma | 50 ++++++++----------- 3 files changed, 24 insertions(+), 31 deletions(-) delete mode 100644 packages/db/prisma/migrations/20250919230022_add_is_public_column_to_repo_table/migration.sql rename packages/db/prisma/migrations/{20250919224623_add_permission_sync_tables => 20250920232318_add_permission_sync_tables}/migration.sql (94%) diff --git a/packages/db/prisma/migrations/20250919230022_add_is_public_column_to_repo_table/migration.sql b/packages/db/prisma/migrations/20250919230022_add_is_public_column_to_repo_table/migration.sql deleted file mode 100644 index 909a6d46..00000000 --- a/packages/db/prisma/migrations/20250919230022_add_is_public_column_to_repo_table/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "Repo" ADD COLUMN "isPublic" BOOLEAN; diff --git a/packages/db/prisma/migrations/20250919224623_add_permission_sync_tables/migration.sql b/packages/db/prisma/migrations/20250920232318_add_permission_sync_tables/migration.sql similarity index 94% rename from packages/db/prisma/migrations/20250919224623_add_permission_sync_tables/migration.sql rename to packages/db/prisma/migrations/20250920232318_add_permission_sync_tables/migration.sql index 1a8f0597..9e921c6d 100644 --- a/packages/db/prisma/migrations/20250919224623_add_permission_sync_tables/migration.sql +++ b/packages/db/prisma/migrations/20250920232318_add_permission_sync_tables/migration.sql @@ -5,7 +5,8 @@ CREATE TYPE "RepoPermissionSyncJobStatus" AS ENUM ('PENDING', 'IN_PROGRESS', 'CO CREATE TYPE "UserPermissionSyncJobStatus" AS ENUM ('PENDING', 'IN_PROGRESS', 'COMPLETED', 'FAILED'); -- AlterTable -ALTER TABLE "Repo" ADD COLUMN "permissionSyncedAt" TIMESTAMP(3); +ALTER TABLE "Repo" ADD COLUMN "isPublic" BOOLEAN NOT NULL DEFAULT false, +ADD COLUMN "permissionSyncedAt" TIMESTAMP(3); -- AlterTable ALTER TABLE "User" ADD COLUMN "permissionSyncedAt" TIMESTAMP(3); diff --git a/packages/db/prisma/schema.prisma b/packages/db/prisma/schema.prisma index 45d9452c..bdebbc69 100644 --- a/packages/db/prisma/schema.prisma +++ b/packages/db/prisma/schema.prisma @@ -41,35 +41,29 @@ enum ChatVisibility { } model Repo { - id Int @id @default(autoincrement()) - name String // Full repo name, including the vcs hostname (ex. github.com/sourcebot-dev/sourcebot) - displayName String? // Display name of the repo for UI (ex. sourcebot-dev/sourcebot) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - - /// When the repo was last indexed successfully. - indexedAt DateTime? + id Int @id @default(autoincrement()) + name String /// Full repo name, including the vcs hostname (ex. github.com/sourcebot-dev/sourcebot) + displayName String? /// Display name of the repo for UI (ex. sourcebot-dev/sourcebot) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + indexedAt DateTime? /// When the repo was last indexed successfully. isFork Boolean isArchived Boolean - isPublic Boolean? - metadata Json // For schema see repoMetadataSchema in packages/backend/src/types.ts + isPublic Boolean @default(false) + metadata Json /// For schema see repoMetadataSchema in packages/backend/src/types.ts cloneUrl String webUrl String? connections RepoToConnection[] imageUrl String? repoIndexingStatus RepoIndexingStatus @default(NEW) + permittedUsers UserToRepoPermission[] - permissionSyncJobs RepoPermissionSyncJob[] - /// When the permissions were last synced successfully. - permissionSyncedAt DateTime? + permissionSyncedAt DateTime? /// When the permissions were last synced successfully. - // The id of the repo in the external service - external_id String - // The type of the external service (e.g., github, gitlab, etc.) - external_codeHostType String - // The base url of the external service (e.g., https://github.com) - external_codeHostUrl String + external_id String /// The id of the repo in the external service + external_codeHostType String /// The type of the external service (e.g., github, gitlab, etc.) + external_codeHostUrl String /// The base url of the external service (e.g., https://github.com) org Org @relation(fields: [orgId], references: [id], onDelete: Cascade) orgId Int @@ -88,10 +82,10 @@ enum RepoPermissionSyncJobStatus { } model RepoPermissionSyncJob { - id String @id @default(cuid()) - status RepoPermissionSyncJobStatus @default(PENDING) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(cuid()) + status RepoPermissionSyncJobStatus @default(PENDING) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt completedAt DateTime? errorMessage String? @@ -327,15 +321,15 @@ enum UserPermissionSyncJobStatus { } model UserPermissionSyncJob { - id String @id @default(cuid()) - status UserPermissionSyncJobStatus @default(PENDING) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(cuid()) + status UserPermissionSyncJobStatus @default(PENDING) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt completedAt DateTime? errorMessage String? - user User @relation(fields: [userId], references: [id], onDelete: Cascade) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) userId String }