(domain, table_id, max_length=50, prefix=UCR_TABLE_PREFIX)
return truncate_value(
        '{}{}_{}_{}'.format(prefix, domain, table_id, _hash(domain, table_id)),
        max_length=max_length,
        from_left=False
    )
:param domain:
    :param table_id:
    :param max_length: Max allowable length of table. Default of 50 to prevent long table
                       name issues with CitusDB. PostgreSQL max is 63.
    :param prefix: Table prefix. Configurable to allow migration from old to new prefix.
    :return:
:param domain:
    :param table_id:
    :param max_length: Max allowable length of table. Default of 50 to prevent long table
                       name issues with CitusDB. PostgreSQL max is 63.
    :param prefix: Table prefix. Configurable to allow migration from old to new prefix.
    :return:
: param domain : : param table_id : : param max_length : Max allowable length of table . Default of 50 to prevent long table name issues with CitusDB . PostgreSQL max is 63 . : param prefix : Table prefix . Configurable to allow migration from old to new prefix . : return :
def get_table_name(domain, table_id, max_length=50, prefix=UCR_TABLE_PREFIX):
    """
    :param domain:
    :param table_id:
    :param max_length: Max allowable length of table. Default of 50 to prevent long table
                       name issues with CitusDB. PostgreSQL max is 63.
    :param prefix: Table prefix. Configurable to allow migration from old to new prefix.
    :return:
    """
    def _hash(domain, table_id):
        return hashlib.sha1(
            '{}_{}'.format(
                hashlib.sha1(domain.encode('utf-8')).hexdigest(),
                table_id
            ).encode('utf-8')
        ).hexdigest()[:8]

    domain = domain.encode('unicode-escape').decode('utf-8')
    table_id = table_id.encode('unicode-escape').decode('utf-8')
    return truncate_value(
        '{}{}_{}_{}'.format(prefix, domain, table_id, _hash(domain, table_id)),
        max_length=max_length,
        from_left=False
    )
def get_table_name ( domain , table_id , max_length = 50 , prefix = UCR_TABLE_PREFIX ) : def _hash ( domain , table_id ) : return hashlib . sha1 ( '{}_{}' . format ( hashlib . sha1 ( domain . encode ( 'utf-8' ) ) . hexdigest ( ) , table_id ) . encode ( 'utf-8' ) ) . hexdigest ( ) [ : 8 ] domain = domain . encode ( 'unicode-escape' ) . decode ( 'utf-8' ) table_id = table_id . encode ( 'unicode-escape' ) . decode ( 'utf-8' ) return truncate_value ( '{}{}_{}_{}' . format ( prefix , domain , table_id , _hash ( domain , table_id ) ) , max_length = max_length , from_left = False )