LazyRecord\SqlBuilder\BaseBuilder::buildForeignKeys PHP Method

buildForeignKeys() public method

public buildForeignKeys ( LazyRecord\Schema\SchemaInterface $schema )
$schema LazyRecord\Schema\SchemaInterface
    public function buildForeignKeys(SchemaInterface $schema)
    {
        $sqls = [];
        foreach ($schema->relations as $rel) {
            switch ($rel['type']) {
                case Relationship::BELONGS_TO:
                case Relationship::HAS_MANY:
                case Relationship::HAS_ONE:
                    if ($rel['foreign_schema'] == $rel['self_schema']) {
                        continue;
                    }
                    if (isset($rel['self_column']) && $rel['self_column'] != 'id') {
                        if ($constraint = $this->buildForeignKeyConstraint($rel)) {
                            $sqls[] = $constraint->toSql($this->driver, new ArgumentArray());
                        }
                    }
                    break;
            }
        }
        return $sqls;
    }