prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  The non-NULL comment text migration needs to be inserted before 4df1fcd59050
  This migration was developed against the develop branch, but I had forgotten that there was already a migration in the develop branch that isn't on the 2.2 branch. We'll need to change both migrations so that the new one is inserted before the prior one:
  
  ```
  [vagrant@localhost vagrant]$ alembic upgrade head
  WARNING:fedmsg.crypto.x509:Crypto disabled ImportError('No module named M2Crypto',)
  INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
  INFO  [alembic.runtime.migration] Will assume transactional DDL.
  /usr/lib/python2.7/site-packages/alembic/util/messaging.py:69: UserWarning: Revision 4df1fcd59050 referenced from 4df1fcd59050 -> 37f38ddc4c8d (head), Do not allow NULL values in the text column of the comments table. is not present
    warnings.warn(msg)
  Traceback (most recent call last):
    File "/usr/bin/alembic", line 9, in <module>
      load_entry_point('alembic==0.8.3', 'console_scripts', 'alembic')()
    File "/usr/lib/python2.7/site-packages/alembic/config.py", line 450, in main
      CommandLine(prog=prog).main(argv=argv)
    File "/usr/lib/python2.7/site-packages/alembic/config.py", line 444, in main
      self.run_cmd(cfg, options)
    File "/usr/lib/python2.7/site-packages/alembic/config.py", line 427, 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 81, 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 "alembic/env.py", line 72, in <module>
      run_migrations_online()
    File "alembic/env.py", line 65, 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 303, in run_migrations
      for step in self._migrations_fn(heads, self):
    File "/usr/lib/python2.7/site-packages/alembic/command.py", line 163, in upgrade
      return script._upgrade_revs(revision, rev)
    File "/usr/lib/python2.7/site-packages/alembic/script/base.py", line 310, in _upgrade_revs
      revs = list(revs)
    File "/usr/lib/python2.7/site-packages/alembic/script/revision.py", line 610, in _iterate_revisions
      requested_lowers = self.get_revisions(lower)
    File "/usr/lib/python2.7/site-packages/alembic/script/revision.py", line 299, in get_revisions
      return sum([self.get_revisions(id_elem) for id_elem in id_], ())
    File "/usr/lib/python2.7/site-packages/alembic/script/revision.py", line 301, in get_revisions
      resolved_id, branch_label = self._resolve_revision_number(id_)
    File "/usr/lib/python2.7/site-packages/alembic/script/revision.py", line 423, in _resolve_revision_number
      self._revision_map
    File "/usr/lib/python2.7/site-packages/alembic/util/langhelpers.py", line 241, in __get__
      obj.__dict__[self.__name__] = result = self.fget(obj)
    File "/usr/lib/python2.7/site-packages/alembic/script/revision.py", line 151, in _revision_map
      down_revision = map_[downrev]
  KeyError: '4df1fcd59050'
  ```
  
  It needs to be possible to vagrant up on the 2.2 branch and then advance to the develop branch.
  
  
  --- 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/4df1fcd59050_.py`
  Content:
  ```
  1 """Add the new pending_signing_tag column to the releases table.
  2 
  3 Revision ID: 4df1fcd59050
  4 Revises: 3c72757fa59e
  5 Create Date: 2016-09-16 18:51:19.514301
  6 
  7 """
  8 from alembic import op
  9 import sqlalchemy as sa
  10 
  11 
  12 # revision identifiers, used by Alembic.
  13 revision = '4df1fcd59050'
  14 down_revision = '3c72757fa59e'
  15 
  16 
  17 def upgrade():
  18     op.add_column('releases',
  19                   sa.Column('pending_signing_tag', sa.UnicodeText(), server_default='',
  20                             nullable=False))
  21     # We only used the server_default to stop the new column from being NULL. Let's now drop the
  22     # server default.
  23     op.alter_column('releases', 'pending_signing_tag', server_default=None)
  24 
  25 
  26 def downgrade():
  27     op.drop_column('releases', 'pending_signing_tag')
  28
  ```
  
  Path: `alembic/versions/37f38ddc4c8d_.py`
  Content:
  ```
  1 """Do not allow NULL values in the text column of the comments table.
  2 
  3 Revision ID: 37f38ddc4c8d
  4 Revises: 4df1fcd59050
  5 Create Date: 2016-09-21 19:51:04.946521
  6 
  7 """
  8 
  9 from alembic import op
  10 import sqlalchemy as sa
  11 
  12 
  13 # revision identifiers, used by Alembic.
  14 revision = '37f38ddc4c8d'
  15 down_revision = '4df1fcd59050'
  16 
  17 
  18 def upgrade():
  19     """
  20     We will need to set all existing NULL comments to "", then change the column to disallow NULL comments.
  21     """
  22     # Build a fake mini version of the comments table so we can form an UPDATE statement.
  23     comments = sa.sql.table('comments', sa.sql.column('text', sa.UnicodeText))
  24     # Set existing NULL comments to "".
  25     op.execute(comments.update().where(comments.c.text==None).values({'text': op.inline_literal('')}))
  26 
  27     # Disallow new NULL comments.
  28     op.alter_column('comments', 'text', existing_type=sa.TEXT(), nullable=False)
  29 
  30 
  31 def downgrade():
  32     op.alter_column('comments', 'text', existing_type=sa.TEXT(), nullable=True)
  33
  ```
  --- 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/37f38ddc4c8d_.py b/alembic/versions/37f38ddc4c8d_.py
  --- a/alembic/versions/37f38ddc4c8d_.py
  +++ b/alembic/versions/37f38ddc4c8d_.py
  @@ -1,7 +1,7 @@
   """Do not allow NULL values in the text column of the comments table.
   
   Revision ID: 37f38ddc4c8d
  -Revises: 4df1fcd59050
  +Revises: 3c72757fa59e
   Create Date: 2016-09-21 19:51:04.946521
   
   """
  @@ -12,7 +12,7 @@
   
   # revision identifiers, used by Alembic.
   revision = '37f38ddc4c8d'
  -down_revision = '4df1fcd59050'
  +down_revision = '3c72757fa59e'
   
   
   def upgrade():
  diff --git a/alembic/versions/4df1fcd59050_.py b/alembic/versions/4df1fcd59050_.py
  --- a/alembic/versions/4df1fcd59050_.py
  +++ b/alembic/versions/4df1fcd59050_.py
  @@ -1,7 +1,7 @@
   """Add the new pending_signing_tag column to the releases table.
   
   Revision ID: 4df1fcd59050
  -Revises: 3c72757fa59e
  +Revises: 37f38ddc4c8d
   Create Date: 2016-09-16 18:51:19.514301
   
   """
  @@ -11,7 +11,7 @@
   
   # revision identifiers, used by Alembic.
   revision = '4df1fcd59050'
  -down_revision = '3c72757fa59e'
  +down_revision = '37f38ddc4c8d'
   
   
   def upgrade():
  
verification_info: {"golden_diff": "diff --git a/alembic/versions/37f38ddc4c8d_.py b/alembic/versions/37f38ddc4c8d_.py\n--- a/alembic/versions/37f38ddc4c8d_.py\n+++ b/alembic/versions/37f38ddc4c8d_.py\n@@ -1,7 +1,7 @@\n \"\"\"Do not allow NULL values in the text column of the comments table.\n \n Revision ID: 37f38ddc4c8d\n-Revises: 4df1fcd59050\n+Revises: 3c72757fa59e\n Create Date: 2016-09-21 19:51:04.946521\n \n \"\"\"\n@@ -12,7 +12,7 @@\n \n # revision identifiers, used by Alembic.\n revision = '37f38ddc4c8d'\n-down_revision = '4df1fcd59050'\n+down_revision = '3c72757fa59e'\n \n \n def upgrade():\ndiff --git a/alembic/versions/4df1fcd59050_.py b/alembic/versions/4df1fcd59050_.py\n--- a/alembic/versions/4df1fcd59050_.py\n+++ b/alembic/versions/4df1fcd59050_.py\n@@ -1,7 +1,7 @@\n \"\"\"Add the new pending_signing_tag column to the releases table.\n \n Revision ID: 4df1fcd59050\n-Revises: 3c72757fa59e\n+Revises: 37f38ddc4c8d\n Create Date: 2016-09-16 18:51:19.514301\n \n \"\"\"\n@@ -11,7 +11,7 @@\n \n # revision identifiers, used by Alembic.\n revision = '4df1fcd59050'\n-down_revision = '3c72757fa59e'\n+down_revision = '37f38ddc4c8d'\n \n \n def upgrade():\n", "issue": "The non-NULL comment text migration needs to be inserted before 4df1fcd59050\nThis migration was developed against the develop branch, but I had forgotten that there was already a migration in the develop branch that isn't on the 2.2 branch. We'll need to change both migrations so that the new one is inserted before the prior one:\n\n```\n[vagrant@localhost vagrant]$ alembic upgrade head\nWARNING:fedmsg.crypto.x509:Crypto disabled ImportError('No module named M2Crypto',)\nINFO  [alembic.runtime.migration] Context impl PostgresqlImpl.\nINFO  [alembic.runtime.migration] Will assume transactional DDL.\n/usr/lib/python2.7/site-packages/alembic/util/messaging.py:69: UserWarning: Revision 4df1fcd59050 referenced from 4df1fcd59050 -> 37f38ddc4c8d (head), Do not allow NULL values in the text column of the comments table. is not present\n  warnings.warn(msg)\nTraceback (most recent call last):\n  File \"/usr/bin/alembic\", line 9, in <module>\n    load_entry_point('alembic==0.8.3', 'console_scripts', 'alembic')()\n  File \"/usr/lib/python2.7/site-packages/alembic/config.py\", line 450, in main\n    CommandLine(prog=prog).main(argv=argv)\n  File \"/usr/lib/python2.7/site-packages/alembic/config.py\", line 444, in main\n    self.run_cmd(cfg, options)\n  File \"/usr/lib/python2.7/site-packages/alembic/config.py\", line 427, in run_cmd\n    **dict((k, getattr(options, k)) for k in kwarg)\n  File \"/usr/lib/python2.7/site-packages/alembic/command.py\", line 174, in upgrade\n    script.run_env()\n  File \"/usr/lib/python2.7/site-packages/alembic/script/base.py\", line 397, in run_env\n    util.load_python_file(self.dir, 'env.py')\n  File \"/usr/lib/python2.7/site-packages/alembic/util/pyfiles.py\", line 81, in load_python_file\n    module = load_module_py(module_id, path)\n  File \"/usr/lib/python2.7/site-packages/alembic/util/compat.py\", line 79, in load_module_py\n    mod = imp.load_source(module_id, path, fp)\n  File \"alembic/env.py\", line 72, in <module>\n    run_migrations_online()\n  File \"alembic/env.py\", line 65, in run_migrations_online\n    context.run_migrations()\n  File \"<string>\", line 8, in run_migrations\n  File \"/usr/lib/python2.7/site-packages/alembic/runtime/environment.py\", line 797, in run_migrations\n    self.get_context().run_migrations(**kw)\n  File \"/usr/lib/python2.7/site-packages/alembic/runtime/migration.py\", line 303, in run_migrations\n    for step in self._migrations_fn(heads, self):\n  File \"/usr/lib/python2.7/site-packages/alembic/command.py\", line 163, in upgrade\n    return script._upgrade_revs(revision, rev)\n  File \"/usr/lib/python2.7/site-packages/alembic/script/base.py\", line 310, in _upgrade_revs\n    revs = list(revs)\n  File \"/usr/lib/python2.7/site-packages/alembic/script/revision.py\", line 610, in _iterate_revisions\n    requested_lowers = self.get_revisions(lower)\n  File \"/usr/lib/python2.7/site-packages/alembic/script/revision.py\", line 299, in get_revisions\n    return sum([self.get_revisions(id_elem) for id_elem in id_], ())\n  File \"/usr/lib/python2.7/site-packages/alembic/script/revision.py\", line 301, in get_revisions\n    resolved_id, branch_label = self._resolve_revision_number(id_)\n  File \"/usr/lib/python2.7/site-packages/alembic/script/revision.py\", line 423, in _resolve_revision_number\n    self._revision_map\n  File \"/usr/lib/python2.7/site-packages/alembic/util/langhelpers.py\", line 241, in __get__\n    obj.__dict__[self.__name__] = result = self.fget(obj)\n  File \"/usr/lib/python2.7/site-packages/alembic/script/revision.py\", line 151, in _revision_map\n    down_revision = map_[downrev]\nKeyError: '4df1fcd59050'\n```\n\nIt needs to be possible to vagrant up on the 2.2 branch and then advance to the develop branch.\n\n", "before_files": [{"content": "\"\"\"Add the new pending_signing_tag column to the releases table.\n\nRevision ID: 4df1fcd59050\nRevises: 3c72757fa59e\nCreate Date: 2016-09-16 18:51:19.514301\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision identifiers, used by Alembic.\nrevision = '4df1fcd59050'\ndown_revision = '3c72757fa59e'\n\n\ndef upgrade():\n    op.add_column('releases',\n                  sa.Column('pending_signing_tag', sa.UnicodeText(), server_default='',\n                            nullable=False))\n    # We only used the server_default to stop the new column from being NULL. Let's now drop the\n    # server default.\n    op.alter_column('releases', 'pending_signing_tag', server_default=None)\n\n\ndef downgrade():\n    op.drop_column('releases', 'pending_signing_tag')\n", "path": "alembic/versions/4df1fcd59050_.py"}, {"content": "\"\"\"Do not allow NULL values in the text column of the comments table.\n\nRevision ID: 37f38ddc4c8d\nRevises: 4df1fcd59050\nCreate Date: 2016-09-21 19:51:04.946521\n\n\"\"\"\n\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision identifiers, used by Alembic.\nrevision = '37f38ddc4c8d'\ndown_revision = '4df1fcd59050'\n\n\ndef upgrade():\n    \"\"\"\n    We will need to set all existing NULL comments to \"\", then change the column to disallow NULL comments.\n    \"\"\"\n    # Build a fake mini version of the comments table so we can form an UPDATE statement.\n    comments = sa.sql.table('comments', sa.sql.column('text', sa.UnicodeText))\n    # Set existing NULL comments to \"\".\n    op.execute(comments.update().where(comments.c.text==None).values({'text': op.inline_literal('')}))\n\n    # Disallow new NULL comments.\n    op.alter_column('comments', 'text', existing_type=sa.TEXT(), nullable=False)\n\n\ndef downgrade():\n    op.alter_column('comments', 'text', existing_type=sa.TEXT(), nullable=True)\n", "path": "alembic/versions/37f38ddc4c8d_.py"}], "after_files": [{"content": "\"\"\"Add the new pending_signing_tag column to the releases table.\n\nRevision ID: 4df1fcd59050\nRevises: 37f38ddc4c8d\nCreate Date: 2016-09-16 18:51:19.514301\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision identifiers, used by Alembic.\nrevision = '4df1fcd59050'\ndown_revision = '37f38ddc4c8d'\n\n\ndef upgrade():\n    op.add_column('releases',\n                  sa.Column('pending_signing_tag', sa.UnicodeText(), server_default='',\n                            nullable=False))\n    # We only used the server_default to stop the new column from being NULL. Let's now drop the\n    # server default.\n    op.alter_column('releases', 'pending_signing_tag', server_default=None)\n\n\ndef downgrade():\n    op.drop_column('releases', 'pending_signing_tag')\n", "path": "alembic/versions/4df1fcd59050_.py"}, {"content": "\"\"\"Do not allow NULL values in the text column of the comments table.\n\nRevision ID: 37f38ddc4c8d\nRevises: 3c72757fa59e\nCreate Date: 2016-09-21 19:51:04.946521\n\n\"\"\"\n\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision identifiers, used by Alembic.\nrevision = '37f38ddc4c8d'\ndown_revision = '3c72757fa59e'\n\n\ndef upgrade():\n    \"\"\"\n    We will need to set all existing NULL comments to \"\", then change the column to disallow NULL comments.\n    \"\"\"\n    # Build a fake mini version of the comments table so we can form an UPDATE statement.\n    comments = sa.sql.table('comments', sa.sql.column('text', sa.UnicodeText))\n    # Set existing NULL comments to \"\".\n    op.execute(comments.update().where(comments.c.text==None).values({'text': op.inline_literal('')}))\n\n    # Disallow new NULL comments.\n    op.alter_column('comments', 'text', existing_type=sa.TEXT(), nullable=False)\n\n\ndef downgrade():\n    op.alter_column('comments', 'text', existing_type=sa.TEXT(), nullable=True)\n", "path": "alembic/versions/37f38ddc4c8d_.py"}]}