Skip to content

Instantly share code, notes, and snippets.

@j-griffith
Created September 27, 2017 21:48
Show Gist options
  • Save j-griffith/cf45938a373cab99d6dab4ae0f91a119 to your computer and use it in GitHub Desktop.
Save j-griffith/cf45938a373cab99d6dab4ae0f91a119 to your computer and use it in GitHub Desktop.
this no workie workie
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
services = Table('services', meta, autoload=True)
if not hasattr(services.c, 'uuid'):
services.create_column(Column('uuid', String(36), nullable=True))
uuid_index_name = 'services_uuid_idx'
indexes = Inspector(migrate_engine).get_indexes('services')
if uuid_index_name not in (i['name'] for i in indexes):
services = Table('services', meta, autoload=True)
Index(uuid_index_name, services.c.uuid, unique=True).create()
service_list = list(services.select().execute())
for s in service_list:
LOG.error("service: %s", service)
s.update().where(services.c.uuid == None).values(uuid=six.text_type(uuid.uuid4())).execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment