diff --git a/nowcasting_datamodel/connection.py b/nowcasting_datamodel/connection.py index d785eb0..0d599a2 100644 --- a/nowcasting_datamodel/connection.py +++ b/nowcasting_datamodel/connection.py @@ -36,19 +36,7 @@ def create_all(self): self.base.metadata.drop_all(self.engine) self.base.metadata.create_all(self.engine) - - # def make_partitions(self): - # """Make partitions tables (useful for testing)""" - # # get partitions - # self.partitions = get_partitions(2019, 1, 2022, 7) - - # # make partitions - # for partition in self.partitions: - # if not self.engine.dialect.has_table( - # connection=self.engine.connect(), table_name=partition.__table__.name - # ): - # partition.__table__.create(bind=self.engine) - + def drop_all(self): """Drop all partitions and tables""" # drop partitions diff --git a/nowcasting_datamodel/migrations/README.md b/nowcasting_datamodel/migrations/README.md index 6465588..bb7669e 100644 --- a/nowcasting_datamodel/migrations/README.md +++ b/nowcasting_datamodel/migrations/README.md @@ -3,8 +3,8 @@ When we change the datamodel of the PV or Forecast database we will need to run a database migration ## 1. old local database -start local database of database before data model changes. This can be done by setting `DB_URL` and `DB_URL_PV` and running -by running ```python nowcasting_datamodel/migrations/app.py --make-migrations``` +Start local database of database before data model changes. This can be done by setting `DB_URL` and running +```python nowcasting_datamodel/migrations/app.py --make-migrations``` ## 2. run migrations scripts by running ```python nowcasting_datamodel/migrations/app.py --run-migrations``` diff --git a/nowcasting_datamodel/models/forecast.py b/nowcasting_datamodel/models/forecast.py index 3075706..a83cd8d 100644 --- a/nowcasting_datamodel/models/forecast.py +++ b/nowcasting_datamodel/models/forecast.py @@ -153,41 +153,6 @@ class ForecastValueSQL( forecast = relationship("ForecastSQL", back_populates="forecast_values") -# def get_partitions(start_year: int, start_month: int, end_year: int, end_month: int): -# """Make partitions. -# -# This is used in the connections object for testing. -# TODO: Thoroughly distinguish between this and make_parititons -# """ -# partitions = [] -# for year in range(start_year, end_year + 1): -# if year != start_year: -# start_month = 1 -# if year == end_year: -# end_month_loop = end_month -# else: -# end_month_loop = 13 -# -# for month in range(start_month, end_month_loop): -# if month == 12: -# year_end = year + 1 -# month_end = 1 -# else: -# year_end = year -# month_end = month + 1 -# -# if month < 10: -# month = f"0{month}" -# if month_end < 10: -# month_end = f"0{month_end}" -# -# partitions.append( -# ForecastValueSQL.create_partition(f"{year}_{month}", f"{year_end}_{month_end}") -# ) -# -# return partitions - - def create_forecastvalueyearmonth_class(year, month): """Dynamically create a ForecastValueYearMonthClass dynamically for input year and month"""