Get the foreign key syntax for a table creation statement.

@param  \Nova\Database\Schema\Blueprint  $blueprint
@return string|null
330502
protected function addForeignKeys(Blueprint $blueprint)
    {
        $sql = '';

        $foreigns = $this->getCommandsByName($blueprint, 'foreign');

        // Once we have all the foreign key commands for the table creation statement
        // we'll loop through each of them and add them to the create table SQL we
        // are building, since SQLite needs foreign keys on the tables creation.
        foreach ($foreigns as $foreign) {
            $sql .= $this->getForeignKey($foreign);

            if (! is_null($foreign->onDelete)) {
                $sql .= " on delete {$foreign->onDelete}";
            }

            if (! is_null($foreign->onUpdate)) {
                $sql .= " on update {$foreign->onUpdate}";
            }
        }

        return $sql;
    }
271951
def compile_create(self, blueprint, command, _):
        
        columns = ', '.join(self._get_columns(blueprint))

        sql = 'CREATE TABLE %s (%s' % (self.wrap_table(blueprint), columns)

        sql += self._add_foreign_keys(blueprint)

        sql += self._add_primary_keys(blueprint)

        return sql + ')'
539850
protected function modifyIncrement(Blueprint $blueprint, Fluent $column)
    {
        if ((in_array($column->type, $this->serials) || ($column->generatedAs !== null)) && $column->autoIncrement) {
            return ' primary key';
        }
    }
1166389
protected function modifyNullable(Blueprint $blueprint, Fluent $column)
    {
        if (is_null($column->virtualAs) && is_null($column->storedAs)) {
            return $column->nullable ? ' null' : ' not null';
        }
    }
782872
public function compileChange(Blueprint $blueprint, Fluent $command, Connection $connection)
	{
		$schema = $connection->getDoctrineSchemaManager();

		$tableDiff = $this->getChangedDiff($blueprint, $schema);

		if ($tableDiff !== false)
		{
			return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff);
		}

		return [];
	}
218469
public function compileSpatialIndex(Blueprint $blueprint, Fluent $command)
    {
        $command->algorithm = 'gist';

        return $this->compileIndex($blueprint, $command);
    }
1203351
private function fluentComments(OracleBlueprint $blueprint)
    {
        foreach ($blueprint->getColumns() as $column) {
            if (isset($column['comment'])) {
                $this->commentColumn($blueprint->getTable(), $column['name'], $column['comment']);
            }
        }
    }
151299
public function compileComment(Blueprint $blueprint, Fluent $command)
    {
        return sprintf('comment on column %s.%s is %s',
            $this->wrapTable($blueprint),
            $this->wrap($command->column->name),
            "'".str_replace("'", "''", $command->value)."'"
        );
    }
1174141
protected function compileCreateTable($blueprint, $command, $connection)
    {
        return sprintf('%s table %s (%s)',
            $blueprint->temporary ? 'create temporary' : 'create',
            $this->wrapTable($blueprint),
            implode(', ', $this->getColumns($blueprint))
        );
    }
495446
protected function createSchema(Closure $blueprint)
    {
        if ($this->hasConnection()) {
            Schema::connection($this->getConnection())
                  ->create($this->getTableName(), $blueprint);
        }
        else {
            Schema::create($this->getTableName(), $blueprint);
        }
    }
990440
public function compileChange( Blueprint $blueprint, Fluent $command, Connection $connection )
	{
		if ( !$connection->isDoctrineAvailable() )
		{
			throw new RuntimeException( sprintf( 'Changing columns for table "%s" requires Doctrine DBAL; install "doctrine/dbal".', $blueprint->getTable() ) );
		}

		$schema = $connection->getDoctrineSchemaManager();

		$tableDiff = $this->getChangedDiff( $blueprint, $schema );

		if ( $tableDiff !== false )
		{
			return (array) $schema->getDatabasePlatform()->getAlterTableSQL( $tableDiff );
		}

		return [];
	}
1130266
def compile_foreign(self, blueprint, command, _):
        
        table = self.wrap_table(blueprint)

        on = self.wrap_table(command.on)

        columns = self.columnize(command.columns)

        on_columns = self.columnize(command.references
                                    if isinstance(command.references, list)
                                    else [command.references])

        sql = 'ALTER TABLE %s ADD CONSTRAINT %s ' % (table, command.index)

        sql += 'FOREIGN KEY (%s) REFERENCES %s (%s)' % (columns, on, on_columns)

        if command.get('on_delete'):
            sql += ' ON DELETE %s' % command.on_delete

        if command.get('on_update'):
            sql += ' ON UPDATE %s' % command.on_update

        return sql
1156292
public function compileCreate(Blueprint $blueprint, Fluent $command)
    {
        $columns = implode(', ', $this->getColumns($blueprint));

        $sql = 'create table '.$this->wrapTable($blueprint)." ($columns";

        // SQLite forces primary keys to be added when the table is initially created
        // so we will need to check for a primary key commands and add the columns
        // to the table's declaration here so they can be created on the tables.
        $sql .= (string) $this->addForeignKeys($blueprint);

        $sql .= (string) $this->addPrimaryKeys($blueprint);

        return $sql .= ')';
    }
1253157
protected function modifySrid(Blueprint $blueprint, Fluent $column)
    {
        if (! is_null($column->srid) && is_int($column->srid) && $column->srid > 0) {
            return ' srid '.$column->srid;
        }
    }
195440
protected static function paths(Blueprint $blueprint, $directory, $filename = null)
    {
        $yaml = file_exists($filename) ? file_get_contents($filename) : '';

        $yaml = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $yaml);

        $yaml = str_replace('%%CURRENT_DIRECTORY%%', $directory, $yaml);

        $result = Yaml::parse($yaml) ?: self::defaults();

        $blueprint->setTemplatePath($result['paths']['templates']);

        $blueprint->setCommandPath($result['paths']['commands']);

        $blueprint->setCommandNamespace($result['namespaces']['commands']);

        return $blueprint;
    }
1099103
public function meet($blueprint)
    {
        $parts = explode('.', $this->dependency);

        return $this->get($parts, $blueprint);
    }
503867
protected function addPrimaryKeys(Blueprint $blueprint)
    {
        $primary = $this->getCommandByName($blueprint, 'primary');

        if (! is_null($primary)) {
            $columns = $this->columnize($primary->columns);

            return ", primary key ({$columns})";
        }
    }