nens / threedi-schema

The schema of 3Di schematization files
MIT License
0 stars 0 forks source link

[0.226.3] NOT NULL constraint failed: _alembic_tmp_dry_weather_flow_map.geom #105

Closed leendertvanwolfswinkel closed 1 month ago

leendertvanwolfswinkel commented 1 month ago
threedi_schema.__version__
'0.226.3'

Sqlite: supermodel_Assen_langzame_afvoer 226.3.sqlitesupermodel_Assen_langzame_afvoer.zip

Error:

Traceback (most recent call last):
  File "C:\Users\leendert.vanwolfswin\Documents\migration_checker\migration_checker.py", line 38, in migrate_spatialite
    schema.validate_schema()
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\threedi_schema\application\schema.py", line 168, in validate_schema
    raise MigrationMissingError(
threedi_schema.application.errors.MigrationMissingError: This tool requires at least schema version 226. Current version: 217.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\sqlalchemy\engine\base.py", line 1967, in _exec_single_context
    self.dialect.do_execute(
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\sqlalchemy\engine\default.py", line 941, in do_execute
    cursor.execute(statement, parameters)
sqlite3.IntegrityError: NOT NULL constraint failed: _alembic_tmp_dry_weather_flow_map.geom

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\leendert.vanwolfswin\Documents\migration_checker\migration_checker.py", line 43, in migrate_spatialite
    schema.upgrade(backup=False, upgrade_spatialite_version=True, convert_to_geopackage=convert_to_geopackage)
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\threedi_schema\application\schema.py", line 146, in upgrade
    _upgrade_database(self.db, revision=revision, unsafe=False)
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\threedi_schema\application\schema.py", line 48, in _upgrade_database
    alembic_command.upgrade(config, revision)
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\alembic\command.py", line 406, in upgrade
    script.run_env()
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\alembic\script\base.py", line 582, in run_env
    util.load_python_file(self.dir, "env.py")
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\alembic\util\pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\alembic\util\pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\threedi_schema\migrations\env.py", line 60, in <module>
    run_migrations_online()
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\threedi_schema\migrations\env.py", line 54, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\alembic\runtime\environment.py", line 946, in run_migrations
    self.get_context().run_migrations(**kw)
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\alembic\runtime\migration.py", line 628, in run_migrations
    step.migration_fn(**kw)
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\threedi_schema\migrations\versions\0223_upgrade_db_inflow.py", line 498, in upgrade
    fix_geometry_columns()
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\threedi_schema\migrations\versions\0223_upgrade_db_inflow.py", line 480, in fix_geometry_columns
    with op.batch_alter_table(table) as batch_op:
  File "C:\ProgramData\anaconda3\envs\gis\Lib\contextlib.py", line 144, in __exit__
    next(self.gen)
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\alembic\operations\base.py", line 398, in batch_alter_table
    impl.flush()
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\alembic\operations\batch.py", line 164, in flush
    batch_impl._create(self.impl)
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\alembic\operations\batch.py", line 451, in _create
    op_impl._exec(
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\alembic\ddl\impl.py", line 210, in _exec
    return conn.execute(construct, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\sqlalchemy\engine\base.py", line 1418, in execute
    return meth(
           ^^^^^
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\sqlalchemy\sql\elements.py", line 515, in _execute_on_connection
    return connection._execute_clauseelement(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\sqlalchemy\engine\base.py", line 1640, in _execute_clauseelement
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\sqlalchemy\engine\base.py", line 1846, in _execute_context
    return self._exec_single_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\sqlalchemy\engine\base.py", line 1986, in _exec_single_context
    self._handle_dbapi_exception(
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\sqlalchemy\engine\base.py", line 2355, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\sqlalchemy\engine\base.py", line 1967, in _exec_single_context
    self.dialect.do_execute(
  File "C:\ProgramData\anaconda3\envs\gis\Lib\site-packages\sqlalchemy\engine\default.py", line 941, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) NOT NULL constraint failed: _alembic_tmp_dry_weather_flow_map.geom
[SQL: INSERT INTO _alembic_tmp_dry_weather_flow_map (id, connection_node_id, dry_weather_flow_id, percentage, tags, code, display_name, geom) SELECT dry_weather_flow_map.id, dry_weather_flow_map.connection_node_id, dry_weather_flow_map.dry_weather_flow_id, dry_weather_flow_map.percentage, dry_weather_flow_map.tags, dry_weather_flow_map.code, dry_weather_flow_map.display_name, dry_weather_flow_map.geom
FROM dry_weather_flow_map]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
margrietpalm commented 1 month ago

@leendertvanwolfswinkel I think this was fixed in 0.226.4

leendertvanwolfswinkel commented 1 month ago

@margrietpalm just tested that and you are right