def add_named_foreign_key_constraint(
        self, name, foreign_table, local_columns, foreign_columns, options
    ):
        """
        Adds a foreign key constraint with a given name.

        :param name: The constraint name
        :type name: str

        :param foreign_table: Table instance or table name
        :type foreign_table: Table or str

        :type local_columns: list

        :type foreign_columns: list

        :type options: dict

        :rtype: Table
        """
        if isinstance(foreign_table, Table):
            for column in foreign_columns:
                if not foreign_table.has_column(column):
                    raise ColumnDoesNotExist(column, foreign_table.get_name())

        for column in local_columns:
            if not self.has_column(column):
                raise ColumnDoesNotExist(column, self._name)

        constraint = ForeignKeyConstraint(
            local_columns, foreign_table, foreign_columns, name, options
        )

        self._add_foreign_key_constraint(constraint)

        return self
def add_named_foreign_key_constraint ( self , name , foreign_table , local_columns , foreign_columns , options ) : if isinstance ( foreign_table , Table ) : for column in foreign_columns : if not foreign_table . has_column ( column ) : raise ColumnDoesNotExist ( column , foreign_table . get_name ( ) ) for column in local_columns : if not self . has_column ( column ) : raise ColumnDoesNotExist ( column , self . _name ) constraint = ForeignKeyConstraint ( local_columns , foreign_table , foreign_columns , name , options ) self . _add_foreign_key_constraint ( constraint ) return self
Adds a foreign key constraint with a given name.

        :param name: The constraint name
        :type name: str

        :param foreign_table: Table instance or table name
        :type foreign_table: Table or str

        :type local_columns: list

        :type foreign_columns: list

        :type options: dict

        :rtype: Table