Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
690e4a6d
Commit
690e4a6d
authored
3 years ago
by
Elmar Ludwig
Committed by
Jan-Hendrik Willms
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
store direction of migration for each branch separately, fixes #778
parent
a2fed7c5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/migrations/Migrator.php
+21
-21
21 additions, 21 deletions
lib/migrations/Migrator.php
with
21 additions
and
21 deletions
lib/migrations/Migrator.php
+
21
−
21
View file @
690e4a6d
...
...
@@ -115,9 +115,9 @@
class
Migrator
{
/**
* Direction of migration, either "up" or "down"
* Direction of migration, either "up" or "down"
for each branch
*
* @var
string
* @var
array
*/
private
$direction
;
...
...
@@ -205,14 +205,14 @@ class Migrator
$this
->
log
(
'Currently at version %d. Now migrating %s to %d.'
,
$this
->
schema_version
->
get
(
$target_branch
),
$this
->
direction
,
$this
->
direction
[
$target_branch
]
,
max
(
$this
->
target_versions
)
);
foreach
(
$migrations
as
$number
=>
$migration
)
{
list
(
$branch
,
$version
)
=
$this
->
migrationBranchAndVersion
(
$number
);
$action
=
$this
->
isUp
()
?
'Migrating'
:
'Reverting'
;
$action
=
$this
->
isUp
(
$branch
)
?
'Migrating'
:
'Reverting'
;
$migration
->
announce
(
"
{
$action
}
%s"
,
$number
);
if
(
$migration
->
description
())
{
...
...
@@ -221,16 +221,16 @@ class Migrator
}
$time_start
=
microtime
(
true
);
$migration
->
migrate
(
$this
->
direction
);
$migration
->
migrate
(
$this
->
direction
[
$branch
]
);
$action
=
$this
->
isUp
()
?
'Migrated'
:
'Reverted'
;
$action
=
$this
->
isUp
(
$branch
)
?
'Migrated'
:
'Reverted'
;
$this
->
log
(
''
);
$migration
->
announce
(
"
{
$action
}
in %ss"
,
round
(
microtime
(
true
)
-
$time_start
,
3
));
$this
->
log
(
''
);
$this
->
schema_version
->
set
(
$this
->
isDown
()
?
$version
-
1
:
$version
,
$branch
);
$this
->
schema_version
->
set
(
$this
->
isDown
(
$branch
)
?
$version
-
1
:
$version
,
$branch
);
$action
=
$this
->
isUp
()
?
'MIGRATE_UP'
:
'MIGRATE_DOWN'
;
$action
=
$this
->
isUp
(
$branch
)
?
'MIGRATE_UP'
:
'MIGRATE_DOWN'
;
StudipLog
::
log
(
$action
,
$number
,
$this
->
schema_version
->
getDomain
());
}
}
...
...
@@ -293,19 +293,17 @@ class Migrator
// Determine migration direction
foreach
(
$this
->
target_versions
as
$branch
=>
$version
)
{
if
(
$this
->
schema_version
->
get
(
$branch
)
<
$version
)
{
$this
->
direction
=
'up'
;
break
;
}
else
if
(
$version
<
$this
->
schema_version
->
get
(
$branch
))
{
$this
->
direction
=
'down'
;
break
;
if
(
$this
->
schema_version
->
get
(
$branch
)
<=
$version
)
{
$this
->
direction
[
$branch
]
=
'up'
;
}
else
{
$this
->
direction
[
$branch
]
=
'down'
;
}
}
// Sort migrations in correct order
uksort
(
$migrations
,
'version_compare'
);
if
(
!
$this
->
isUp
())
{
if
(
!
$this
->
isUp
(
$branch
))
{
$migrations
=
array_reverse
(
$migrations
,
true
);
}
...
...
@@ -347,10 +345,10 @@ class Migrator
if
(
!
isset
(
$this
->
target_versions
[
$branch
]))
{
return
false
;
}
else
if
(
$this
->
isUp
())
{
}
else
if
(
$this
->
isUp
(
$branch
))
{
return
$current_version
<
$version
&&
$version
<=
$this
->
target_versions
[
$branch
];
}
else
if
(
$this
->
isDown
())
{
}
else
if
(
$this
->
isDown
(
$branch
))
{
return
$current_version
>=
$version
&&
$version
>
$this
->
target_versions
[
$branch
];
}
...
...
@@ -361,21 +359,23 @@ class Migrator
/**
* Am I migrating up?
*
* @param string schema branch
* @return bool TRUE if migrating up, FALSE otherwise
*/
private
function
isUp
()
private
function
isUp
(
$branch
)
{
return
$this
->
direction
===
'up'
;
return
$this
->
direction
[
$branch
]
===
'up'
;
}
/**
* Am I migrating down?
*
* @param string schema branch
* @return bool TRUE if migrating down, FALSE otherwise
*/
private
function
isDown
()
private
function
isDown
(
$branch
)
{
return
$this
->
direction
===
'down'
;
return
$this
->
direction
[
$branch
]
===
'down'
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment