xpgdiff.py
def print_views_migration_ddl(source_schema, target_schema):
    """
    Prints DDL to migrate the views in two schemas.

    :param source_schema: The source schema.
    :param target_schema: The target schema.
    """
    print('--')
    print('-- VIEWS')
    print('--')
    next_source_view = next_or_none(source_schema.views)
    next_target_view = next_or_none(target_schema.views)

    source_view = next_source_view()
    target_view = next_target_view()

    while source_view or target_view:
        if not target_view:
            print(source_view.dropstr())
            source_view = next_source_view()
            continue

        if not source_view:
            print(f'{str(target_view)}')
            target_view = next_target_view()
            continue

        if source_view.name < target_view.name:
            print(source_view.dropstr())
            source_view = next_source_view()
            continue

        if source_view.name > target_view.name:
            print(f'{str(target_view)}')
            target_view = next_target_view()
            continue

        if source_view.definition != target_view.definition:
            print(source_view.dropstr())
            print(f'{str(target_view)}')
        else:
            print_grants_migration_ddl(source_view, target_view)
            if (source_view.owner != target_view.owner):
                print(target_view.ownerstr())

        source_view = next_source_view()
        target_view = next_target_view()

    Prints DDL to migrate the views in two schemas.

    :param source_schema: The source schema.
    :param target_schema: The target schema.
    
Prints DDL to migrate the views in two schemas.
Prints DDL to migrate the views in two schemas .
def print_views_migration_ddl(source_schema, target_schema):
    print('--')
    print('-- VIEWS')
    print('--')
    next_source_view = next_or_none(source_schema.views)
    next_target_view = next_or_none(target_schema.views)
    source_view = next_source_view()
    target_view = next_target_view()
    while source_view or target_view:
        if not target_view:
            print(source_view.dropstr())
            source_view = next_source_view()
            continue
        if not source_view:
            print(f'{str(target_view)}')
            target_view = next_target_view()
            continue
        if source_view.name < target_view.name:
            print(source_view.dropstr())
            source_view = next_source_view()
            continue
        if source_view.name > target_view.name:
            print(f'{str(target_view)}')
            target_view = next_target_view()
            continue
        if source_view.definition != target_view.definition:
            print(source_view.dropstr())
            print(f'{str(target_view)}')
        else:
            print_grants_migration_ddl(source_view, target_view)
            if (source_view.owner != target_view.owner):
                print(target_view.ownerstr())
        source_view = next_source_view()
        target_view = next_target_view()
def print_views_migration_ddl ( source_schema , target_schema ) : print ( '--' ) print ( '-- VIEWS' ) print ( '--' ) next_source_view = next_or_none ( source_schema . views ) next_target_view = next_or_none ( target_schema . views ) source_view = next_source_view ( ) target_view = next_target_view ( ) while source_view or target_view : if not target_view : print ( source_view . dropstr ( ) ) source_view = next_source_view ( ) continue if not source_view : print ( f'{str(target_view)}' ) target_view = next_target_view ( ) continue if source_view . name < target_view . name : print ( source_view . dropstr ( ) ) source_view = next_source_view ( ) continue if source_view . name > target_view . name : print ( f'{str(target_view)}' ) target_view = next_target_view ( ) continue if source_view . definition != target_view . definition : print ( source_view . dropstr ( ) ) print ( f'{str(target_view)}' ) else : print_grants_migration_ddl ( source_view , target_view ) if ( source_view . owner != target_view . owner ) : print ( target_view . ownerstr ( ) ) source_view = next_source_view ( ) target_view = next_target_view ( )
Prints DDL to migrate the views in two schemas.
Prints DDL to migrate the views in two schemas .
"""
    Prints DDL to migrate the views in two schemas.

    :param source_schema: The source schema.
    :param target_schema: The target schema.
    """
source_schema
The source schema.
The source schema .
target_schema
The target schema.
The target schema .