Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
38234c61
Commit
38234c61
authored
Jul 19, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #480 from cviebrock/schema-rename
Schema::rename('oldtable','newtable') support
parents
c937f98b
ef5ab30c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
2 deletions
+80
-2
schema.php
laravel/database/schema.php
+19
-0
mysql.php
laravel/database/schema/grammars/mysql.php
+12
-0
postgres.php
laravel/database/schema/grammars/postgres.php
+13
-1
sqlite.php
laravel/database/schema/grammars/sqlite.php
+12
-0
sqlserver.php
laravel/database/schema/grammars/sqlserver.php
+13
-1
table.php
laravel/database/schema/table.php
+11
-0
No files found.
laravel/database/schema.php
View file @
38234c61
...
...
@@ -40,6 +40,25 @@ class Schema {
return
static
::
execute
(
$table
);
}
/**
* Rename a database table in the schema.
*
* @param string $table
* @param string $name
* @return void
*/
public
static
function
rename
(
$table
,
$new_name
)
{
$table
=
new
Schema\Table
(
$table
);
// To indicate that the table needs to be renamed, we will run the
// "rename" command on the table instance and pass the instance to
// the execute method as calling a Closure isn't needed.
$table
->
rename
(
$new_name
);
return
static
::
execute
(
$table
);
}
/**
* Drop a database table from the schema.
*
...
...
laravel/database/schema/grammars/mysql.php
View file @
38234c61
...
...
@@ -212,6 +212,18 @@ class MySQL extends Grammar {
return
'ALTER TABLE '
.
$this
->
wrap
(
$table
)
.
" ADD
{
$type
}
{
$name
}
(
{
$keys
}
)"
;
}
/**
* 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.
*
...
...
laravel/database/schema/grammars/postgres.php
View file @
38234c61
...
...
@@ -198,6 +198,18 @@ class Postgres extends Grammar {
return
$create
.
" INDEX
{
$command
->
name
}
ON "
.
$this
->
wrap
(
$table
)
.
" (
{
$columns
}
)"
;
}
/**
* 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.
*
...
...
@@ -302,7 +314,7 @@ class Postgres extends Grammar {
*/
public
function
drop_foreign
(
Table
$table
,
Fluent
$command
)
{
return
$this
->
drop_constraint
(
$table
,
$command
);
return
$this
->
drop_constraint
(
$table
,
$command
);
}
/**
...
...
laravel/database/schema/grammars/sqlite.php
View file @
38234c61
...
...
@@ -201,6 +201,18 @@ class SQLite extends Grammar {
return
$create
.
" INDEX
{
$command
->
name
}
ON "
.
$this
->
wrap
(
$table
)
.
" (
{
$columns
}
)"
;
}
/**
* 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.
*
...
...
laravel/database/schema/grammars/sqlserver.php
View file @
38234c61
...
...
@@ -212,6 +212,18 @@ class SQLServer extends Grammar {
return
$create
.
" INDEX
{
$command
->
name
}
ON "
.
$this
->
wrap
(
$table
)
.
" (
{
$columns
}
)"
;
}
/**
* 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.
*
...
...
@@ -320,7 +332,7 @@ class SQLServer extends Grammar {
*/
public
function
drop_foreign
(
Table
$table
,
Fluent
$command
)
{
return
$this
->
drop_constraint
(
$table
,
$command
);
return
$this
->
drop_constraint
(
$table
,
$command
);
}
/**
...
...
laravel/database/schema/table.php
View file @
38234c61
...
...
@@ -144,6 +144,17 @@ class Table {
return
$this
->
command
(
$type
,
compact
(
'name'
,
'columns'
));
}
/**
* Rename the database table.
*
* @param string $name
* @return Fluent
*/
public
function
rename
(
$name
)
{
return
$this
->
command
(
__FUNCTION__
,
compact
(
'name'
));
}
/**
* Drop the database table.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment