diff --git a/database/.gitignore b/database/.gitignore new file mode 100644 index 00000000..dd400a6a --- /dev/null +++ b/database/.gitignore @@ -0,0 +1 @@ +*.db* \ No newline at end of file diff --git a/database/migrations/20240903193230_normalized_billing_record/migration.sql b/database/migrations/20240903193230_normalized_billing_record/migration.sql new file mode 100644 index 00000000..d557a425 --- /dev/null +++ b/database/migrations/20240903193230_normalized_billing_record/migration.sql @@ -0,0 +1,14 @@ +-- CreateTable +CREATE TABLE "NormalizedBillingPeriodRecord" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "period_start_date" DATETIME NOT NULL, + "period_end_date" DATETIME NOT NULL, + "usage" REAL NOT NULL, + "analysis_type_override" TEXT NOT NULL, + "inclusion_override" BOOLEAN NOT NULL, + "model_config" TEXT NOT NULL, + "analysis_type" TEXT NOT NULL, + "default_inclusion_by_calculation" BOOLEAN NOT NULL, + "eliminated_as_outlier" BOOLEAN NOT NULL, + "whole_home_heat_loss_rate" REAL NOT NULL +); diff --git a/database/migrations/migration_lock.toml b/database/migrations/migration_lock.toml new file mode 100644 index 00000000..e5e5c470 --- /dev/null +++ b/database/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (i.e. Git) +provider = "sqlite" \ No newline at end of file diff --git a/database/package-lock.json b/database/package-lock.json new file mode 100644 index 00000000..b98038ff --- /dev/null +++ b/database/package-lock.json @@ -0,0 +1,118 @@ +{ + "name": "database", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "@prisma/client": "^5.19.1" + }, + "devDependencies": { + "prisma": "^5.19.1" + } + }, + "node_modules/@prisma/client": { + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.19.1.tgz", + "integrity": "sha512-x30GFguInsgt+4z5I4WbkZP2CGpotJMUXy+Gl/aaUjHn2o1DnLYNTA+q9XdYmAQZM8fIIkvUiA2NpgosM3fneg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "engines": { + "node": ">=16.13" + }, + "peerDependencies": { + "prisma": "*" + }, + "peerDependenciesMeta": { + "prisma": { + "optional": true + } + } + }, + "node_modules/@prisma/debug": { + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.19.1.tgz", + "integrity": "sha512-lAG6A6QnG2AskAukIEucYJZxxcSqKsMK74ZFVfCTOM/7UiyJQi48v6TQ47d6qKG3LbMslqOvnTX25dj/qvclGg==", + "devOptional": true, + "license": "Apache-2.0" + }, + "node_modules/@prisma/engines": { + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.19.1.tgz", + "integrity": "sha512-kR/PoxZDrfUmbbXqqb8SlBBgCjvGaJYMCOe189PEYzq9rKqitQ2fvT/VJ8PDSe8tTNxhc2KzsCfCAL+Iwm/7Cg==", + "devOptional": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "5.19.1", + "@prisma/engines-version": "5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3", + "@prisma/fetch-engine": "5.19.1", + "@prisma/get-platform": "5.19.1" + } + }, + "node_modules/@prisma/engines-version": { + "version": "5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3.tgz", + "integrity": "sha512-xR6rt+z5LnNqTP5BBc+8+ySgf4WNMimOKXRn6xfNRDSpHvbOEmd7+qAOmzCrddEc4Cp8nFC0txU14dstjH7FXA==", + "devOptional": true, + "license": "Apache-2.0" + }, + "node_modules/@prisma/fetch-engine": { + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.19.1.tgz", + "integrity": "sha512-pCq74rtlOVJfn4pLmdJj+eI4P7w2dugOnnTXpRilP/6n5b2aZiA4ulJlE0ddCbTPkfHmOL9BfaRgA8o+1rfdHw==", + "devOptional": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "5.19.1", + "@prisma/engines-version": "5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3", + "@prisma/get-platform": "5.19.1" + } + }, + "node_modules/@prisma/get-platform": { + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.19.1.tgz", + "integrity": "sha512-sCeoJ+7yt0UjnR+AXZL7vXlg5eNxaFOwC23h0KvW1YIXUoa7+W2ZcAUhoEQBmJTW4GrFqCuZ8YSP0mkDa4k3Zg==", + "devOptional": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "5.19.1" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/prisma": { + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.19.1.tgz", + "integrity": "sha512-c5K9MiDaa+VAAyh1OiYk76PXOme9s3E992D7kvvIOhCrNsBQfy2mP2QAQtX0WNj140IgG++12kwZpYB9iIydNQ==", + "devOptional": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/engines": "5.19.1" + }, + "bin": { + "prisma": "build/index.js" + }, + "engines": { + "node": ">=16.13" + }, + "optionalDependencies": { + "fsevents": "2.3.3" + } + } + } +} diff --git a/database/package.json b/database/package.json new file mode 100644 index 00000000..f01d7f4f --- /dev/null +++ b/database/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "prisma": "^5.19.1" + }, + "dependencies": { + "@prisma/client": "^5.19.1" + } +} diff --git a/database/schema.prisma b/database/schema.prisma new file mode 100644 index 00000000..a6c61d9e --- /dev/null +++ b/database/schema.prisma @@ -0,0 +1,29 @@ +generator client { + provider = "prisma-client-js" +} + + +datasource db { + provider = "sqlite" + url = "file:./heat.db" +} + + +model NormalizedBillingPeriodRecord { + id Int @id @default(autoincrement()) + + // NormalizedBillingPeriodRecordBase (inherited) + // prisma does not support direct inheritance; therefore we directly coded these fields + period_start_date DateTime + period_end_date DateTime + usage Float + analysis_type_override String // AnalysisType in NormalizedBillingPeriodRecord of pydantic_models.py + inclusion_override Boolean + + // NormalizedBillingPeriodRecord + model_config String // ConfigDict in NormalizedBillingPeriodRecord of pydantic_models.py + analysis_type String // AnalysisType in NormalizedBillingPeriodRecord of pydantic_models.py + default_inclusion_by_calculation Boolean + eliminated_as_outlier Boolean + whole_home_heat_loss_rate Float +} \ No newline at end of file