Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
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
PSDI Army
yii2
Commits
d229cb82
Commit
d229cb82
authored
May 27, 2014
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
limit applied to migration
parent
5c96ba98
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
4 deletions
+40
-4
MigrateController.php
framework/console/controllers/MigrateController.php
+40
-4
No files found.
framework/console/controllers/MigrateController.php
View file @
d229cb82
...
@@ -204,7 +204,10 @@ class MigrateController extends Controller
...
@@ -204,7 +204,10 @@ class MigrateController extends Controller
*/
*/
public
function
actionDown
(
$limit
=
1
)
public
function
actionDown
(
$limit
=
1
)
{
{
if
(
$limit
===
'all'
)
{
$downAll
=
(
$limit
===
'all'
);
if
(
$downAll
)
{
$limit
=
null
;
$limit
=
null
;
}
else
{
}
else
{
$limit
=
(
int
)
$limit
;
$limit
=
(
int
)
$limit
;
...
@@ -214,11 +217,13 @@ class MigrateController extends Controller
...
@@ -214,11 +217,13 @@ class MigrateController extends Controller
}
}
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
if
(
empty
(
$migrations
))
{
if
(
empty
(
$migrations
))
{
echo
"No migration has been done before.
\n
"
;
echo
"No migration has been done before.
\n
"
;
return
self
::
EXIT_CODE_NORMAL
;
return
self
::
EXIT_CODE_NORMAL
;
}
}
$migrations
=
array_keys
(
$migrations
);
$migrations
=
array_keys
(
$migrations
);
$n
=
count
(
$migrations
);
$n
=
count
(
$migrations
);
...
@@ -249,6 +254,7 @@ class MigrateController extends Controller
...
@@ -249,6 +254,7 @@ class MigrateController extends Controller
* ~~~
* ~~~
* yii migrate/redo # redo the last applied migration
* yii migrate/redo # redo the last applied migration
* yii migrate/redo 3 # redo the last 3 applied migrations
* yii migrate/redo 3 # redo the last 3 applied migrations
* yii migrate/redo all # redo all migrations
* ~~~
* ~~~
*
*
* @param integer $limit the number of migrations to be redone. Defaults to 1,
* @param integer $limit the number of migrations to be redone. Defaults to 1,
...
@@ -259,17 +265,25 @@ class MigrateController extends Controller
...
@@ -259,17 +265,25 @@ class MigrateController extends Controller
*/
*/
public
function
actionRedo
(
$limit
=
1
)
public
function
actionRedo
(
$limit
=
1
)
{
{
$redoAll
=
(
$limit
===
'all'
);
if
(
$redoAll
)
{
$limit
=
null
;
}
else
{
$limit
=
(
int
)
$limit
;
$limit
=
(
int
)
$limit
;
if
(
$limit
<
1
)
{
if
(
$limit
<
1
)
{
throw
new
Exception
(
"The step argument must be greater than 0."
);
throw
new
Exception
(
"The step argument must be greater than 0."
);
}
}
}
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
if
(
empty
(
$migrations
))
{
if
(
empty
(
$migrations
))
{
echo
"No migration has been done before.
\n
"
;
echo
"No migration has been done before.
\n
"
;
return
self
::
EXIT_CODE_NORMAL
;
return
self
::
EXIT_CODE_NORMAL
;
}
}
$migrations
=
array_keys
(
$migrations
);
$migrations
=
array_keys
(
$migrations
);
$n
=
count
(
$migrations
);
$n
=
count
(
$migrations
);
...
@@ -410,7 +424,7 @@ class MigrateController extends Controller
...
@@ -410,7 +424,7 @@ class MigrateController extends Controller
* ~~~
* ~~~
* yii migrate/history # showing the last 10 migrations
* yii migrate/history # showing the last 10 migrations
* yii migrate/history 5 # showing the last 5 migrations
* yii migrate/history 5 # showing the last 5 migrations
* yii migrate/history
0
# showing the whole history
* yii migrate/history
all
# showing the whole history
* ~~~
* ~~~
*
*
* @param integer $limit the maximum number of migrations to be displayed.
* @param integer $limit the maximum number of migrations to be displayed.
...
@@ -418,8 +432,19 @@ class MigrateController extends Controller
...
@@ -418,8 +432,19 @@ class MigrateController extends Controller
*/
*/
public
function
actionHistory
(
$limit
=
10
)
public
function
actionHistory
(
$limit
=
10
)
{
{
$showAll
=
(
$limit
===
'all'
);
if
(
$showAll
)
{
$limit
=
null
;
}
else
{
$limit
=
(
int
)
$limit
;
$limit
=
(
int
)
$limit
;
if
(
$limit
<
1
)
{
throw
new
Exception
(
"The step argument must be greater than 0."
);
}
}
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
if
(
empty
(
$migrations
))
{
if
(
empty
(
$migrations
))
{
echo
"No migration has been done before.
\n
"
;
echo
"No migration has been done before.
\n
"
;
}
else
{
}
else
{
...
@@ -444,7 +469,7 @@ class MigrateController extends Controller
...
@@ -444,7 +469,7 @@ class MigrateController extends Controller
* ~~~
* ~~~
* yii migrate/new # showing the first 10 new migrations
* yii migrate/new # showing the first 10 new migrations
* yii migrate/new 5 # showing the first 5 new migrations
* yii migrate/new 5 # showing the first 5 new migrations
* yii migrate/new
0
# showing all new migrations
* yii migrate/new
all
# showing all new migrations
* ~~~
* ~~~
*
*
* @param integer $limit the maximum number of new migrations to be displayed.
* @param integer $limit the maximum number of new migrations to be displayed.
...
@@ -452,13 +477,24 @@ class MigrateController extends Controller
...
@@ -452,13 +477,24 @@ class MigrateController extends Controller
*/
*/
public
function
actionNew
(
$limit
=
10
)
public
function
actionNew
(
$limit
=
10
)
{
{
$showAll
=
(
$limit
===
'all'
);
if
(
$showAll
)
{
$limit
=
null
;
}
else
{
$limit
=
(
int
)
$limit
;
$limit
=
(
int
)
$limit
;
if
(
$limit
<
1
)
{
throw
new
Exception
(
"The step argument must be greater than 0."
);
}
}
$migrations
=
$this
->
getNewMigrations
();
$migrations
=
$this
->
getNewMigrations
();
if
(
empty
(
$migrations
))
{
if
(
empty
(
$migrations
))
{
echo
"No new migrations found. Your system is up-to-date.
\n
"
;
echo
"No new migrations found. Your system is up-to-date.
\n
"
;
}
else
{
}
else
{
$n
=
count
(
$migrations
);
$n
=
count
(
$migrations
);
if
(
$limit
>
0
&&
$n
>
$limit
)
{
if
(
$limit
&&
$n
>
$limit
)
{
$migrations
=
array_slice
(
$migrations
,
0
,
$limit
);
$migrations
=
array_slice
(
$migrations
,
0
,
$limit
);
echo
"Showing
$limit
out of
$n
new "
.
(
$n
===
1
?
'migration'
:
'migrations'
)
.
":
\n
"
;
echo
"Showing
$limit
out of
$n
new "
.
(
$n
===
1
?
'migration'
:
'migrations'
)
.
":
\n
"
;
}
else
{
}
else
{
...
...
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