Commit 7d4a346f by Colin Viebrock

Adding Schema::rename('oldtable','newtable') support

Signed-off-by: Colin Viebrock <colin@viebrock.ca>
parent 2a49787e
...@@ -213,6 +213,18 @@ class MySQL extends Grammar { ...@@ -213,6 +213,18 @@ class MySQL extends Grammar {
} }
/** /**
* Generate the SQL statement for a rename table command.
*
* @param Table $table
* @param Fluent $command
* @return string
*/
public function rename(Table $table, Fluent $command)
{
return 'RENAME TABLE '.$this->wrap($table).' TO '.$this->wrap($command->name);
}
/**
* Generate the SQL statement for a drop table command. * Generate the SQL statement for a drop table command.
* *
* @param Table $table * @param Table $table
......
...@@ -199,6 +199,18 @@ class Postgres extends Grammar { ...@@ -199,6 +199,18 @@ class Postgres extends Grammar {
} }
/** /**
* Generate the SQL statement for a rename table command.
*
* @param Table $table
* @param Fluent $command
* @return string
*/
public function rename(Table $table, Fluent $command)
{
return 'ALTER TABLE '.$this->wrap($table).' RENAME TO '.$this->wrap($command->name);
}
/**
* Generate the SQL statement for a drop table command. * Generate the SQL statement for a drop table command.
* *
* @param Table $table * @param Table $table
...@@ -302,7 +314,7 @@ class Postgres extends Grammar { ...@@ -302,7 +314,7 @@ class Postgres extends Grammar {
*/ */
public function drop_foreign(Table $table, Fluent $command) public function drop_foreign(Table $table, Fluent $command)
{ {
return $this->drop_constraint($table, $command); return $this->drop_constraint($table, $command);
} }
/** /**
......
...@@ -202,6 +202,18 @@ class SQLite extends Grammar { ...@@ -202,6 +202,18 @@ class SQLite extends Grammar {
} }
/** /**
* Generate the SQL statement for a rename table command.
*
* @param Table $table
* @param Fluent $command
* @return string
*/
public function rename(Table $table, Fluent $command)
{
return 'ALTER TABLE '.$this->wrap($table).' RENAME TO '.$this->wrap($command->name);
}
/**
* Generate the SQL statement for a drop table command. * Generate the SQL statement for a drop table command.
* *
* @param Table $table * @param Table $table
......
...@@ -213,6 +213,18 @@ class SQLServer extends Grammar { ...@@ -213,6 +213,18 @@ class SQLServer extends Grammar {
} }
/** /**
* Generate the SQL statement for a rename table command.
*
* @param Table $table
* @param Fluent $command
* @return string
*/
public function rename(Table $table, Fluent $command)
{
return 'ALTER TABLE '.$this->wrap($table).' RENAME TO '.$this->wrap($command->name);
}
/**
* Generate the SQL statement for a drop table command. * Generate the SQL statement for a drop table command.
* *
* @param Table $table * @param Table $table
...@@ -320,7 +332,7 @@ class SQLServer extends Grammar { ...@@ -320,7 +332,7 @@ class SQLServer extends Grammar {
*/ */
public function drop_foreign(Table $table, Fluent $command) public function drop_foreign(Table $table, Fluent $command)
{ {
return $this->drop_constraint($table, $command); return $this->drop_constraint($table, $command);
} }
/** /**
......
...@@ -143,6 +143,17 @@ class Table { ...@@ -143,6 +143,17 @@ class Table {
} }
/** /**
* Rename the database table.
*
* @param string $name
* @return Fluent
*/
public function rename($name)
{
return $this->command(__FUNCTION__, compact('name'));
}
/**
* Drop the database table. * Drop the database table.
* *
* @return Fluent * @return Fluent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment