pavelfilippi / weather-monitor

MIT License
1 stars 0 forks source link

Make weather_real_time hypertable again! #10

Closed pavelfilippi closed 1 year ago

pavelfilippi commented 1 year ago

I have removed manual migration in 7e58210df0df1cf5b5ffbcde005709b4f500a002 and forgot to make (via alembic?) weather_real_time hypertable again!

Possible solution:

from sqlalchemy import Column, Integer, DateTime, event, DDL, orm

Base = orm.declarative_base()

class ExampleModel(Base):
    __tablename__ = 'example_model'

    id = Column(Integer, primary_key=True)
    time = Column(DateTime)

event.listen(
    ExampleModel.__table__,
    'after_create',
    DDL(f"SELECT create_hypertable('{ExampleModel.__tablename__}', 'time');")
)

via https://stackoverflow.com/questions/50862609/creating-hypertables-through-sql-alchemy

pavelfilippi commented 1 year ago

Fixed in https://github.com/pavelfilippi/weather-monitor/pull/16