def migrate(ctx, start_version, end_version):
    """Transition from one SWAG schema to another."""
    if ctx.type == 'file':
        if ctx.data_file:
            file_path = ctx.data_file
        else:
            file_path = os.path.join(ctx.data_file, ctx.namespace + '.json')

        # todo make this more like alemebic and determine/load versions automatically
        with open(file_path, 'r') as f:
            data = json.loads(f.read())

        data = run_migration(data, start_version, end_version)
        with open(file_path, 'w') as f:
            f.write(json.dumps(data))
def migrate ( ctx , start_version , end_version ) : if ctx . type == 'file' : if ctx . data_file : file_path = ctx . data_file else : file_path = os . path . join ( ctx . data_file , ctx . namespace + '.json' ) with open ( file_path , 'r' ) as f : data = json . loads ( f . read ( ) ) data = run_migration ( data , start_version , end_version ) with open ( file_path , 'w' ) as f : f . write ( json . dumps ( data ) )
Transition from one SWAG schema to another.