diff --git a/README.md b/README.md index 36b52d4..1b8c0ee 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/ogn/commands/database.py b/ogn/commands/database.py index 4eba2bc..cba0cdd 100644 --- a/ogn/commands/database.py +++ b/ogn/commands/database.py @@ -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."""