The database migration in PR #256 fails in the staging environment because the staging database has entries in the job table which violate the NOT NULL constraint on the new column created by this migration.
Traceback (most recent call last):
File "/app/ptero_workflow/api/application.py", line 38, in before_request
flask.g.backend = factory.create_backend()
File "/app/.heroku/src/ptero-common/ptero_common/factories/bigfactory.py", line 23, in create_backend
self._initialize()
File "/app/.heroku/src/ptero-common/ptero_common/factories/bigfactory.py", line 32, in _initialize
self._initialize_database()
File "/app/.heroku/src/ptero-common/ptero_common/factories/dbfactorymixin.py", line 23, in _initialize_database
alembic_upgrade(self.alembic_config, self.engine)
File "/app/.heroku/src/ptero-common/ptero_common/factories/dbfactorymixin.py", line 34, in alembic_upgrade
command.upgrade(alembic_config, "head")
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/command.py", line 174, in upgrade
script.run_env()
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/script/base.py", line 397, in run_env
util.load_python_file(self.dir, 'env.py')
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 81, in load_python_file
module = load_module_py(module_id, path)
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/util/compat.py", line 79, in load_module_py
mod = imp.load_source(module_id, path, fp)
File "/app/ptero_workflow/alembic/env.py", line 67, in <module>
run_migrations_online()
File "/app/ptero_workflow/alembic/env.py", line 62, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/runtime/environment.py", line 797, in run_migrations
self.get_context().run_migrations(**kw)
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/runtime/migration.py", line 312, in run_migrations
step.migration_fn(**kw)
File "/app/ptero_workflow/alembic/versions/89b1fb28bb6c_store_service_data.py", line 20, in upgrade
op.add_column('job', sa.Column('service_data_to_save', postgresql.JSON(), nullable=False))
File "<string>", line 8, in add_column
File "<string>", line 3, in add_column
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/operations/ops.py", line 1535, in add_column
return operations.invoke(op)
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/operations/base.py", line 318, in invoke
return fn(self, operation)
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/operations/toimpl.py", line 123, in add_column
schema=schema
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/ddl/impl.py", line 172, in add_column
self._exec(base.AddColumn(table_name, column, schema=schema))
File "/app/.heroku/python/lib/python2.7/site-packages/alembic/ddl/impl.py", line 118, in _exec
return conn.execute(construct, *multiparams, **params)
File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
return meth(self, multiparams, params)
File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 968, in _execute_ddl
compiled
File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
context)
File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
exc_info
File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb)
File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
context)
File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
cursor.execute(statement, parameters)
IntegrityError: (psycopg2.IntegrityError) column "service_data_to_save" contains null values
[SQL: 'ALTER TABLE job ADD COLUMN service_data_to_save JSON NOT NULL']
Coverage increased (+0.02%) to 88.577% when pulling 4c08b6427522fc5e15c5b997933818817975454a on revert-256-service_data_to_save_feature into f80079c1bf70f059eea7b7100ab6f259fccfd171 on master.
Reverts genome/ptero-workflow#256
The database migration in PR #256 fails in the staging environment because the staging database has entries in the
job
table which violate the NOT NULL constraint on the new column created by this migration.