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 {
}
/**
* 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.
*
* @param Table $table
......
......@@ -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.
*
* @param Table $table
......
......@@ -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.
*
* @param Table $table
......
......@@ -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.
*
* @param Table $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.
*
* @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