ckanext-spatial icon indicating copy to clipboard operation
ckanext-spatial copied to clipboard

SQLAlchemy requires extend_existing

Open florianm opened this issue 10 years ago • 0 comments

Datacats CKAN "latest" (2.5a) with our ckanext-spatial fork which is exactly up to date with upstream/master.

With SQLAlchemy==0.9.6 installed, booting up CKAN trips when spatial inits their tables. SQLAlchemy defaults to creating/updating tables with Table(..., column defs, extend_existing=False), we'll need True:

  File "/project/ckanext-spatial/ckanext/spatial/plugin.py", line 78, in configure
    setup_model()
  File "/project/ckanext-spatial/ckanext/spatial/model/package_extent.py", line 22, in setup
    define_spatial_tables(srid)
  File "/project/ckanext-spatial/ckanext/spatial/model/package_extent.py", line 69, in define_spatial_tables
    package_extent_table = setup_spatial_table(PackageExtent, db_srid)
  File "/project/ckanext-spatial/ckanext/spatial/geoalchemy_common.py", line 74, in setup_spatial_table
    management=management)),
  File "/usr/lib/ckan/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 339, in __new__
    "existing Table object." % key)
sqlalchemy.exc.InvalidRequestError: Table 'package_extent' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
Starting subprocess with file monitor

This sounds similar to ckan/ckanext-pages#27. I'll attempt a fix now, if you don't hear a PR from me, send coffee and help.

florianm avatar Oct 09 '15 06:10 florianm