From 8db84391f9a438a56929a787ebd266fe91b416ef Mon Sep 17 00:00:00 2001 From: quentingrchr Date: Wed, 23 Oct 2024 15:25:04 +0200 Subject: [PATCH 1/3] add prisma migration check --- .github/workflows/code-chek.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/code-chek.yml diff --git a/.github/workflows/code-chek.yml b/.github/workflows/code-chek.yml new file mode 100644 index 0000000..d29e24b --- /dev/null +++ b/.github/workflows/code-chek.yml @@ -0,0 +1,27 @@ +name: Check code + +on: + pull_request: + branches: + - main + +jobs: + check-migrations: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + + - name: Check Prisma Migrations + uses: premieroctet/prisma-drop-migration-warning@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + main-branch: 'main' + path: 'prisma' + warning: true \ No newline at end of file From 02f7375d51be7427695e46e3fd1904c1a314b925 Mon Sep 17 00:00:00 2001 From: quentingrchr Date: Wed, 23 Oct 2024 15:49:22 +0200 Subject: [PATCH 2/3] add new model --- prisma/json-schema/json-schema.json | 36 +++++ .../migration.sql | 22 +++ .../migration.sql | 2 + prisma/schema.prisma | 138 ++++++++++-------- 4 files changed, 135 insertions(+), 63 deletions(-) create mode 100644 prisma/migrations/20241023134742_new_cool_migration/migration.sql create mode 100644 prisma/migrations/20241023134913_this_one_is_better/migration.sql diff --git a/prisma/json-schema/json-schema.json b/prisma/json-schema/json-schema.json index a1ebcc5..b15fadf 100644 --- a/prisma/json-schema/json-schema.json +++ b/prisma/json-schema/json-schema.json @@ -95,6 +95,12 @@ "type": "string", "format": "date-time" }, + "hello": { + "type": [ + "string", + "null" + ] + }, "name": { "type": [ "string", @@ -155,6 +161,16 @@ "type": "null" } ] + }, + "vault": { + "anyOf": [ + { + "$ref": "#/definitions/Vault" + }, + { + "type": "null" + } + ] } } }, @@ -173,6 +189,23 @@ } } }, + "Vault": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "password": { + "type": "string" + }, + "User": { + "type": "array", + "items": { + "$ref": "#/definitions/User" + } + } + } + }, "Team": { "type": "object", "properties": { @@ -704,6 +737,9 @@ "verificationToken": { "$ref": "#/definitions/VerificationToken" }, + "vault": { + "$ref": "#/definitions/Vault" + }, "team": { "$ref": "#/definitions/Team" }, diff --git a/prisma/migrations/20241023134742_new_cool_migration/migration.sql b/prisma/migrations/20241023134742_new_cool_migration/migration.sql new file mode 100644 index 0000000..17b81a7 --- /dev/null +++ b/prisma/migrations/20241023134742_new_cool_migration/migration.sql @@ -0,0 +1,22 @@ +/* + Warnings: + + - You are about to drop the column `image` on the `users` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "users" DROP COLUMN "image", +ADD COLUMN "hello" TEXT, +ADD COLUMN "vaultId" TEXT; + +-- CreateTable +CREATE TABLE "Vault" ( + "id" TEXT NOT NULL, + "password" TEXT NOT NULL +); + +-- CreateIndex +CREATE UNIQUE INDEX "Vault_id_key" ON "Vault"("id"); + +-- AddForeignKey +ALTER TABLE "users" ADD CONSTRAINT "users_vaultId_fkey" FOREIGN KEY ("vaultId") REFERENCES "Vault"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/migrations/20241023134913_this_one_is_better/migration.sql b/prisma/migrations/20241023134913_this_one_is_better/migration.sql new file mode 100644 index 0000000..39de7af --- /dev/null +++ b/prisma/migrations/20241023134913_this_one_is_better/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "users" ADD COLUMN "image" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 405e5d4..f8df1bd 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -38,7 +38,7 @@ enum DigestBlockType { } model Account { - id String @id @default(uuid()) + id String @id @default(uuid()) userId String type String provider String @@ -70,6 +70,7 @@ model User { id String @id @default(uuid()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + hello String? name String? email String? @unique emailVerified DateTime? @@ -80,6 +81,8 @@ model User { memberships Membership[] defaultTeam Team? @relation(fields: [defaultTeamId], references: [id], onDelete: SetNull) defaultTeamId String? + vault Vault? @relation(fields: [vaultId], references: [id], onDelete: SetNull) + vaultId String? @@map("users") } @@ -93,29 +96,35 @@ model VerificationToken { @@map("verification_tokens") } +model Vault { + id String @unique + password String + User User[] +} + model Team { - id String @id @default(uuid()) - name String - slug String - memberships Membership[] - subscriptions Subscription[] - users User[] - Digest Digest[] - bookmarks Bookmark[] - slackToken String? - slackTeamId String? - typefullyToken String? - bio String? - website String? - twitter String? - github String? - createdAt DateTime @default(now()) - apiKey String? + id String @id @default(uuid()) + name String + slug String + memberships Membership[] + subscriptions Subscription[] + users User[] + Digest Digest[] + bookmarks Bookmark[] + slackToken String? + slackTeamId String? + typefullyToken String? + bio String? + website String? + twitter String? + github String? + createdAt DateTime @default(now()) + apiKey String? nextSuggestedDigestTitle String? - color String? - subscriptionId String? - prompt String? - + color String? + subscriptionId String? + prompt String? + @@unique([id, slackTeamId]) @@unique(slug) @@map("teams") @@ -159,86 +168,89 @@ model Link { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt bookmark Bookmark[] - tags Tag[] @relation("links_to_tags") + tags Tag[] @relation("links_to_tags") + @@map("links") } model Bookmark { - id String @id @default(uuid()) - link Link @relation(fields: [linkId], references: [id], onDelete: Cascade) + id String @id @default(uuid()) + link Link @relation(fields: [linkId], references: [id], onDelete: Cascade) linkId String - membership Membership? @relation(fields: [membershipId], references: [id], onDelete: SetNull) + membership Membership? @relation(fields: [membershipId], references: [id], onDelete: SetNull) membershipId String? - team Team @relation(fields: [teamId], references: [id], onDelete: Cascade) + team Team @relation(fields: [teamId], references: [id], onDelete: Cascade) teamId String - provider Provider @default(WEB) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + provider Provider @default(WEB) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt digestBlocks DigestBlock[] metadata Json? - views Int @default(0) + views Int @default(0) + @@map("bookmarks") } model Digest { - id String @id @default(uuid()) - title String - slug String - description String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - publishedAt DateTime? - team Team @relation(fields: [teamId], references: [id], onDelete: Cascade) - teamId String - digestBlocks DigestBlock[] + id String @id @default(uuid()) + title String + slug String + description String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + publishedAt DateTime? + team Team @relation(fields: [teamId], references: [id], onDelete: Cascade) + teamId String + digestBlocks DigestBlock[] typefullyThreadUrl String? - hasSentNewsletter Boolean @default(false) - isFeatured Boolean @default(false) - isTemplate Boolean @default(false) - views Int @default(0) + hasSentNewsletter Boolean @default(false) + isFeatured Boolean @default(false) + isTemplate Boolean @default(false) + views Int @default(0) + @@unique([slug, teamId]) @@map("digests") } - model DigestBlock { - id String @id @default(uuid()) - bookmark Bookmark? @relation(fields : [bookmarkId], references : [id], onDelete: Cascade) + id String @id @default(uuid()) + bookmark Bookmark? @relation(fields: [bookmarkId], references: [id], onDelete: Cascade) bookmarkId String? - digest Digest @relation(fields : [digestId], references: [id], onDelete: Cascade) + digest Digest @relation(fields: [digestId], references: [id], onDelete: Cascade) digestId String order Int style BookmarkDigestStyle @default(BLOCK) title String? description String? - type DigestBlockType @default(BOOKMARK) + type DigestBlockType @default(BOOKMARK) text String? - isTemplate Boolean @default(false) - tags Tag[] @relation("digestblocks_to_tags") + isTemplate Boolean @default(false) + tags Tag[] @relation("digestblocks_to_tags") @@unique([bookmarkId, digestId]) @@map("digest_blocks") } model Subscription { - id String @id @default(uuid()) - team Team @relation(fields: [teamId], references: [id], onDelete: Cascade) - teamId String - email String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(uuid()) + team Team @relation(fields: [teamId], references: [id], onDelete: Cascade) + teamId String + email String + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt @@map("subscriptions") } model Tag { - id String @id @default(uuid()) + id String @id @default(uuid()) name String slug String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt description String? - links Link[] @relation("links_to_tags") + links Link[] @relation("links_to_tags") bookmarks DigestBlock[] @relation("digestblocks_to_tags") + @@map("tags") -} \ No newline at end of file +} From 51f3c857761558ce1f7179eb86d67104fdf1c991 Mon Sep 17 00:00:00 2001 From: quentingrchr Date: Wed, 23 Oct 2024 16:02:39 +0200 Subject: [PATCH 3/3] remove unused check --- .github/workflows/code-chek.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/code-chek.yml diff --git a/.github/workflows/code-chek.yml b/.github/workflows/code-chek.yml deleted file mode 100644 index d29e24b..0000000 --- a/.github/workflows/code-chek.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Check code - -on: - pull_request: - branches: - - main - -jobs: - check-migrations: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - - name: Check Prisma Migrations - uses: premieroctet/prisma-drop-migration-warning@main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - main-branch: 'main' - path: 'prisma' - warning: true \ No newline at end of file