Skip to content

Commit 4be16ad

Browse files
authored
Merge pull request #18 from Visual-Regression-Tracker/69-branch-stratedy
69 branch stratedy
2 parents fd5ccea + 6663aca commit 4be16ad

File tree

10 files changed

+771
-91
lines changed

10 files changed

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

prisma/migrations/migrate.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
20200524162125-baseline-history
55
20200526195312-approved-test-status-added
66
20200627134248-comment-added
7-
20200707182652-project-name-unique-constraint
7+
20200707182652-project-name-unique-constraint
8+
20200711125803-branch-strategy

prisma/schema.prisma

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ model Build {
2424
model Project {
2525
id String @default(uuid()) @id
2626
name String
27+
mainBranchName String @default("master")
2728
builds Build[]
2829
testVariations TestVariation[]
2930
updatedAt DateTime @updatedAt
@@ -56,6 +57,8 @@ model TestRun {
5657
ignoreAreas String @default("[]")
5758
comment String?
5859
baseline Baseline?
60+
branchName String @default("master")
61+
baselineBranchName String?
5962
}
6063

6164
model TestVariation {
@@ -72,6 +75,7 @@ model TestVariation {
7275
testRuns TestRun[]
7376
baselines Baseline[]
7477
comment String?
78+
branchName String @default("master")
7579
updatedAt DateTime @updatedAt
7680
createdAt DateTime @default(now())
7781
}

src/shared/dto/baseline-data.dto.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ export class BaselineDataDto {
2525
@IsOptional()
2626
@IsString()
2727
device?: string;
28+
29+
@ApiProperty()
30+
@IsString()
31+
branchName: string;
2832
}
2933

3034
export const convertBaselineDataToQuery = (data: BaselineDataDto) => {
3135
return {
3236
name: data.name,
37+
branchName: data.branchName,
3338
os: data.os ? data.os : null,
3439
browser: data.browser ? data.browser : null,
3540
device: data.device ? data.device : null,

0 commit comments

Comments
 (0)