prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py uses server default
  The ```alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py``` migration uses a server default, which is not allowed by BDR:
  
  ```
  [bowlofeggs@bodhi-backend01 ~][STG]$ sudo /usr/bin/alembic -c /etc/bodhi/alembic.ini upgrade head
  INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
  INFO  [alembic.runtime.migration] Will assume transactional DDL.
  INFO  [alembic.runtime.migration] Running upgrade 12d3e8695f90 -> 9241378c92ab, Convert the builds table to be polymorphic.
  Traceback (most recent call last):
    File "/usr/bin/alembic", line 12, in <module>
      sys.exit(load_entry_point('alembic', 'console_scripts', 'alembic')())
    File "/usr/lib/python2.7/site-packages/alembic/config.py", line 479, in main
      CommandLine(prog=prog).main(argv=argv)
    File "/usr/lib/python2.7/site-packages/alembic/config.py", line 473, in main
      self.run_cmd(cfg, options)
    File "/usr/lib/python2.7/site-packages/alembic/config.py", line 456, in run_cmd
      **dict((k, getattr(options, k)) for k in kwarg)
    File "/usr/lib/python2.7/site-packages/alembic/command.py", line 174, in upgrade
      script.run_env()
    File "/usr/lib/python2.7/site-packages/alembic/script/base.py", line 397, in run_env
      util.load_python_file(self.dir, 'env.py')
    File "/usr/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
      module = load_module_py(module_id, path)
    File "/usr/lib/python2.7/site-packages/alembic/util/compat.py", line 79, in load_module_py
      mod = imp.load_source(module_id, path, fp)
    File "/usr/share/bodhi/alembic/env.py", line 83, in <module>
      run_migrations_online()
    File "/usr/share/bodhi/alembic/env.py", line 76, in run_migrations_online
      context.run_migrations()
    File "<string>", line 8, in run_migrations
    File "/usr/lib/python2.7/site-packages/alembic/runtime/environment.py", line 797, in run_migrations
      self.get_context().run_migrations(**kw)
    File "/usr/lib/python2.7/site-packages/alembic/runtime/migration.py", line 312, in run_migrations
      step.migration_fn(**kw)
    File "/usr/share/bodhi/alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py", line 19, in upgrade
      op.add_column('builds', sa.Column('type', sa.Integer(), nullable=False, server_default=u'1'))
    File "<string>", line 8, in add_column
    File "<string>", line 3, in add_column
    File "/usr/lib/python2.7/site-packages/alembic/operations/ops.py", line 1535, in add_column
      return operations.invoke(op)
    File "/usr/lib/python2.7/site-packages/alembic/operations/base.py", line 318, in invoke
      return fn(self, operation)
    File "/usr/lib/python2.7/site-packages/alembic/operations/toimpl.py", line 123, in add_column
      schema=schema
    File "/usr/lib/python2.7/site-packages/alembic/ddl/impl.py", line 172, in add_column
      self._exec(base.AddColumn(table_name, column, schema=schema))
    File "/usr/lib/python2.7/site-packages/alembic/ddl/impl.py", line 118, in _exec
      return conn.execute(construct, *multiparams, **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/ddl.py", line 68, in _execute_on_connection
      return connection._execute_ddl(self, multiparams, params)
    File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 968, in _execute_ddl
      compiled
    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 203, 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)
  sqlalchemy.exc.NotSupportedError: (psycopg2.NotSupportedError) ALTER TABLE ... ADD COLUMN ... DEFAULT may only affect UNLOGGED or TEMPORARY tables when BDR is active; builds is a regular table
   [SQL: "ALTER TABLE builds ADD COLUMN type INTEGER DEFAULT '1' NOT NULL"]
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py`
  Content:
  ```
  1 """Convert the builds table to be polymorphic.
  2 
  3 Revision ID: 9241378c92ab
  4 Revises: 12d3e8695f90
  5 Create Date: 2017-04-06 20:37:24.766366
  6 """
  7 from alembic import op
  8 import sqlalchemy as sa
  9 
  10 
  11 # revision identifiers, used by Alembic.
  12 revision = '9241378c92ab'
  13 down_revision = '12d3e8695f90'
  14 
  15 
  16 def upgrade():
  17     """Add the type column to the builds table."""
  18     # The default of ``1`` is the RPM Build type.
  19     op.add_column('builds', sa.Column('type', sa.Integer(), nullable=False, server_default=u'1'))
  20     op.alter_column('builds', 'type', server_default=None)
  21 
  22 
  23 def downgrade():
  24     """Remove the type column from the builds table."""
  25     op.drop_column('builds', 'type')
  26
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py b/alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py
  --- a/alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py
  +++ b/alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py
  @@ -15,9 +15,11 @@
   
   def upgrade():
       """Add the type column to the builds table."""
  -    # The default of ``1`` is the RPM Build type.
  -    op.add_column('builds', sa.Column('type', sa.Integer(), nullable=False, server_default=u'1'))
  -    op.alter_column('builds', 'type', server_default=None)
  +    builds = sa.sql.table('builds', sa.sql.column('type', sa.Integer()))
  +    op.add_column('builds', sa.Column('type', sa.Integer(), nullable=True))
  +    # The type 1 is the RPM Build type.
  +    op.execute(builds.update().values({'type': 1}))
  +    op.alter_column('builds', 'type', nullable=False)
   
   
   def downgrade():
  
verification_info: {"golden_diff": "diff --git a/alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py b/alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py\n--- a/alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py\n+++ b/alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py\n@@ -15,9 +15,11 @@\n \n def upgrade():\n     \"\"\"Add the type column to the builds table.\"\"\"\n-    # The default of ``1`` is the RPM Build type.\n-    op.add_column('builds', sa.Column('type', sa.Integer(), nullable=False, server_default=u'1'))\n-    op.alter_column('builds', 'type', server_default=None)\n+    builds = sa.sql.table('builds', sa.sql.column('type', sa.Integer()))\n+    op.add_column('builds', sa.Column('type', sa.Integer(), nullable=True))\n+    # The type 1 is the RPM Build type.\n+    op.execute(builds.update().values({'type': 1}))\n+    op.alter_column('builds', 'type', nullable=False)\n \n \n def downgrade():\n", "issue": "alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py uses server default\nThe ```alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py``` migration uses a server default, which is not allowed by BDR:\r\n\r\n```\r\n[bowlofeggs@bodhi-backend01 ~][STG]$ sudo /usr/bin/alembic -c /etc/bodhi/alembic.ini upgrade head\r\nINFO  [alembic.runtime.migration] Context impl PostgresqlImpl.\r\nINFO  [alembic.runtime.migration] Will assume transactional DDL.\r\nINFO  [alembic.runtime.migration] Running upgrade 12d3e8695f90 -> 9241378c92ab, Convert the builds table to be polymorphic.\r\nTraceback (most recent call last):\r\n  File \"/usr/bin/alembic\", line 12, in <module>\r\n    sys.exit(load_entry_point('alembic', 'console_scripts', 'alembic')())\r\n  File \"/usr/lib/python2.7/site-packages/alembic/config.py\", line 479, in main\r\n    CommandLine(prog=prog).main(argv=argv)\r\n  File \"/usr/lib/python2.7/site-packages/alembic/config.py\", line 473, in main\r\n    self.run_cmd(cfg, options)\r\n  File \"/usr/lib/python2.7/site-packages/alembic/config.py\", line 456, in run_cmd\r\n    **dict((k, getattr(options, k)) for k in kwarg)\r\n  File \"/usr/lib/python2.7/site-packages/alembic/command.py\", line 174, in upgrade\r\n    script.run_env()\r\n  File \"/usr/lib/python2.7/site-packages/alembic/script/base.py\", line 397, in run_env\r\n    util.load_python_file(self.dir, 'env.py')\r\n  File \"/usr/lib/python2.7/site-packages/alembic/util/pyfiles.py\", line 93, in load_python_file\r\n    module = load_module_py(module_id, path)\r\n  File \"/usr/lib/python2.7/site-packages/alembic/util/compat.py\", line 79, in load_module_py\r\n    mod = imp.load_source(module_id, path, fp)\r\n  File \"/usr/share/bodhi/alembic/env.py\", line 83, in <module>\r\n    run_migrations_online()\r\n  File \"/usr/share/bodhi/alembic/env.py\", line 76, in run_migrations_online\r\n    context.run_migrations()\r\n  File \"<string>\", line 8, in run_migrations\r\n  File \"/usr/lib/python2.7/site-packages/alembic/runtime/environment.py\", line 797, in run_migrations\r\n    self.get_context().run_migrations(**kw)\r\n  File \"/usr/lib/python2.7/site-packages/alembic/runtime/migration.py\", line 312, in run_migrations\r\n    step.migration_fn(**kw)\r\n  File \"/usr/share/bodhi/alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py\", line 19, in upgrade\r\n    op.add_column('builds', sa.Column('type', sa.Integer(), nullable=False, server_default=u'1'))\r\n  File \"<string>\", line 8, in add_column\r\n  File \"<string>\", line 3, in add_column\r\n  File \"/usr/lib/python2.7/site-packages/alembic/operations/ops.py\", line 1535, in add_column\r\n    return operations.invoke(op)\r\n  File \"/usr/lib/python2.7/site-packages/alembic/operations/base.py\", line 318, in invoke\r\n    return fn(self, operation)\r\n  File \"/usr/lib/python2.7/site-packages/alembic/operations/toimpl.py\", line 123, in add_column\r\n    schema=schema\r\n  File \"/usr/lib/python2.7/site-packages/alembic/ddl/impl.py\", line 172, in add_column\r\n    self._exec(base.AddColumn(table_name, column, schema=schema))\r\n  File \"/usr/lib/python2.7/site-packages/alembic/ddl/impl.py\", line 118, in _exec\r\n    return conn.execute(construct, *multiparams, **params)\r\n  File \"/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py\", line 914, in execute\r\n    return meth(self, multiparams, params)\r\n  File \"/usr/lib64/python2.7/site-packages/sqlalchemy/sql/ddl.py\", line 68, in _execute_on_connection\r\n    return connection._execute_ddl(self, multiparams, params)\r\n  File \"/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py\", line 968, in _execute_ddl\r\n    compiled\r\n  File \"/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py\", line 1146, in _execute_context\r\n    context)\r\n  File \"/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py\", line 1341, in _handle_dbapi_exception\r\n    exc_info\r\n  File \"/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py\", line 203, in raise_from_cause\r\n    reraise(type(exception), exception, tb=exc_tb, cause=cause)\r\n  File \"/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py\", line 1139, in _execute_context\r\n    context)\r\n  File \"/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py\", line 450, in do_execute\r\n    cursor.execute(statement, parameters)\r\nsqlalchemy.exc.NotSupportedError: (psycopg2.NotSupportedError) ALTER TABLE ... ADD COLUMN ... DEFAULT may only affect UNLOGGED or TEMPORARY tables when BDR is active; builds is a regular table\r\n [SQL: \"ALTER TABLE builds ADD COLUMN type INTEGER DEFAULT '1' NOT NULL\"]\r\n```\n", "before_files": [{"content": "\"\"\"Convert the builds table to be polymorphic.\n\nRevision ID: 9241378c92ab\nRevises: 12d3e8695f90\nCreate Date: 2017-04-06 20:37:24.766366\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision identifiers, used by Alembic.\nrevision = '9241378c92ab'\ndown_revision = '12d3e8695f90'\n\n\ndef upgrade():\n    \"\"\"Add the type column to the builds table.\"\"\"\n    # The default of ``1`` is the RPM Build type.\n    op.add_column('builds', sa.Column('type', sa.Integer(), nullable=False, server_default=u'1'))\n    op.alter_column('builds', 'type', server_default=None)\n\n\ndef downgrade():\n    \"\"\"Remove the type column from the builds table.\"\"\"\n    op.drop_column('builds', 'type')\n", "path": "alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py"}], "after_files": [{"content": "\"\"\"Convert the builds table to be polymorphic.\n\nRevision ID: 9241378c92ab\nRevises: 12d3e8695f90\nCreate Date: 2017-04-06 20:37:24.766366\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision identifiers, used by Alembic.\nrevision = '9241378c92ab'\ndown_revision = '12d3e8695f90'\n\n\ndef upgrade():\n    \"\"\"Add the type column to the builds table.\"\"\"\n    builds = sa.sql.table('builds', sa.sql.column('type', sa.Integer()))\n    op.add_column('builds', sa.Column('type', sa.Integer(), nullable=True))\n    # The type 1 is the RPM Build type.\n    op.execute(builds.update().values({'type': 1}))\n    op.alter_column('builds', 'type', nullable=False)\n\n\ndef downgrade():\n    \"\"\"Remove the type column from the builds table.\"\"\"\n    op.drop_column('builds', 'type')\n", "path": "alembic/versions/9241378c92ab_convert_the_builds_table_to_be_.py"}]}