Compile a foreign key command.

@param  \Illuminate\Database\Schema\Blueprint  $blueprint
@param  \Illuminate\Support\Fluent  $command
@return string
482781
public function compileForeign(Blueprint $blueprint, Fluent $command)
    {
        $sql = parent::compileForeign($blueprint, $command);

        if (! is_null($command->deferrable)) {
            $sql .= $command->deferrable ? ' deferrable' : ' not deferrable';
        }

        if ($command->deferrable && ! is_null($command->initiallyImmediate)) {
            $sql .= $command->initiallyImmediate ? ' initially immediate' : ' initially deferred';
        }

        if (! is_null($command->notValid)) {
            $sql .= ' not valid';
        }

        return $sql;
    }
49391
public function compileAdd(Blueprint $blueprint, Fluent $command)
    {
        return sprintf('alter table %s add %s',
            $this->wrapTable($blueprint),
            implode(', ', $this->getColumns($blueprint))
        );
    }
1166389
protected function modifyNullable(Blueprint $blueprint, Fluent $column)
    {
        if (is_null($column->virtualAs) && is_null($column->storedAs)) {
            return $column->nullable ? ' null' : ' not null';
        }
    }
1046589
public function compileCreate(Blueprint $blueprint, Fluent $command)
	{
		$columns = implode(', ', $this->getColumns($blueprint));

		$sql = $blueprint->temporary ? 'create temporary' : 'create';

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

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

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

            return ", primary key ({$columns})";
        }
    }
1124326
public function compilePrimary(Blueprint $blueprint, Fluent $command)
    {
        $columns = $this->columnize($command->columns);

        return 'alter table '.$this->wrapTable($blueprint)." add primary key ({$columns})";
    }
540193
private function prepareSingletonBindingClosure($id, $blueprint, $dependencies): Closure
    {
        $binding = $this->bindings[$id];
        $instance = $blueprint;

        if ($blueprint instanceof ReflectionClass) {
            foreach ($dependencies as $key => $dependency) {
                if ($dependency instanceof Closure) {
                    $dependencies[$key] = $dependency();
                }
            }
            $instance = $blueprint->newInstanceArgs($dependencies);
        }
        if ($blueprint instanceof Closure) {
            $instance = $blueprint();
        }
        // If blueprint is supplied as a class name.
        if (is_string($blueprint)) {
            $instance = new $blueprint;
        }
        // Singletons won't need these any longer so free up the memory.
        unset($binding['dependencies'], $binding['reflector']);

        return $this->cache[$id] = function () use ($instance) {
            return $instance;
        };
    }
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))
        );
    }
10477
protected function compileGeometry(Blueprint $blueprint, Fluent $command)
    {

        $dimensions = $command->dimensions ?: 2;
        $typmod = $command->typmod ? 'true' : 'false';
        $srid = $command->srid ?: 4326;

        return sprintf(
            "SELECT AddGeometryColumn('%s', '%s', %d, '%s', %d, %s)",
            $blueprint->getTable(),
            $command->column,
            $srid,
            strtoupper($command->type),
            $dimensions,
            $typmod
        );
    }
372256
public function createAutoIncrementObjects(Blueprint $blueprint, $table)
    {
        $column = $this->getQualifiedAutoIncrementColumn($blueprint);

        // return if no qualified AI column
        if (is_null($column)) {
            return;
        }

        $col   = $column->name;
        $start = isset($column->start) ? $column->start : 1;

        // get table prefix
        $prefix = $this->connection->getTablePrefix();

        // create sequence for auto increment
        $sequenceName = $this->createObjectName($prefix, $table, $col, 'seq');
        $this->sequence->create($sequenceName, $start, $column->nocache);

        // create trigger for auto increment work around
        $triggerName = $this->createObjectName($prefix, $table, $col, 'trg');
        $this->trigger->autoIncrement($prefix . $table, $col, $triggerName, $sequenceName);
    }
1200207
public function compileDropPrimary(Blueprint $blueprint, Fluent $command)
	{
		$table = $blueprint->getTable();

		$index = $this->wrap("{$table}_pkey");

		return 'alter table '.$this->wrapTable($blueprint)." drop constraint {$index}";
	}
200826
public function compileDropPrimary(Blueprint $blueprint, Fluent $command)
    {
        $index = $this->wrap($command->index);

        return "alter table {$this->wrapTable($blueprint)} drop constraint {$index}";
    }
950365
private function validateEvent(Blueprint $blueprint)
    {
        if (! in_array(strtolower($blueprint->event), $this->events)) {
            throw new InvalidArgumentException("Cannot use {$blueprint->event} as trigger event.");
        }

        return $blueprint->event;
    }
196311
public function toCypher(ConnectionInterface $connection, IlluminateSchemaGrammar $grammar)
    {
        $statements = [];

        // Each type of command has a corresponding compiler function on the schema
        // grammar which is used to build the necessary SQL statements to build
        // the blueprint element, so we'll just call that compilers function.
        foreach ($this->commands as $command)
        {
            $method = 'compile'.ucfirst($command->name);

            if (method_exists($grammar, $method))
            {
                if ( ! is_null($cypher = $grammar->$method($this, $command, $connection)))
                {
                    $statements = array_merge($statements, (array) $cypher);
                }
            }
        }

        return $statements;
    }
1302040
public function compileDropColumn(Blueprint $blueprint, Fluent $command)
    {
        $columns = $this->wrapArray($command->columns);

        return 'alter table '.$this->wrapTable($blueprint).' drop column '.implode(', ', $columns);
    }
1203351
private function fluentComments(OracleBlueprint $blueprint)
    {
        foreach ($blueprint->getColumns() as $column) {
            if (isset($column['comment'])) {
                $this->commentColumn($blueprint->getTable(), $column['name'], $column['comment']);
            }
        }
    }
120797
protected function resolveForeignTable($table, Blueprint $blueprint)
    {
        $referenced = explode('.', $table);

        if (count($referenced) == 2) {
            return [
                'database' => current($referenced),
                'table' => next($referenced),
            ];
        }

        return [
            'database' => $blueprint->schema(),
            'table' => current($referenced),
        ];
    }