-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new database schema to add battery temperature logging
- Loading branch information
1 parent
8209552
commit 9080c2c
Showing
5 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from sqlalchemy import Column, Integer, Float, String, ForeignKey, UniqueConstraint | ||
from sqlalchemy.orm import relationship | ||
|
||
from vwsfriend.model.base import Base | ||
from vwsfriend.model.datetime_decorator import DatetimeDecorator | ||
|
||
|
||
class BatteryTemperature(Base): | ||
__tablename__ = 'battery_temperature' | ||
__table_args__ = ( | ||
UniqueConstraint('vehicle_vin', 'carCapturedTimestamp'), | ||
) | ||
id = Column(Integer, primary_key=True) | ||
vehicle_vin = Column(String, ForeignKey('vehicles.vin')) | ||
carCapturedTimestamp = Column(DatetimeDecorator(timezone=True), nullable=False) | ||
vehicle = relationship("Vehicle") | ||
temperatureHvBatteryMin_K = Column(Float) | ||
temperatureHvBatteryMax_K = Column(Float) | ||
|
||
def __init__(self, vehicle, carCapturedTimestamp, temperatureHvBatteryMin_K, temperatureHvBatteryMax_K): | ||
self.vehicle = vehicle | ||
self.carCapturedTimestamp = carCapturedTimestamp | ||
self.temperatureHvBatteryMin_K = temperatureHvBatteryMin_K | ||
self.temperatureHvBatteryMax_K = temperatureHvBatteryMax_K |
Binary file not shown.
34 changes: 34 additions & 0 deletions
34
...vwsfriend/model/vwsfriend-schema/versions/6c4cdc5006ba_added_battery_temperature_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Added battery temperature table | ||
Revision ID: 6c4cdc5006ba | ||
Revises: f3a66cd08ebe | ||
Create Date: 2023-10-27 12:12:09.450271 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from vwsfriend.model.datetime_decorator import DatetimeDecorator | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '6c4cdc5006ba' | ||
down_revision = 'f3a66cd08ebe' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table('battery_temperature', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('vehicle_vin', sa.String(), nullable=True), | ||
sa.Column('carCapturedTimestamp', DatetimeDecorator(timezone=True), nullable=False), | ||
sa.Column('temperatureHvBatteryMin_K', sa.Float(), nullable=True), | ||
sa.Column('temperatureHvBatteryMax_K', sa.Float(), nullable=True), | ||
sa.ForeignKeyConstraint(['vehicle_vin'], ['vehicles.vin'], ), | ||
sa.PrimaryKeyConstraint('id'), | ||
sa.UniqueConstraint('vehicle_vin', 'carCapturedTimestamp') | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('battery_temperature') |