Skip to content

Commit c05438f

Browse files
authored
Merge pull request #72 from Visual-Regression-Tracker/142-add-build-name
Add build upsert by ID
2 parents 3c98e5d + 5979f1b commit c05438f

23 files changed

+421
-157
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Migration `20201115155739-ci-build-id-added`
2+
3+
This migration has been generated by Pavel Strunkin at 11/15/2020, 5:57:39 PM.
4+
You can check out the [state of the schema](./schema.prisma) after the migration.
5+
6+
## Database Steps
7+
8+
```sql
9+
ALTER TABLE "public"."Build" ADD COLUMN "ciBuildId" text
10+
11+
CREATE UNIQUE INDEX "Build.ciBuildId_unique" ON "public"."Build"("ciBuildId")
12+
```
13+
14+
## Changes
15+
16+
```diff
17+
diff --git schema.prisma schema.prisma
18+
migration 20201007145002-builds-counter..20201115155739-ci-build-id-added
19+
--- datamodel.dml
20+
+++ datamodel.dml
21+
@@ -1,16 +1,17 @@
22+
generator client {
23+
- provider = "prisma-client-js"
24+
+ provider = "prisma-client-js"
25+
previewFeatures = ["atomicNumberOperations"]
26+
}
27+
datasource db {
28+
- provider = "postgresql"
29+
- url = "***"
30+
+ provider = "postgresql"
31+
+ url = "***"
32+
}
33+
model Build {
34+
id String @id @default(uuid())
35+
+ ciBuildId String? @unique
36+
number Int?
37+
branchName String?
38+
status String?
39+
testRuns TestRun[]
40+
```
41+
42+
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
generator client {
2+
provider = "prisma-client-js"
3+
previewFeatures = ["atomicNumberOperations"]
4+
}
5+
6+
datasource db {
7+
provider = "postgresql"
8+
url = "***"
9+
}
10+
11+
model Build {
12+
id String @id @default(uuid())
13+
ciBuildId String? @unique
14+
number Int?
15+
branchName String?
16+
status String?
17+
testRuns TestRun[]
18+
projectId String
19+
project Project @relation(fields: [projectId], references: [id])
20+
updatedAt DateTime @updatedAt
21+
createdAt DateTime @default(now())
22+
user User? @relation(fields: [userId], references: [id])
23+
userId String?
24+
isRunning Boolean?
25+
}
26+
27+
model Project {
28+
id String @id @default(uuid())
29+
name String
30+
mainBranchName String @default("master")
31+
builds Build[]
32+
buildsCounter Int @default(0)
33+
testVariations TestVariation[]
34+
updatedAt DateTime @updatedAt
35+
createdAt DateTime @default(now())
36+
37+
@@unique([name])
38+
}
39+
40+
model TestRun {
41+
id String @id @default(uuid())
42+
imageName String
43+
diffName String?
44+
diffPercent Float?
45+
diffTollerancePercent Float @default(0)
46+
pixelMisMatchCount Int?
47+
status TestStatus
48+
buildId String
49+
build Build @relation(fields: [buildId], references: [id])
50+
testVariationId String
51+
testVariation TestVariation @relation(fields: [testVariationId], references: [id])
52+
merge Boolean @default(false)
53+
updatedAt DateTime @updatedAt
54+
createdAt DateTime @default(now())
55+
// Test variation data
56+
name String @default("")
57+
browser String?
58+
device String?
59+
os String?
60+
viewport String?
61+
baselineName String?
62+
ignoreAreas String @default("[]")
63+
comment String?
64+
baseline Baseline?
65+
branchName String @default("master")
66+
baselineBranchName String?
67+
}
68+
69+
model TestVariation {
70+
id String @id @default(uuid())
71+
name String
72+
branchName String @default("master")
73+
browser String?
74+
device String?
75+
os String?
76+
viewport String?
77+
baselineName String?
78+
ignoreAreas String @default("[]")
79+
projectId String
80+
project Project @relation(fields: [projectId], references: [id])
81+
testRuns TestRun[]
82+
baselines Baseline[]
83+
comment String?
84+
updatedAt DateTime @updatedAt
85+
createdAt DateTime @default(now())
86+
87+
@@unique([projectId, name, browser, device, os, viewport, branchName])
88+
}
89+
90+
model Baseline {
91+
id String @id @default(uuid())
92+
baselineName String
93+
testVariationId String
94+
testVariation TestVariation @relation(fields: [testVariationId], references: [id])
95+
testRunId String?
96+
testRun TestRun? @relation(fields: [testRunId], references: [id])
97+
updatedAt DateTime @updatedAt
98+
createdAt DateTime @default(now())
99+
}
100+
101+
model User {
102+
id String @id @default(uuid())
103+
email String @unique
104+
password String
105+
firstName String?
106+
lastName String?
107+
apiKey String @unique
108+
isActive Boolean @default(true)
109+
builds Build[]
110+
updatedAt DateTime @updatedAt
111+
createdAt DateTime @default(now())
112+
}
113+
114+
enum TestStatus {
115+
failed
116+
new
117+
ok
118+
unresolved
119+
approved
120+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": "0.3.14-fixed",
3+
"steps": [
4+
{
5+
"tag": "CreateField",
6+
"model": "Build",
7+
"field": "ciBuildId",
8+
"type": "String",
9+
"arity": "Optional"
10+
},
11+
{
12+
"tag": "CreateDirective",
13+
"location": {
14+
"path": {
15+
"tag": "Field",
16+
"model": "Build",
17+
"field": "ciBuildId"
18+
},
19+
"directive": "unique"
20+
}
21+
}
22+
]
23+
}

prisma/migrations/migrate.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
20200728221159-zero-diff-tolerance
1010
20200812213545-build-run-status
1111
20200909223305-test-variation-project-id-added-into-unique-constraint
12-
20201007145002-builds-counter
12+
20201007145002-builds-counter
13+
20201115155739-ci-build-id-added

prisma/schema.prisma

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
generator client {
2-
provider = "prisma-client-js"
2+
provider = "prisma-client-js"
33
previewFeatures = ["atomicNumberOperations"]
44
}
55

66
datasource db {
7-
provider = "postgresql"
8-
url = env("DATABASE_URL")
7+
provider = "postgresql"
8+
url = env("DATABASE_URL")
99
}
1010

1111
model Build {
1212
id String @id @default(uuid())
13+
ciBuildId String? @unique
1314
number Int?
1415
branchName String?
1516
status String?

src/builds/builds.module.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { Module } from '@nestjs/common';
1+
import { forwardRef, Module } from '@nestjs/common';
22
import { BuildsService } from './builds.service';
33
import { BuildsController } from './builds.controller';
44
import { UsersModule } from '../users/users.module';
55
import { PrismaService } from '../prisma/prisma.service';
66
import { TestRunsModule } from '../test-runs/test-runs.module';
77
import { SharedModule } from '../shared/shared.module';
88
import { AuthModule } from '../auth/auth.module';
9+
import { ProjectsModule } from '../projects/projects.module';
910

1011
@Module({
11-
imports: [SharedModule, UsersModule, TestRunsModule, AuthModule],
12+
imports: [SharedModule, UsersModule, forwardRef(() => TestRunsModule), AuthModule, forwardRef(() => ProjectsModule)],
1213
providers: [BuildsService, PrismaService],
1314
controllers: [BuildsController],
1415
exports: [BuildsService],

0 commit comments

Comments
 (0)