Repository: fedora-infra/bodhi

Issue:
Database migration needed for the new releases.pending_signing_tag column
The develop branch current fails to operate properly, as we need to add a migration to create the new releases.pending_signing_tag column:

```
2016-09-16 17:52:07,057 ERROR [waitress][Dummy-2] Exception when serving /
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/waitress/channel.py", line 337, in service
    task.service()
  File "/usr/lib/python2.7/site-packages/waitress/task.py", line 173, in service
    self.execute()
  File "/usr/lib/python2.7/site-packages/waitress/task.py", line 392, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/usr/lib/python2.7/site-packages/pyramid-1.7.3-py2.7.egg/pyramid/router.py", line 236, in __call__
    response = self.invoke_subrequest(request, use_tweens=True)
  File "/usr/lib/python2.7/site-packages/pyramid-1.7.3-py2.7.egg/pyramid/router.py", line 211, in invoke_subrequest
    response = handle_request(request)
  File "/usr/lib/python2.7/site-packages/pyramid_debugtoolbar-3.0.4-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 187, in toolbar_tween
    return handler(request)
  File "/usr/lib/python2.7/site-packages/pyramid-1.7.3-py2.7.egg/pyramid/tweens.py", line 51, in excview_tween
    request_iface=request_iface.combined
  File "/usr/lib/python2.7/site-packages/pyramid-1.7.3-py2.7.egg/pyramid/view.py", line 547, in _call_view
    response = view_callable(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid-1.7.3-py2.7.egg/pyramid/viewderivers.py", line 330, in _authdebug_view
    return view(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid-1.7.3-py2.7.egg/pyramid/viewderivers.py", line 413, in viewresult_to_response
    result = view(context, request)
  File "/vagrant/bodhi/server/views/generic.py", line 255, in exception_view
    return bodhi.server.services.errors.html_handler(errors)
  File "/vagrant/bodhi/server/services/errors.py", line 73, in __init__
    summary=status2summary(errors.status),
  File "/usr/lib/python2.7/site-packages/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 803, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 835, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 860, in _exec_template
    callable_(context, *args, **kwargs)
  File "master_html", line 114, in render_body
  File "/usr/lib/python2.7/site-packages/pyramid-1.7.3-py2.7.egg/pyramid/decorator.py", line 42, in __get__
    val = self.wrapped(inst)
  File "/usr/lib/python2.7/site-packages/pyramid-1.7.3-py2.7.egg/pyramid/util.py", line 67, in <lambda>
    fn = lambda this: callable(this)
  File "/vagrant/bodhi/server/__init__.py", line 103, in get_releases
    return Release.all_releases(request.db)
  File "/vagrant/bodhi/server/models/models.py", line 330, in all_releases
    for release in session.query(cls).order_by(cls.name.desc()).all():
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2613, in all
    return list(self)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2761, in __iter__
    return self._execute_and_instances(context)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2776, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
    exc_info
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 202, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
    cursor.execute(statement, parameters)
ProgrammingError: (psycopg2.ProgrammingError) column releases.pending_signing_tag does not exist
LINE 1: ...releases.candidate_tag AS releases_candidate_tag, releases.p...
                                                             ^
 [SQL: 'SELECT releases.id AS releases_id, releases.name AS releases_name, releases.long_name AS releases_long_name, releases.version AS releases_version, releases.id_prefix AS releases_id_prefix, releases.branch AS releases_branch, releases.dist_tag AS releases_dist_tag, releases.stable_tag AS releases_stable_tag, releases.testing_tag AS releases_testing_tag, releases.candidate_tag AS releases_candidate_tag, releases.pending_signing_tag AS releases_pending_signing_tag, releases.pending_testing_tag AS releases_pending_testing_tag, releases.pending_stable_tag AS releases_pending_stable_tag, releases.override_tag AS releases_override_tag, releases.state AS releases_state \nFROM releases ORDER BY releases.name DESC']
```



Discussion:

Resolving patch:
diff --git a/alembic/versions/4df1fcd59050_.py b/alembic/versions/4df1fcd59050_.py
new file mode 100644
--- /dev/null
+++ b/alembic/versions/4df1fcd59050_.py
@@ -0,0 +1,27 @@
+"""Add the new pending_signing_tag column to the releases table.
+
+Revision ID: 4df1fcd59050
+Revises: 3c72757fa59e
+Create Date: 2016-09-16 18:51:19.514301
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '4df1fcd59050'
+down_revision = '3c72757fa59e'
+
+
+def upgrade():
+    op.add_column('releases',
+                  sa.Column('pending_signing_tag', sa.UnicodeText(), server_default='',
+                            nullable=False))
+    # We only used the server_default to stop the new column from being NULL. Let's now drop the
+    # server default.
+    op.alter_column('releases', 'pending_signing_tag', server_default=None)
+
+
+def downgrade():
+    op.drop_column('releases', 'pending_signing_tag')


Test patch: