Skip to content

Commit 69c7d28

Browse files
authored
Merge pull request #1833 from mrrobot47/update/migration
Skip migration if first execution and minor fixes
2 parents 69b29e9 + 2850be3 commit 69c7d28

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

.github/workflows/test_and_build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
128128
- name: Install docker-compose
129129
run: |
130-
sudo curl -L https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
130+
sudo curl -L https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
131131
sudo chmod +x /usr/local/bin/docker-compose
132132
133133
- name: Install dependencies

migrations/db/20240502102550_easyengine_check_and_update_docker_one.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,26 @@
88

99
class CheckAndUpdateDockerOne extends Base {
1010

11+
public function __construct() {
12+
13+
if ( $this->is_first_execution ) {
14+
$this->skip_this_migration = true;
15+
}
16+
}
17+
1118
/**
1219
* Execute create table query for site and sitemeta table.
1320
*
1421
* @throws EE\ExitException
1522
*/
1623
public function up() {
1724

25+
if ( $this->skip_this_migration ) {
26+
EE::debug( 'Skipping migration as it is not needed.' );
27+
28+
return;
29+
}
30+
1831
EE::log( 'Checking Docker version.' );
1932
$docker_version = trim( EE::launch( 'docker version --format "{{.Server.Version}}"' )->stdout );
2033

@@ -45,7 +58,7 @@ public function up() {
4558
}
4659
$fs->copy( $docker_compose_path, $docker_compose_backup_path );
4760

48-
if ( version_compare( '1.29.2', $docker_compose_version, '>' ) ) {
61+
if ( version_compare( '1.29.2', $docker_compose_version, '!=' ) ) {
4962
EE::exec( "curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m) -o $docker_compose_path && chmod +x $docker_compose_path" );
5063
}
5164

php/EE/Migration/Containers.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static function start_container_migration() {
5858
}
5959

6060
if ( empty( $updated_images ) ) {
61+
6162
return;
6263
}
6364

@@ -131,13 +132,15 @@ public static function update_docker_compose() {
131132
$docker_compose_path = EE::launch( 'command -v docker-compose' )->stdout;
132133
$docker_compose_path = trim( $docker_compose_path );
133134
$docker_compose_backup_path = EE_BACKUP_DIR . '/docker-compose.backup';
134-
$fs = new Filesystem();
135-
if ( ! $fs->exists( EE_BACKUP_DIR ) ) {
136-
$fs->mkdir( EE_BACKUP_DIR );
137-
}
138-
$fs->copy( $docker_compose_path, $docker_compose_backup_path );
139135

140136
if ( version_compare( '2.27.0', $docker_compose_version, '>' ) ) {
137+
138+
$fs = new Filesystem();
139+
if ( ! $fs->exists( EE_BACKUP_DIR ) ) {
140+
$fs->mkdir( EE_BACKUP_DIR );
141+
}
142+
$fs->copy( $docker_compose_path, $docker_compose_backup_path );
143+
141144
EE::exec( "curl -L https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-$(uname -s)-$(uname -m) -o $docker_compose_path && chmod +x $docker_compose_path" );
142145
}
143146
}

php/EE/Runner.php

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ private function migrate() {
138138
$rsp->add_step( 'ee-db-migrations', 'EE\Migration\Executor::execute_migrations' );
139139
$rsp->add_step( 'ee-custom-container-migrations', 'EE\Migration\CustomContainerMigrations::execute_migrations' );
140140
$rsp->add_step( 'ee-docker-image-migrations', 'EE\Migration\Containers::start_container_migration' );
141+
$rsp->add_step( 'ee-update-docker-compose', 'EE\Migration\Containers::update_docker_compose' );
141142
return $rsp->execute();
142143
}
143144

0 commit comments

Comments
 (0)