updated routing to fix several issues.
This commit is contained in:
@@ -23,14 +23,14 @@ class MySQL extends Grammar {
|
||||
{
|
||||
$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. They will be added in separate commands.
|
||||
// First we will generate the base table creation statement. Other than incrementing
|
||||
// keys, no indexes will be created during the first creation of the table since
|
||||
// they will be added in separate commands.
|
||||
$sql = 'CREATE TABLE '.$this->wrap($table).' ('.$columns.')';
|
||||
|
||||
// MySQL supports various "engines" for database tables. If an engine
|
||||
// was specified by the developer, we will set it after adding the
|
||||
// columns the table creation statement.
|
||||
// MySQL supports various "engines" for database tables. If an engine ws specified
|
||||
// by the developer, we will set it after adding the columns the table creation
|
||||
// statement. Some engines support extra indexes.
|
||||
if ( ! is_null($table->engine))
|
||||
{
|
||||
$sql .= ' ENGINE = '.$table->engine;
|
||||
@@ -50,9 +50,9 @@ class MySQL extends Grammar {
|
||||
{
|
||||
$columns = $this->columns($table);
|
||||
|
||||
// Once we the array of column definitions, we need to add "add"
|
||||
// to the front of each definition, then we'll concatenate the
|
||||
// definitions using commas like normal and generate the SQL.
|
||||
// Once we the array of column definitions, we need to add "add" to the front
|
||||
// of each definition, then we'll concatenate the definitions using commas
|
||||
// like normal and generate the SQL.
|
||||
$columns = implode(', ', array_map(function($column)
|
||||
{
|
||||
return 'ADD '.$column;
|
||||
@@ -77,7 +77,7 @@ class MySQL extends Grammar {
|
||||
// Each of the data type's have their own definition creation method,
|
||||
// which is responsible for creating the SQL for the type. This lets
|
||||
// us to keep the syntax easy and fluent, while translating the
|
||||
// types to the types used by the database.
|
||||
// types to the correct types.
|
||||
$sql = $this->wrap($column).' '.$this->type($column);
|
||||
|
||||
$elements = array('nullable', 'defaults', 'incrementer');
|
||||
@@ -223,9 +223,9 @@ class MySQL extends Grammar {
|
||||
{
|
||||
$columns = array_map(array($this, 'wrap'), $command->columns);
|
||||
|
||||
// Once we the array of column names, we need to add "drop" to the
|
||||
// front of each column, then we'll concatenate the columns using
|
||||
// commas and generate the alter statement SQL.
|
||||
// Once we the array of column names, we need to add "drop" to the front
|
||||
// of each column, then we'll concatenate the columns using commas and
|
||||
// generate the alter statement SQL.
|
||||
$columns = implode(', ', array_map(function($column)
|
||||
{
|
||||
return 'DROP '.$column;
|
||||
|
||||
@@ -16,9 +16,9 @@ class Postgres extends Grammar {
|
||||
{
|
||||
$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. They will be added in separate commands.
|
||||
// First we will generate the base table creation statement. Other than incrementing
|
||||
// keys, no indexes will be created during the first creation of the table since
|
||||
// they will be added in separate commands.
|
||||
$sql = 'CREATE TABLE '.$this->wrap($table).' ('.$columns.')';
|
||||
|
||||
return $sql;
|
||||
@@ -35,9 +35,9 @@ class Postgres extends Grammar {
|
||||
{
|
||||
$columns = $this->columns($table);
|
||||
|
||||
// Once we the array of column definitions, we'll add "add column"
|
||||
// to the front of each definition, then we'll concatenate the
|
||||
// definitions using commas like normal and generate the SQL.
|
||||
// Once we the array of column definitions, we need to add "add" to the front
|
||||
// of each definition, then we'll concatenate the definitions using commas
|
||||
// like normal and generate the SQL.
|
||||
$columns = implode(', ', array_map(function($column)
|
||||
{
|
||||
return 'ADD COLUMN '.$column;
|
||||
@@ -114,10 +114,9 @@ class Postgres extends Grammar {
|
||||
*/
|
||||
protected function incrementer(Table $table, Fluent $column)
|
||||
{
|
||||
// We don't actually need to specify an "auto_increment" keyword since
|
||||
// we handle the auto-increment definition in the type definition for
|
||||
// integers by changing the type to "serial", which is a convenient
|
||||
// notational short-cut provided by Postgres.
|
||||
// We don't actually need to specify an "auto_increment" keyword since we
|
||||
// handle the auto-increment definition in the type definition for
|
||||
// integers by changing the type to "serial".
|
||||
if ($column->type == 'integer' and $column->increment)
|
||||
{
|
||||
return ' PRIMARY KEY';
|
||||
@@ -218,9 +217,9 @@ class Postgres extends Grammar {
|
||||
{
|
||||
$columns = array_map(array($this, 'wrap'), $command->columns);
|
||||
|
||||
// Once we the array of column names, we need to add "drop" to the
|
||||
// front of each column, then we'll concatenate the columns using
|
||||
// commas and generate the alter statement SQL.
|
||||
// Once we the array of column names, we need to add "drop" to the front
|
||||
// of each column, then we'll concatenate the columns using commas and
|
||||
// generate the alter statement SQL.
|
||||
$columns = implode(', ', array_map(function($column)
|
||||
{
|
||||
return 'DROP COLUMN '.$column;
|
||||
|
||||
@@ -16,26 +16,22 @@ class SQLite extends Grammar {
|
||||
{
|
||||
$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. They will be added in separate commands.
|
||||
// First we will generate the base table creation statement. Other than incrementing
|
||||
// keys, no indexes will be created during the first creation of the table since
|
||||
// they will be added in separate commands.
|
||||
$sql = 'CREATE TABLE '.$this->wrap($table).' ('.$columns;
|
||||
|
||||
// SQLite does not allow adding a primary key as a command apart from
|
||||
// when the table is initially created, so we'll need to sniff out
|
||||
// any primary keys here and add them to the table.
|
||||
//
|
||||
// Because of this, this class does not have the typical "primary"
|
||||
// method as it would be pointless since the primary keys can't
|
||||
// be set on anything but the table creation statement.
|
||||
// SQLite does not allow adding a primary key as a command apart from the creation
|
||||
// of the table, so we'll need to sniff out any primary keys here and add them to
|
||||
// the table now during this command.
|
||||
$primary = array_first($table->commands, function($key, $value)
|
||||
{
|
||||
return $value->type == 'primary';
|
||||
});
|
||||
|
||||
// If we found primary key in the array of commands, we'll create
|
||||
// the SQL for the key addition and append it to the SQL table
|
||||
// creation statement for the schema table.
|
||||
// If we found primary key in the array of commands, we'll create the SQL for
|
||||
// the key addition and append it to the SQL table creation statement for
|
||||
// the schema table so the index is properly generated.
|
||||
if ( ! is_null($primary))
|
||||
{
|
||||
$columns = $this->columnize($primary->columns);
|
||||
@@ -57,18 +53,18 @@ class SQLite extends Grammar {
|
||||
{
|
||||
$columns = $this->columns($table);
|
||||
|
||||
// Once we have an array of all of the column definitions, we need to
|
||||
// spin through each one and prepend "ADD COLUMN" to each of them,
|
||||
// which is the syntax used by SQLite when adding columns.
|
||||
// Once we the array of column definitions, we need to add "add" to the front
|
||||
// of each definition, then we'll concatenate the definitions using commas
|
||||
// like normal and generate the SQL.
|
||||
$columns = array_map(function($column)
|
||||
{
|
||||
return 'ADD COLUMN '.$column;
|
||||
|
||||
}, $columns);
|
||||
|
||||
// SQLite only allows one column to be added in an ALTER statement,
|
||||
// so we will create an array of statements and return them all to
|
||||
// the schema manager, which will execute each one.
|
||||
// SQLite only allows one column to be added in an ALTER statement, so we
|
||||
// will create an array of statements and return them all to the schema
|
||||
// manager, which will execute each one separately.
|
||||
foreach ($columns as $column)
|
||||
{
|
||||
$sql[] = 'ALTER TABLE '.$this->wrap($table).' '.$column;
|
||||
|
||||
@@ -23,9 +23,9 @@ class SQLServer extends Grammar {
|
||||
{
|
||||
$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. They will be added in separate commands.
|
||||
// First we will generate the base table creation statement. Other than incrementing
|
||||
// keys, no indexes will be created during the first creation of the table since
|
||||
// they will be added in separate commands.
|
||||
$sql = 'CREATE TABLE '.$this->wrap($table).' ('.$columns.')';
|
||||
|
||||
return $sql;
|
||||
@@ -42,9 +42,9 @@ class SQLServer extends Grammar {
|
||||
{
|
||||
$columns = $this->columns($table);
|
||||
|
||||
// Once we the array of column definitions, we need to add "add"
|
||||
// to the front of each definition, then we'll concatenate the
|
||||
// definitions using commas like normal and generate the SQL.
|
||||
// Once we the array of column definitions, we need to add "add" to the front
|
||||
// of each definition, then we'll concatenate the definitions using commas
|
||||
// like normal and generate the SQL.
|
||||
$columns = implode(', ', array_map(function($column)
|
||||
{
|
||||
return 'ADD '.$column;
|
||||
@@ -166,18 +166,18 @@ class SQLServer extends Grammar {
|
||||
{
|
||||
$columns = $this->columnize($command->columns);
|
||||
|
||||
// SQL Server requires the creation of a full-text "catalog" before
|
||||
// creating a full-text index, so we'll first create the catalog
|
||||
// then add another statement for the index. The catalog will
|
||||
// be updated automatically by the server.
|
||||
$table = $this->wrap($table);
|
||||
|
||||
// SQL Server requires the creation of a full-text "catalog" before creating
|
||||
// a full-text index, so we'll first create the catalog then add another
|
||||
// separate statement for the index.
|
||||
$sql[] = "CREATE FULLTEXT CATALOG {$command->catalog}";
|
||||
|
||||
$create = "CREATE FULLTEXT INDEX ON ".$this->wrap($table)." ({$columns}) ";
|
||||
$create = "CREATE FULLTEXT INDEX ON ".$table." ({$columns}) ";
|
||||
|
||||
// Full-text indexes must specify a unique, non-nullable column as
|
||||
// the index "key" and this should have been created manually by
|
||||
// the developer in a separate column addition command, so we
|
||||
// can just specify it in this statement.
|
||||
// Full-text indexes must specify a unique, non-null column as the index
|
||||
// "key" and this should have been created manually by the developer in
|
||||
// a separate column addition command.
|
||||
$sql[] = $create .= "KEY INDEX {$command->key} ON {$command->catalog}";
|
||||
|
||||
return $sql;
|
||||
@@ -235,9 +235,9 @@ class SQLServer extends Grammar {
|
||||
{
|
||||
$columns = array_map(array($this, 'wrap'), $command->columns);
|
||||
|
||||
// Once we the array of column names, we need to add "drop" to the
|
||||
// front of each column, then we'll concatenate the columns using
|
||||
// commas and generate the alter statement SQL.
|
||||
// Once we the array of column names, we need to add "drop" to the front
|
||||
// of each column, then we'll concatenate the columns using commas and
|
||||
// generate the alter statement SQL.
|
||||
$columns = implode(', ', array_map(function($column)
|
||||
{
|
||||
return 'DROP '.$column;
|
||||
|
||||
Reference in New Issue
Block a user