Compile a primary key command.

@param  \Illuminate\Database\Schema\Blueprint $blueprint
@param  \Illuminate\Support\Fluent $command
@return string
512545
public function compilePrimary(Blueprint $blueprint, Fluent $command)
    {
        $create = $this->getCommandByName($blueprint, 'create');

        if (is_null($create)) {
            $columns = $this->columnize($command->columns);

            $table = $this->wrapTable($blueprint);

            return "alter table {$table} add constraint {$command->index} primary key ({$columns})";
        }
    }
263263
public function compileGeometrycollection(Blueprint $blueprint, Fluent $command)
    {
        $command->type = 'GEOMETRYCOLLECTION';

        return $this->compileGeometry($blueprint, $command);
    }
81491
protected function addModifiers($sql, Blueprint $blueprint, Fluent $column)
    {
        foreach ($this->modifiers as $modifier) {
            if (method_exists($this, $method = "modify{$modifier}")) {
                $sql .= $this->{$method}($blueprint, $column);
            }
        }

        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 + ')'
773820
public function primary(Table $table, Fluent $command)
		{
			return $this->key($table, $command->name(null), 'PRIMARY KEY');
		}
249351
protected function compileCreateEncoding( $sql, Connection $connection, Blueprint $blueprint )
	{
		if ( isset( $blueprint->charset ) )
		{
			$sql .= ' default character set ' . $blueprint->charset;
		}
		elseif ( !is_null( $charset = $connection->getConfig( 'charset' ) ) )
		{
			$sql .= ' default character set ' . $charset;
		}

		if ( isset( $blueprint->collation ) )
		{
			$sql .= ' collate ' . $blueprint->collation;
		}
		elseif ( !is_null( $collation = $connection->getConfig( 'collation' ) ) )
		{
			$sql .= ' collate ' . $collation;
		}

		return $sql;
	}
509976
public function compileDropIfExists(Blueprint $blueprint, Fluent $command)
    {
        return sprintf('if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = %s) drop table %s',
            "'".str_replace("'", "''", $this->getTablePrefix().$blueprint->getTable())."'",
            $this->wrapTable($blueprint)
        );
    }
558556
public function addItemsFromBlueprint(Blueprint $blueprint) {
        foreach($blueprint->getToolbarItems() as $item) {
            $this->addItem($item);
        }
    }
755044
public function create(Table $table, Fluent $command)
		{
			$columns = implode(', ', $this->columns($table));

			// First we will generate the base table creation statement. Other than auto
			// incrementing keys, no indexes will be created during the first creation
			// of the table as they're added in separate commands.
			$sql = 'CREATE TABLE ' . $this->wrap($table) . ' (' . $columns . ')';

			if (!is_null($table->engine)) {
				$sql .= ' ENGINE = ' . $table->engine;
			}

			return $sql;
		}
202897
protected function modifyAfter(Blueprint $blueprint, Fluent $column)
    {
        if (! is_null($column->after)) {
            return ' after '.$this->wrap($column->after);
        }
    }
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;
	}
1244170
public function compileDropColumn(Blueprint $blueprint, Fluent $command) {
        $table  = $this->wrapTable($blueprint);
        // @TODO: always one column; or more?
        $column = $command->columns[0];

        // @TODO: changed syntax; is there a better writing
        return 'DROP PROPERTY ' . $table . '.' . $column . ' IF EXISTS';
    }
47349
protected function compileIndexKey($operation, Blueprint $blueprint, Fluent $command)
    {
        $label = $this->wrapLabel($blueprint);
        $property = $this->propertize($command->property);

        return "$operation INDEX ON $label($property)";
    }
527853
public function compileForeign(Blueprint $blueprint, Fluent $command)
    {
        // We need to prepare several of the elements of the foreign key definition
        // before we can create the SQL, such as wrapping the tables and convert
        // an array of columns to comma-delimited strings for the SQL queries.
        $sql = sprintf('alter table %s add constraint %s ',
            $this->wrapTable($blueprint),
            $this->wrap($command->index)
        );

        // Once we have the initial portion of the SQL statement we will add on the
        // key name, table name, and referenced columns. These will complete the
        // main portion of the SQL statement and this SQL will almost be done.
        $sql .= sprintf('foreign key (%s) references %s (%s)',
            $this->columnize($command->columns),
            $this->wrapTable($command->on),
            $this->columnize((array) $command->references)
        );

        // Once we have the basic foreign key creation statement constructed we can
        // build out the syntax for what should happen on an update or delete of
        // the affected columns, which will get something like "cascade", etc.
        if (! is_null($command->onDelete)) {
            $sql .= " on delete {$command->onDelete}";
        }

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

        return $sql;
    }
1229122
public function compileAdd(Blueprint $blueprint, Fluent $command)
    {
        $columns = $this->prefixArray('add column', $this->getColumns($blueprint));

        return collect($columns)->map(function ($column) use ($blueprint) {
            return 'alter table '.$this->wrapTable($blueprint).' '.$column;
        })->all();
    }
285131
protected function compileCreateEngine($sql, Connection $connection, Blueprint $blueprint)
    {
        if (isset($blueprint->engine)) {
            return $sql.' engine = '.$blueprint->engine;
        } elseif (! is_null($engine = $connection->getConfig('engine'))) {
            return $sql.' engine = '.$engine;
        }

        return $sql;
    }
1180734
public function toDSL(Grammar $grammar)
    {
        $statements = [];

        // Each type of command has a corresponding compiler function on the schema
        // grammar which is used to build the necessary DSL 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($dsl = $grammar->$method($this, $command))) {
                    $statements = array_merge($statements, (array) $dsl);
                }
            }
        }

        return $statements;
    }