Skip to content

Commit

Permalink
Merge branch 'feature-optimize-database-inserts' into jona
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaraphael committed Nov 18, 2023
2 parents defa2fd + 5d07870 commit 15aabef
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions alembic/versions/c7c033c1cdb5_populate_aoi_chunks_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@


def upgrade() -> None:
"""
Upgrade the database schema.
This function subdivides the geometries in the 'aoi' table into smaller chunks
if they have more than 255 points, and inserts these chunks into the 'aoi_chunks' table.
This is done to manage large geometries more efficiently.
"""
bind = op.get_bind()
session = orm.Session(bind=bind)
with session.begin():
Expand All @@ -41,6 +48,12 @@ def upgrade() -> None:


def downgrade() -> None:
"""
Downgrade the database schema.
This function clears the 'aoi_chunks' table by truncating it, effectively
undoing the changes made by the upgrade function.
"""
bind = op.get_bind()
session = orm.Session(bind=bind)
with session.begin():
Expand Down

0 comments on commit 15aabef

Please sign in to comment.