Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [


{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"name": "Attach NestJS WS",
"port": 9229,
"processId": "${command:PickProcess}"
},
"restart": true,
"stopOnEntry": false,
"protocol": "inspector"
}
]
}
14 changes: 13 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"docker:build_api": "docker build -t visualregressiontracker/api:$npm_package_version -f ./Dockerfile . && docker push visualregressiontracker/api:$npm_package_version",
"docker:build_api": "npm run test && npm run test:e2e && docker build -t visualregressiontracker/api:$npm_package_version -f ./Dockerfile . && docker push visualregressiontracker/api:$npm_package_version",
"docker:build_migration": "docker build -t visualregressiontracker/migration:0.0.2 -f ./prisma/Dockerfile ./prisma"
},
"dependencies": {
Expand Down Expand Up @@ -53,6 +53,7 @@
"@nestjs/schematics": "^7.0.0",
"@nestjs/testing": "^7.0.0",
"@prisma/cli": "^2.0.0-beta.5",
"@types/bcryptjs": "^2.4.2",
"@types/express": "^4.17.3",
"@types/jest": "25.1.4",
"@types/node": "^13.9.1",
Expand All @@ -61,6 +62,7 @@
"@types/pixelmatch": "^5.1.0",
"@types/pngjs": "^3.4.2",
"@types/supertest": "^2.0.8",
"@types/uuid-apikey": "^1.4.0",
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0",
"eslint": "^6.8.0",
Expand Down
112 changes: 112 additions & 0 deletions prisma/migrations/20200524162125-baseline-history/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Migration `20200524162125-baseline-history`

This migration has been generated by Pavel Strunkin at 5/24/2020, 4:21:25 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.

## Database Steps

```sql
CREATE TABLE "public"."Baseline" (
"baselineName" text NOT NULL ,"createdAt" timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,"id" text NOT NULL ,"testRunId" text ,"testVariationId" text NOT NULL ,"updatedAt" timestamp(3) NOT NULL ,
PRIMARY KEY ("id"))

ALTER TABLE "public"."TestRun" ADD COLUMN "baselineName" text ,
ADD COLUMN "browser" text ,
ADD COLUMN "device" text ,
ADD COLUMN "ignoreAreas" text NOT NULL DEFAULT '[]',
ADD COLUMN "name" text NOT NULL DEFAULT '',
ADD COLUMN "os" text ,
ADD COLUMN "viewport" text ;

CREATE UNIQUE INDEX "Baseline_testRunId" ON "public"."Baseline"("testRunId")

ALTER TABLE "public"."Baseline" ADD FOREIGN KEY ("testVariationId")REFERENCES "public"."TestVariation"("id") ON DELETE CASCADE ON UPDATE CASCADE

ALTER TABLE "public"."Baseline" ADD FOREIGN KEY ("testRunId")REFERENCES "public"."TestRun"("id") ON DELETE SET NULL ON UPDATE CASCADE
```

## Changes

```diff
diff --git schema.prisma schema.prisma
migration 20200503001556-init..20200524162125-baseline-history
--- datamodel.dml
+++ datamodel.dml
@@ -3,9 +3,9 @@
}
datasource db {
provider = "postgresql"
- url = "***"
+ url = env("DATABASE_URL")
}
model Build {
id String @default(uuid()) @id
@@ -14,12 +14,12 @@
status String?
testRuns TestRun[]
projectId String
project Project @relation(fields: [projectId], references: [id])
- // userId String
- // user User @relation(fields: [userId], references: [id])
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
+ user User? @relation(fields: [userId], references: [id])
+ userId String?
}
model Project {
id String @default(uuid()) @id
@@ -43,26 +43,48 @@
testVariationId String
testVariation TestVariation @relation(fields: [testVariationId], references: [id])
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
+ // Test variation data
+ name String @default("")
+ browser String?
+ device String?
+ os String?
+ viewport String?
+ baselineName String?
+ ignoreAreas String @default("[]")
+ // Baseline
+ baseline Baseline?
}
model TestVariation {
- id String @default(uuid()) @id
+ id String @default(uuid()) @id
name String
browser String?
device String?
os String?
viewport String?
baselineName String?
- ignoreAreas String @default("[]")
+ ignoreAreas String @default("[]")
projectId String
- project Project @relation(fields: [projectId], references: [id])
+ project Project @relation(fields: [projectId], references: [id])
testRuns TestRun[]
- updatedAt DateTime @updatedAt
- createdAt DateTime @default(now())
+ baselines Baseline[]
+ updatedAt DateTime @updatedAt
+ createdAt DateTime @default(now())
}
+model Baseline {
+ id String @default(uuid()) @id
+ baselineName String
+ testVariationId String
+ testVariation TestVariation @relation(fields: [testVariationId], references: [id])
+ testRunId String?
+ testRun TestRun? @relation(fields: [testRunId], references: [id])
+ updatedAt DateTime @updatedAt
+ createdAt DateTime @default(now())
+}
+
model User {
id String @default(uuid()) @id
email String @unique
password String
```


105 changes: 105 additions & 0 deletions prisma/migrations/20200524162125-baseline-history/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = "***"
}

model Build {
id String @default(uuid()) @id
number Int?
branchName String?
status String?
testRuns TestRun[]
projectId String
project Project @relation(fields: [projectId], references: [id])
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
user User? @relation(fields: [userId], references: [id])
userId String?
}

model Project {
id String @default(uuid()) @id
name String
builds Build[]
testVariations TestVariation[]
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
}

model TestRun {
id String @default(uuid()) @id
imageName String
diffName String?
diffPercent Float?
diffTollerancePercent Float @default(1.0)
pixelMisMatchCount Int?
status TestStatus
buildId String
build Build @relation(fields: [buildId], references: [id])
testVariationId String
testVariation TestVariation @relation(fields: [testVariationId], references: [id])
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
// Test variation data
name String @default("")
browser String?
device String?
os String?
viewport String?
baselineName String?
ignoreAreas String @default("[]")
// Baseline
baseline Baseline?
}

model TestVariation {
id String @default(uuid()) @id
name String
browser String?
device String?
os String?
viewport String?
baselineName String?
ignoreAreas String @default("[]")
projectId String
project Project @relation(fields: [projectId], references: [id])
testRuns TestRun[]
baselines Baseline[]
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
}

model Baseline {
id String @default(uuid()) @id
baselineName String
testVariationId String
testVariation TestVariation @relation(fields: [testVariationId], references: [id])
testRunId String?
testRun TestRun? @relation(fields: [testRunId], references: [id])
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
}

model User {
id String @default(uuid()) @id
email String @unique
password String
firstName String?
lastName String?
apiKey String @unique
isActive Boolean @default(true)
builds Build[]
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
}

enum TestStatus {
failed
new
ok
unresolved
}
Loading