Created
September 27, 2017 21:48
-
-
Save j-griffith/cf45938a373cab99d6dab4ae0f91a119 to your computer and use it in GitHub Desktop.
this no workie workie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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