diff --git a/.github/workflows/deploy-to-vm.yaml b/.github/workflows/deploy-to-vm.yaml index b0d34ba..f7d2eca 100644 --- a/.github/workflows/deploy-to-vm.yaml +++ b/.github/workflows/deploy-to-vm.yaml @@ -25,12 +25,7 @@ name: CI/CD - Deploy to VM -on: - workflow_run: - workflows: ['CI/CD - Linter, formatter and tests'] - types: [completed] - branches: - - main +on: workflow_dispatch permissions: contents: read @@ -79,6 +74,9 @@ jobs: printf 'DATABASE_URL="%s"\n' "$DATABASE_URL" > apps/backend/.env cp apps/backend/.env packages/db/.env + - name: Apply database migrations + run: pnpm --filter @t09-project-2/db run db:push + - name: Generate Prisma client run: pnpm --filter @t09-project-2/db run db:generate diff --git a/README.md b/README.md index 3cbbd9d..189d0d1 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Most recent commit hash at time of hand-in: [`efdbfa5`](https://git.ntnu.no/IT28 Handed in Oct 16th -Most recent commit hash at time of hand-in: [`TDB`](<>) (Will update if there is a more recent version in the future) +Most recent commit hash at time of hand-in: [`054801b`](https://git.ntnu.no/IT2810-H26/T09-Project-2/tree/054801b7b8058fe35a5303cd54ff7815cbac0be8) ### 3rd hand-in of project 2 diff --git a/docker-compose.yml b/docker-compose.yml index 64d4da1..b7584f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ services: db: container_name: g_spotter_db - image: postgres:16-alpine@sha256:b7587f3cb74f4f4b2a4f9d67f052edbf95eb93f4fec7c5ada3792546caaf7383 + image: postgres:18-alpine@sha256:898c60cb390d1085bc97bdd6a1ae968757421df394b071848b52b1c09c89d6a5 restart: always environment: POSTGRES_PASSWORD: gspotter diff --git a/packages/db/prisma/migrations/20261025211749_update_uuids_to_v7_and_remove_unnecessary_dates/migration.sql b/packages/db/prisma/migrations/20261025211749_update_uuids_to_v7_and_remove_unnecessary_dates/migration.sql new file mode 100644 index 0000000..ba7e32d --- /dev/null +++ b/packages/db/prisma/migrations/20261025211749_update_uuids_to_v7_and_remove_unnecessary_dates/migration.sql @@ -0,0 +1,15 @@ +-- AlterTable +ALTER TABLE "city" ALTER COLUMN "id" SET DEFAULT uuidv7(); + +-- AlterTable +ALTER TABLE "opening_hours" ALTER COLUMN "id" SET DEFAULT uuidv7(), +ALTER COLUMN "opening" SET DATA TYPE TIMETZ, +ALTER COLUMN "closing" SET DATA TYPE TIMETZ; + +-- AlterTable +ALTER TABLE "price_sighting" ALTER COLUMN "id" SET DEFAULT uuidv7(), +ALTER COLUMN "time_start" SET DATA TYPE TIMETZ, +ALTER COLUMN "time_end" SET DATA TYPE TIMETZ; + +-- AlterTable +ALTER TABLE "venue" ALTER COLUMN "id" SET DEFAULT uuidv7(); diff --git a/packages/db/prisma/schema.prisma b/packages/db/prisma/schema.prisma index 914b1db..f9b09c3 100644 --- a/packages/db/prisma/schema.prisma +++ b/packages/db/prisma/schema.prisma @@ -14,17 +14,17 @@ datasource db { } enum GlassSize { - PINT @map("PINT") - HALF_LITER @map("HALF_LITER") + PINT @map("PINT") + HALF_LITER @map("HALF_LITER") QUARTER_LITER @map("QUARTER_LITER") - BOX @map("BOX") - OTHER @map("OTHER") + BOX @map("BOX") + OTHER @map("OTHER") @@map("glass_size") } enum Limitations { - TIME @map("TIME") + TIME @map("TIME") MEMBERSHIP @map("MEMBERSHIP") @@map("limitations") @@ -43,14 +43,14 @@ enum Day { } model Venue { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - name String + id String @id @default(dbgenerated("uuidv7()")) @db.Uuid + name String address String openingHours OpeningHours[] - cityId String @db.Uuid @map("city_id") - city City @relation(fields: [cityId], references: [id]) + cityId String @map("city_id") @db.Uuid + city City @relation(fields: [cityId], references: [id]) pricesSighted PriceSighting[] @@ -58,22 +58,22 @@ model Venue { } model OpeningHours { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - days Day[] - opening DateTime @db.Timestamptz() - closing DateTime @db.Timestamptz() + id String @id @default(dbgenerated("uuidv7()")) @db.Uuid + days Day[] + opening DateTime @db.Timetz() + closing DateTime @db.Timetz() - venueId String @db.Uuid @map("venue_id") - venue Venue @relation(fields: [venueId], references: [id]) + venueId String @map("venue_id") @db.Uuid + venue Venue @relation(fields: [venueId], references: [id]) @@map("opening_hours") } model City { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - name String - centreLon Float @map("centre_lon") - centreLat Float @map("centre_lat") + id String @id @default(dbgenerated("uuidv7()")) @db.Uuid + name String + centreLon Float @map("centre_lon") + centreLat Float @map("centre_lat") venues Venue[] @@ -81,17 +81,17 @@ model City { } model PriceSighting { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - price Float - size GlassSize - limitation Limitations[] - timeStart DateTime? @db.Timestamptz() @map("time_start") - timeEnd DateTime? @db.Timestamptz() @map("time_end") - sizeMl Float? @map("size_ml") - timeSighted DateTime @db.Timestamptz() @map("time_sighted") - - venueId String @db.Uuid @map("venue_id") - venue Venue @relation(fields: [venueId], references: [id]) + id String @id @default(dbgenerated("uuidv7()")) @db.Uuid + price Float + size GlassSize + limitation Limitations[] + timeStart DateTime? @map("time_start") @db.Timetz() + timeEnd DateTime? @map("time_end") @db.Timetz() + sizeMl Float? @map("size_ml") + timeSighted DateTime @map("time_sighted") @db.Timestamptz() + + venueId String @map("venue_id") @db.Uuid + venue Venue @relation(fields: [venueId], references: [id]) @@map("price_sighting") } diff --git a/scripts/setup-db.sh b/scripts/setup-db.sh index 7805307..6fb7b45 100755 --- a/scripts/setup-db.sh +++ b/scripts/setup-db.sh @@ -21,7 +21,7 @@ fi apt-get update -y -if ! apt-get install -y postgresql-16; then +if ! apt-get install -y postgresql-18; then apt-get install -y postgresql fi