Separate TimescaleDB features initialization.

pull/68/head
Konstantin Gründger 2019-01-04 15:06:11 +01:00
rodzic 50f112e664
commit d6fdb6aa52
2 zmienionych plików z 13 dodań i 5 usunięć

Wyświetl plik

@ -95,7 +95,7 @@ available commands:
create_gaps2d Create 'gaps' from logfile tables.
file_export Export separate logfile tables to csv files. They can be used for fast bulk import with sql COPY command.
file_import Import APRS logfiles into separate logfile tables.
transfer_aircraft_beaconsTransfer beacons from separate logfile tables to beacon table.
transfer Transfer beacons from separate logfile tables to beacon table.
update Update beacons (add foreign keys, compute distance, bearing, ags, etc.) in separate logfile tables.
[db]
@ -105,6 +105,7 @@ available commands:
import_file Import registered devices from a local file.
import_flarmnet Import registered devices from a local file.
init Initialize the database.
init_timescaledb Initialize TimescaleDB features.
update_country_codes Update country codes of all receivers.
upgrade Upgrade database to the latest version.

Wyświetl plik

@ -37,17 +37,24 @@ def init():
session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
session.execute('CREATE EXTENSION IF NOT EXISTS btree_gist;')
#session.execute('CREATE EXTENSION IF NOT EXISTS timescaledb;')
session.commit()
Base.metadata.create_all(engine)
#session.execute("SELECT create_hypertable('aircraft_beacons', 'timestamp', chunk_target_size => '2GB', if_not_exists => TRUE);")
#session.execute("SELECT create_hypertable('receiver_beacons', 'timestamp', chunk_target_size => '2GB', if_not_exists => TRUE);")
#session.commit()
#alembic_cfg = Config(ALEMBIC_CONFIG_FILE)
#command.stamp(alembic_cfg, "head")
print("Done.")
@manager.command
def init_timescaledb():
"""Initialize TimescaleDB features."""
session.execute('CREATE EXTENSION IF NOT EXISTS timescaledb;')
session.execute("SELECT create_hypertable('aircraft_beacons', 'timestamp', chunk_target_size => '2GB', if_not_exists => TRUE);")
session.execute("SELECT create_hypertable('receiver_beacons', 'timestamp', chunk_target_size => '2GB', if_not_exists => TRUE);")
session.commit()
@manager.command
def upgrade():
"""Upgrade database to the latest version."""