Skip to content

Commit ad7c126

Browse files
committed
Add migration steps to update site's docker-compose.yml
1 parent 8538289 commit ad7c126

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

migrations/container/20181225063950_service-command_change_global_service_container_names.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,44 @@ public function up() {
128128
null
129129
);
130130

131+
/**
132+
* Update site's docker-compose.yml
133+
*/
134+
$db = new \EE_DB();
135+
$sites = ( $db->table( 'sites' )->all() );
136+
137+
foreach ( $sites as $site ) {
138+
$docker_yml = $site['site_fs_path'] . '/docker-compose.yml';
139+
$docker_yml_backup = EE_BACKUP_DIR . '/' . $site['site_url'] . '/docker-compose.yml.backup';
140+
$ee_site_object = SiteContainers::get_site_object( $site['site_type'] );
141+
142+
self::$rsp->add_step(
143+
"take-${site['site_url']}-docker-compose-backup",
144+
'EE\Migration\SiteContainers::backup_restore',
145+
'EE\Migration\SiteContainers::backup_restore',
146+
[ $docker_yml, $docker_yml_backup ],
147+
[ $docker_yml_backup, $docker_yml ]
148+
);
149+
150+
self::$rsp->add_step(
151+
"generate-${site['site_url']}-docker-compose",
152+
'EE\Migration\SiteContainers::generate_site_docker_compose_file',
153+
null,
154+
[ $site, $ee_site_object ],
155+
null
156+
);
157+
158+
if ( $site['site_enabled'] ) {
159+
self::$rsp->add_step(
160+
"upgrade-${site['site_url']}-containers",
161+
'EE\Migration\SiteContainers::enable_default_containers',
162+
null,
163+
[ $site, $ee_site_object ],
164+
null
165+
);
166+
}
167+
}
168+
131169
if ( ! self::$rsp->execute() ) {
132170
throw new \Exception( 'Unable run change-global-service-container-name migrations.' );
133171
}

0 commit comments

Comments
 (0)