Skip to content

Commit 7ce7fc1

Browse files
committed
migrate. project name unique constraint added
1 parent 7db3a10 commit 7ce7fc1

File tree

5 files changed

+174
-1
lines changed

5 files changed

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

prisma/migrations/migrate.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
20200503001556-init
44
20200524162125-baseline-history
55
20200526195312-approved-test-status-added
6-
20200627134248-comment-added
6+
20200627134248-comment-added
7+
20200707182652-project-name-unique-constraint

prisma/schema.prisma

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ model Project {
2828
testVariations TestVariation[]
2929
updatedAt DateTime @updatedAt
3030
createdAt DateTime @default(now())
31+
32+
@@unique([name])
3133
}
3234

3335
model TestRun {

0 commit comments

Comments
 (0)