add_is_default_to_subnetpool migration[1] is not working on PostgreSQL with a non empty because it adds a new column non-nullable with no default value and PostgreSQL cannot deduce it.
user@host:/opt/stack/neutron$ neutron-db-manage --config-file ~/a upgrade head
No handlers could be found for logger "oslo_config.cfg"
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
Running upgrade for neutron ...
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade 34af2b5c5a59 -> 59cb5b6cf4d, Add availability zone
INFO [alembic.runtime.migration] Running upgrade 59cb5b6cf4d -> 13cfb89f881a, add is_default to subnetpool
Traceback (most recent call last):
File "/opt/stack/neutron/.tox/py27/bin/neutron-db-manage", line 10, in <module>
sys.exit(main())
File "/opt/stack/neutron/neutron/db/migration/cli.py", line 749, in main
return_val |= bool(CONF.command.func(config, CONF.command.name))
File "/opt/stack/neutron/neutron/db/migration/cli.py", line 225, in do_upgrade
desc=branch, sql=CONF.command.sql)
File "/opt/stack/neutron/neutron/db/migration/cli.py", line 127, in do_alembic_command
getattr(alembic_command, cmd)(config, *args, **kwargs)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/command.py", line 174, in upgrade
script.run_env()
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/script/base.py", line 397, in run_env
util.load_python_file(self.dir, 'env.py')
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 81, in load_python_file
module = load_module_py(module_id, path)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/util/compat.py", line 79, in load_module_py
mod = imp.load_source(module_id, path, fp)
File "/opt/stack/neutron/neutron/db/migration/alembic_migrations/env.py", line 126, in <module>
run_migrations_online()
File "/opt/stack/neutron/neutron/db/migration/alembic_migrations/env.py", line 120, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/runtime/environment.py", line 797, in run_migrations
self.get_context().run_migrations(**kw)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/runtime/migration.py", line 312, in run_migrations
step.migration_fn(**kw)
File "/opt/stack/neutron/neutron/db/migration/alembic_migrations/versions/mitaka/expand/13cfb89f881a_add_is_default_to_subnetpool.py", line 36, in upgrade
nullable=False))
File "<string>", line 8, in add_column
File "<string>", line 3, in add_column
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/operations/ops.py", line 1535, in add_column
return operations.invoke(op)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/operations/base.py", line 318, in invoke
return fn(self, operation)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/operations/toimpl.py", line 123, in add_column
schema=schema
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/ddl/impl.py", line 172, in add_column
self._exec(base.AddColumn(table_name, column, schema=schema))
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/alembic/ddl/impl.py", line 118, in _exec
return conn.execute(construct, *multiparams, **params)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
return meth(self, multiparams, params)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 968, in _execute_ddl
compiled
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
context)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1337, in _handle_dbapi_exception
util.raise_from_cause(newraise, exc_info)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
context)
File "/opt/stack/neutron/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
cursor.execute(statement, parameters)
oslo_db.exception.DBError: (psycopg2.IntegrityError) column "is_default" contains null values
[SQL: 'ALTER TABLE subnetpools ADD COLUMN is_default BOOLEAN NOT NULL']
add_is_ default_ to_subnetpool migration[1] is not working on PostgreSQL with a non empty because it adds a new column non-nullable with no default value and PostgreSQL cannot deduce it.
It could affect also MySQL.
[1] neutron/ db/migration/ alembic_ migrations/ versions/ mitaka/ expand/ 13cfb89f881a_ add_is_ default_ to_subnetpool. py
[2] stacktrace
user@host: /opt/stack/ neutron$ neutron-db-manage --config-file ~/a upgrade head runtime. migration] Context impl PostgresqlImpl. runtime. migration] Will assume transactional DDL. runtime. migration] Context impl PostgresqlImpl. runtime. migration] Will assume transactional DDL. runtime. migration] Running upgrade 34af2b5c5a59 -> 59cb5b6cf4d, Add availability zone runtime. migration] Running upgrade 59cb5b6cf4d -> 13cfb89f881a, add is_default to subnetpool neutron/ .tox/py27/ bin/neutron- db-manage" , line 10, in <module> exit(main( )) neutron/ neutron/ db/migration/ cli.py" , line 749, in main command. func(config, CONF.command.name)) neutron/ neutron/ db/migration/ cli.py" , line 225, in do_upgrade command. sql) neutron/ neutron/ db/migration/ cli.py" , line 127, in do_alembic_command alembic_ command, cmd)(config, *args, **kwargs) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ command. py", line 174, in upgrade run_env( ) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ script/ base.py" , line 397, in run_env load_python_ file(self. dir, 'env.py') neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ util/pyfiles. py", line 81, in load_python_file py(module_ id, path) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ util/compat. py", line 79, in load_module_py source( module_ id, path, fp) neutron/ neutron/ db/migration/ alembic_ migrations/ env.py" , line 126, in <module> migrations_ online( ) neutron/ neutron/ db/migration/ alembic_ migrations/ env.py" , line 120, in run_migrations_ online run_migrations( ) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ runtime/ environment. py", line 797, in run_migrations get_context( ).run_migration s(**kw) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ runtime/ migration. py", line 312, in run_migrations migration_ fn(**kw) neutron/ neutron/ db/migration/ alembic_ migrations/ versions/ mitaka/ expand/ 13cfb89f881a_ add_is_ default_ to_subnetpool. py", line 36, in upgrade False)) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ operations/ ops.py" , line 1535, in add_column invoke( op) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ operations/ base.py" , line 318, in invoke neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ operations/ toimpl. py", line 123, in add_column neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ ddl/impl. py", line 172, in add_column _exec(base. AddColumn( table_name, column, schema=schema)) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ alembic/ ddl/impl. py", line 118, in _exec construct, *multiparams, **params) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ sqlalchemy/ engine/ base.py" , line 914, in execute neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ sqlalchemy/ sql/ddl. py", line 68, in _execute_ on_connection _execute_ ddl(self, multiparams, params) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ sqlalchemy/ engine/ base.py" , line 968, in _execute_ddl neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ sqlalchemy/ engine/ base.py" , line 1146, in _execute_context neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ sqlalchemy/ engine/ base.py" , line 1337, in _handle_ dbapi_exception raise_from_ cause(newraise, exc_info) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ sqlalchemy/ util/compat. py", line 200, in raise_from_cause type(exception) , exception, tb=exc_tb, cause=cause) neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ sqlalchemy/ engine/ base.py" , line 1139, in _execute_context neutron/ .tox/py27/ local/lib/ python2. 7/site- packages/ sqlalchemy/ engine/ default. py", line 450, in do_execute execute( statement, parameters) exception. DBError: (psycopg2. IntegrityError) column "is_default" contains null values
No handlers could be found for logger "oslo_config.cfg"
INFO [alembic.
INFO [alembic.
Running upgrade for neutron ...
INFO [alembic.
INFO [alembic.
INFO [alembic.
INFO [alembic.
Traceback (most recent call last):
File "/opt/stack/
sys.
File "/opt/stack/
return_val |= bool(CONF.
File "/opt/stack/
desc=branch, sql=CONF.
File "/opt/stack/
getattr(
File "/opt/stack/
script.
File "/opt/stack/
util.
File "/opt/stack/
module = load_module_
File "/opt/stack/
mod = imp.load_
File "/opt/stack/
run_
File "/opt/stack/
context.
File "<string>", line 8, in run_migrations
File "/opt/stack/
self.
File "/opt/stack/
step.
File "/opt/stack/
nullable=
File "<string>", line 8, in add_column
File "<string>", line 3, in add_column
File "/opt/stack/
return operations.
File "/opt/stack/
return fn(self, operation)
File "/opt/stack/
schema=schema
File "/opt/stack/
self.
File "/opt/stack/
return conn.execute(
File "/opt/stack/
return meth(self, multiparams, params)
File "/opt/stack/
return connection.
File "/opt/stack/
compiled
File "/opt/stack/
context)
File "/opt/stack/
util.
File "/opt/stack/
reraise(
File "/opt/stack/
context)
File "/opt/stack/
cursor.
oslo_db.
[SQL: 'ALTER TABLE subnetpools ADD COLUMN is_default BOOLEAN NOT NULL']