diff --git a/prisma/migrations/20231107141232_added_table_for_heating_type/migration.sql b/prisma/migrations/20231107141232_added_table_for_heating_type/migration.sql new file mode 100644 index 0000000000000000000000000000000000000000..189aa4e31f0093b0e3a53be266e5157c58543e89 --- /dev/null +++ b/prisma/migrations/20231107141232_added_table_for_heating_type/migration.sql @@ -0,0 +1,18 @@ +-- CreateEnum +CREATE TYPE "Dwelling" AS ENUM ('SEMI', 'DETACHED', 'FLAT', 'TERRACED'); + +-- CreateEnum +CREATE TYPE "Heating_Type" AS ENUM ('RESISTANCE', 'GAS_BOILER', 'OIL_BOILER', 'BIOMASS_BOILER'); + +-- CreateTable +CREATE TABLE "HeatingType" ( + "lsoa11cd" TEXT NOT NULL, + "heatingType" "Heating_Type", + "dwelling" "Dwelling", + "value" DECIMAL, + + CONSTRAINT "HeatingType_pkey" PRIMARY KEY ("lsoa11cd") +); + +-- AddForeignKey +ALTER TABLE "HeatingType" ADD CONSTRAINT "lsoa11cd___fk" FOREIGN KEY ("lsoa11cd") REFERENCES "lsoa"("lsoa11cd") ON DELETE NO ACTION ON UPDATE NO ACTION; diff --git a/prisma/migrations/20231107152025_heating_type_table/migration.sql b/prisma/migrations/20231107152025_heating_type_table/migration.sql new file mode 100644 index 0000000000000000000000000000000000000000..e7f6876abe969fe0a6103368d32ef8300aa83ee4 --- /dev/null +++ b/prisma/migrations/20231107152025_heating_type_table/migration.sql @@ -0,0 +1,34 @@ +/* + Warnings: + + - You are about to drop the column `dwelling` on the `HeatingType` table. All the data in the column will be lost. + - You are about to drop the column `heatingType` on the `HeatingType` table. All the data in the column will be lost. + - You are about to drop the column `value` on the `HeatingType` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "HeatingType" DROP COLUMN "dwelling", +DROP COLUMN "heatingType", +DROP COLUMN "value", +ADD COLUMN "detached_Biomass" DECIMAL, +ADD COLUMN "detached_Gas" DECIMAL, +ADD COLUMN "detached_Oil" DECIMAL, +ADD COLUMN "detached_Resistance" DECIMAL, +ADD COLUMN "flats_Biomass" DECIMAL, +ADD COLUMN "flats_Gas" DECIMAL, +ADD COLUMN "flats_Oil" DECIMAL, +ADD COLUMN "flats_Resistance" DECIMAL, +ADD COLUMN "semi_detached_Biomass" DECIMAL, +ADD COLUMN "semi_detached_Gas" DECIMAL, +ADD COLUMN "semi_detached_Oil" DECIMAL, +ADD COLUMN "semi_detached_Resistance" DECIMAL, +ADD COLUMN "terraced_Biomass" DECIMAL, +ADD COLUMN "terraced_Gas" DECIMAL, +ADD COLUMN "terraced_Oil" DECIMAL, +ADD COLUMN "terraced_Resistance" DECIMAL; + +-- DropEnum +DROP TYPE "Dwelling"; + +-- DropEnum +DROP TYPE "Heating_Type"; diff --git a/prisma/migrations/20231115142640_lsoatranslatetable/migration.sql b/prisma/migrations/20231115142640_lsoatranslatetable/migration.sql new file mode 100644 index 0000000000000000000000000000000000000000..1892b3db9c573dedc63a9545d011852948889726 --- /dev/null +++ b/prisma/migrations/20231115142640_lsoatranslatetable/migration.sql @@ -0,0 +1,10 @@ +-- CreateTable +CREATE TABLE "lsoaCoordinates" ( + "geo_code" TEXT NOT NULL, + "geo_label" TEXT NOT NULL, + "geo_label_w" TEXT NOT NULL, + "x_coordinate" DECIMAL(65,30) NOT NULL, + "y_coordinate" DECIMAL(65,30) NOT NULL, + + CONSTRAINT "lsoaCoordinates_pkey" PRIMARY KEY ("geo_code") +); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 01224332beb92c7b296631c9e8088fbfe886b712..57b5d399523eb6cc882700c6ca2521b303f8f218 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,12 +1,10 @@ generator client { - provider = "prisma-client-js" - binaryTargets = ["native", "rhel-openssl-1.0.x"] + provider = "prisma-client-js" } datasource db { - provider = "postgresql" - url = env("POSTGRES_PRISMA_URL") - directUrl = env("POSTGRES_URL_NON_POOLING") + provider = "postgresql" + url = env("POSTGRES_URL") } model HeatDemand { @@ -16,17 +14,47 @@ model HeatDemand { lsoa lsoa @relation(fields: [lsoa11cd], references: [lsoa11cd], onDelete: NoAction, onUpdate: NoAction, map: "lsoa11cd___fk") } +model HeatingType { + lsoa11cd String @id + detached_Biomass Decimal? @db.Decimal + detached_Gas Decimal? @db.Decimal + detached_Oil Decimal? @db.Decimal + detached_Resistance Decimal? @db.Decimal + flats_Biomass Decimal? @db.Decimal + flats_Gas Decimal? @db.Decimal + flats_Oil Decimal? @db.Decimal + flats_Resistance Decimal? @db.Decimal + semi_detached_Biomass Decimal? @db.Decimal + semi_detached_Gas Decimal? @db.Decimal + semi_detached_Oil Decimal? @db.Decimal + semi_detached_Resistance Decimal? @db.Decimal + terraced_Biomass Decimal? @db.Decimal + terraced_Gas Decimal? @db.Decimal + terraced_Oil Decimal? @db.Decimal + terraced_Resistance Decimal? @db.Decimal + lsoa lsoa @relation(fields: [lsoa11cd], references: [lsoa11cd], onDelete: NoAction, onUpdate: NoAction, map: "lsoa11cd___fk") +} + +model admin { + username String @id + password String +} + +model lsoaCoordinates { + geo_code String @id + geo_label String + geo_label_w String + x_coordinate Decimal @db.Decimal + y_coordinate Decimal @db.Decimal +} + model lsoa { - lsoa11cd String @id + lsoa11cd String @id lsoa11nm String? lad17cd String? lad17nm String? HeatDemands HeatDemand? + HeatingType HeatingType? @@index([lsoa11cd, lad17cd], map: "lsoa__index") } - -model admin { - username String @id @default(cuid()) - password String -}