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

    :param source_schema: The source schema.
    :param target_schema: The target schema.
    """
    print('--')
    print('-- FUNCTIONS')
    print('--')
    next_source_function = next_or_none(sorted(source_schema.functions, key=lambda f: f.fullname))
    next_target_function = next_or_none(sorted(target_schema.functions, key=lambda f: f.fullname))

    source_function = next_source_function()
    target_function = next_target_function()

    while source_function or target_function:
        if not target_function:
            print(source_function.dropstr())
            source_function = next_source_function()
            continue

        if not source_function:
            print(f'{str(target_function)}')
            target_function = next_target_function()
            continue

        if source_function.name < target_function.name:
            print(source_function.dropstr())
            source_function = next_source_function()
            continue

        if source_function.name > target_function.name:
            print(f'{str(target_function)}')
            target_function = next_target_function()
            continue

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

        source_function = next_source_function()
        target_function = next_target_function()

    Prints DDL to migrate the functions in two schemas.

    :param source_schema: The source schema.
    :param target_schema: The target schema.
    
Prints DDL to migrate the functions in two schemas.
Prints DDL to migrate the functions in two schemas .
def print_functions_migration_ddl(source_schema, target_schema):
    print('--')
    print('-- FUNCTIONS')
    print('--')
    next_source_function = next_or_none(sorted(source_schema.functions, key=lambda f: f.fullname))
    next_target_function = next_or_none(sorted(target_schema.functions, key=lambda f: f.fullname))
    source_function = next_source_function()
    target_function = next_target_function()
    while source_function or target_function:
        if not target_function:
            print(source_function.dropstr())
            source_function = next_source_function()
            continue
        if not source_function:
            print(f'{str(target_function)}')
            target_function = next_target_function()
            continue
        if source_function.name < target_function.name:
            print(source_function.dropstr())
            source_function = next_source_function()
            continue
        if source_function.name > target_function.name:
            print(f'{str(target_function)}')
            target_function = next_target_function()
            continue
        if source_function.definition != target_function.definition:
            print(source_function.dropstr())
            print(f'{str(target_function)}')
        else:
            print_grants_migration_ddl(source_function, target_function)
            if source_function.owner != target_function.owner:
                print(target_function.ownerstr())
        source_function = next_source_function()
        target_function = next_target_function()
def print_functions_migration_ddl ( source_schema , target_schema ) : print ( '--' ) print ( '-- FUNCTIONS' ) print ( '--' ) next_source_function = next_or_none ( sorted ( source_schema . functions , key = lambda f : f . fullname ) ) next_target_function = next_or_none ( sorted ( target_schema . functions , key = lambda f : f . fullname ) ) source_function = next_source_function ( ) target_function = next_target_function ( ) while source_function or target_function : if not target_function : print ( source_function . dropstr ( ) ) source_function = next_source_function ( ) continue if not source_function : print ( f'{str(target_function)}' ) target_function = next_target_function ( ) continue if source_function . name < target_function . name : print ( source_function . dropstr ( ) ) source_function = next_source_function ( ) continue if source_function . name > target_function . name : print ( f'{str(target_function)}' ) target_function = next_target_function ( ) continue if source_function . definition != target_function . definition : print ( source_function . dropstr ( ) ) print ( f'{str(target_function)}' ) else : print_grants_migration_ddl ( source_function , target_function ) if source_function . owner != target_function . owner : print ( target_function . ownerstr ( ) ) source_function = next_source_function ( ) target_function = next_target_function ( )
Prints DDL to migrate the functions in two schemas.
Prints DDL to migrate the functions in two schemas .
"""
    Prints DDL to migrate the functions 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 .