@commentable
    def add(self):
        match = ''
        if hasattr(self, 'match'):
            match = " MATCH %s" % self.match.upper()
        actions = ''
        if hasattr(self, 'on_update'):
            actions = " ON UPDATE %s" % self.on_update.upper()
        if hasattr(self, 'on_delete'):
            actions += " ON DELETE %s" % self.on_delete.upper()
        if getattr(self, 'deferrable', False):
            actions += " DEFERRABLE"
        if getattr(self, 'deferred', False):
            actions += " INITIALLY DEFERRED"

        return "ALTER TABLE %s ADD CONSTRAINT %s FOREIGN KEY (%s) " \
            "REFERENCES %s (%s)%s%s" % (
            self._table.qualname(), quote_id(self.name), self.key_columns(),
            self.references.qualname(), self.ref_columns(), match, actions)
Return string to add the foreign key via ALTER TABLE
dataset/ETHPy150Open perseas/Pyrseas/pyrseas/dbobject/constraint.py/ForeignKey.add