Skip to content

Commit

Permalink
feat: Setup Prisma migrations (#146)
Browse files Browse the repository at this point in the history
* chore: Bump prisma

* feat: Setup initial migration

* feat: GHA workflow
  • Loading branch information
DafyddLlyr authored Dec 6, 2024
1 parent cb32f66 commit e91c717
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 29 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/deploy-migrations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy migrations
on:
push:
paths:
# Only run this workflow when migrations are updated
- prisma/migrations/**
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
- name: Install dependencies
run: npm install
- name: Apply all pending migrations to the database
run: npx prisma migrate deploy
env:
DATABASE_URL: ${{ secrets.PRODUCTION_DATABASE_URL }}
56 changes: 28 additions & 28 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"lint-staged": "^15.2.10",
"postcss": "^8",
"prettier": "3.3.3",
"prisma": "^5.21.1",
"prisma": "^5.22.0",
"tailwindcss": "^3.4.14",
"ts-jest": "^29.2.5",
"tsuml2": "^0.17.0",
Expand Down
98 changes: 98 additions & 0 deletions prisma/migrations/0_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
-- CreateTable
CREATE TABLE "buildprices" (
"id" SERIAL NOT NULL,
"housetypedescription" VARCHAR(250),
"housetype" VARCHAR(1),
"pricerange" VARCHAR(50),
"pricemid" DOUBLE PRECISION,

CONSTRAINT "buildprices_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "gdhi" (
"id" SERIAL NOT NULL,
"itllevel" VARCHAR(250),
"itl3" VARCHAR(250),
"region" VARCHAR(250),
"gdhi_2020" DOUBLE PRECISION,

CONSTRAINT "gdhi_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "hpi" (
"id" SERIAL NOT NULL,
"region" VARCHAR(250),
"itl3" VARCHAR(250),
"ladcode" VARCHAR(250),
"hpi_2000" DOUBLE PRECISION,

CONSTRAINT "hpi_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "itl_lookup" (
"postcode" TEXT,
"district" TEXT,
"areacode" TEXT,
"itl3" TEXT,
"id" SERIAL NOT NULL,

CONSTRAINT "itl_lookup_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "pricespaid" (
"id" SERIAL NOT NULL,
"transactionidentifier" VARCHAR(250),
"price" DOUBLE PRECISION,
"postcode" VARCHAR(250),
"propertytype" VARCHAR(250),
"newbuild" VARCHAR(250),

CONSTRAINT "pricespaid_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "rent" (
"id" SERIAL NOT NULL,
"itl3" VARCHAR(250),
"ladcode" VARCHAR(250),
"region" VARCHAR(250),
"monthlymeanrent" DOUBLE PRECISION,

CONSTRAINT "rent_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "soc_rent_adjustments" (
"year" VARCHAR(10),
"inflation" DOUBLE PRECISION,
"additional" DOUBLE PRECISION,
"total" DOUBLE PRECISION,
"id" SERIAL NOT NULL,

CONSTRAINT "soc_rent_adjustments_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "socialrent" (
"id" SERIAL NOT NULL,
"county" VARCHAR(250),
"itl3" VARCHAR(250),
"earningsperweek" DOUBLE PRECISION,

CONSTRAINT "socialrent_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "gas_bills" (
"id" INTEGER NOT NULL,
"Region" VARCHAR NOT NULL,
"itl" VARCHAR NOT NULL,
"bill" DOUBLE PRECISION NOT NULL,

CONSTRAINT "gas_bills_pkey" PRIMARY KEY ("id")
);

3 changes: 3 additions & 0 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"

0 comments on commit e91c717

Please sign in to comment.