Skip to content

Commit

Permalink
Merge pull request #7 from AdamFinkle/persistent-data-124
Browse files Browse the repository at this point in the history
Set up a database of NormalizedBillingPeriodRecords.
  • Loading branch information
AdamFinkle authored Sep 3, 2024
2 parents 2822f5f + d26737d commit 10bf99a
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 0 deletions.
1 change: 1 addition & 0 deletions database/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.db*
Original file line number Diff line number Diff line change
@@ -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
);
3 changes: 3 additions & 0 deletions database/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 = "sqlite"
118 changes: 118 additions & 0 deletions database/package-lock.json

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

8 changes: 8 additions & 0 deletions database/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"devDependencies": {
"prisma": "^5.19.1"
},
"dependencies": {
"@prisma/client": "^5.19.1"
}
}
29 changes: 29 additions & 0 deletions database/schema.prisma
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 10bf99a

Please sign in to comment.