SpatiaLite includes a function for standing up geospatial functionality in an existing SQLite database, namely, InitSpatialMetaData()
.
I'm seeking a similar method for tearing down geospatial metadata tables, and associated triggers and views, specifically as a way of implementing the downgrade()
function in an alembic migration context for my database. Currently, the only way seems to be to specifically call out each piece of metadata by hand and remove them individually. Is this the best method or is there a better way to remove these metadata tables, etc?
Relevant Version Information:
OS: Debian Buster
SQLite: 3.27.2
SpatiaLite: 4.3
Code to Generate Spatial Tables (from GeoAlchemy2 SpatiaLite Tutorial):
from sqlalchemy import create_engine
from sqlalchemy.event import listen
from sqlalchemy.sql import select, func
def load_spatialite(dbapi_conn, connection_record):
dbapi_conn.enable_load_extension(True)
dbapi_conn.load_extension('/usr/lib/x86_64-linux-gnu/mod_spatialite.so')
engine = create_engine('sqlite:///gis.db', echo=True)
listen(engine, 'connect', load_spatialite)
conn.execute(select([func.InitSpatialMetaData()]))
tldr; Does SpatiaLite have an analog for the opposite of the function InitSpatialMetaData()
?