from sqlalchemy import MetaData, Table, Column
from sqlalchemy import Integer


def upgrade(migrate_engine):
    meta = MetaData(bind=migrate_engine)

    table = Table('badge', meta, autoload=True)
    col = Column('impact', Integer, default=0, nullable=False)
    col.create(table)

from sqlalchemy import MetaData, Table, Column
from sqlalchemy import Integer


def upgrade(migrate_engine):
    meta = MetaData(bind=migrate_engine)

    table = Table('badge', meta, autoload=True)
    col = Column('impact', Integer, default=0, server_default=u'0',
                 nullable=False)
    col.create(table)

Fix badge impact migration if badges are present
Fix badge impact migration if badges are present

If badges are already present in the system, their impact value must be set to something other than NULL. (default=0 is misleading, since it just applies to newly created badges, see http://stackoverflow.com/q/16097149/35070).

  from sqlalchemy import MetaData, Table, Column
  from sqlalchemy import Integer
  
  
  def upgrade(migrate_engine):
      meta = MetaData(bind=migrate_engine)
  
      table = Table('badge', meta, autoload=True)
-     col = Column('impact', Integer, default=0, nullable=False)
+     col = Column('impact', Integer, default=0, server_default=u'0',
+                  nullable=False)
      col.create(table)
  
Fix badge impact migration if badges are present
## Code Before:
from sqlalchemy import MetaData, Table, Column
from sqlalchemy import Integer


def upgrade(migrate_engine):
    meta = MetaData(bind=migrate_engine)

    table = Table('badge', meta, autoload=True)
    col = Column('impact', Integer, default=0, nullable=False)
    col.create(table)

## Instruction:
Fix badge impact migration if badges are present
## Code After:
from sqlalchemy import MetaData, Table, Column
from sqlalchemy import Integer


def upgrade(migrate_engine):
    meta = MetaData(bind=migrate_engine)

    table = Table('badge', meta, autoload=True)
    col = Column('impact', Integer, default=0, server_default=u'0',
                 nullable=False)
    col.create(table)
