@@ -123,6 +123,42 @@ def migrate_project(
123123 if not is_renku_project ():
124124 return False , template_updated , docker_updated
125125
126+ n_migrations_executed = 0
127+
128+ if not skip_migrations :
129+ project_version = project_version or get_project_version ()
130+
131+ migration_context = MigrationContext (
132+ strict = strict , type = migration_type , preserve_identifiers = preserve_identifiers
133+ )
134+
135+ version = 1
136+ for version , path in get_migrations ():
137+ if max_version and version > max_version :
138+ break
139+ if version > project_version :
140+ module = importlib .import_module (path )
141+ module_name = module .__name__ .split ("." )[- 1 ]
142+ communication .echo (f"Applying migration { module_name } ..." )
143+ try :
144+ module .migrate (migration_context )
145+ except (Exception , BaseException ) as e :
146+ raise MigrationError ("Couldn't execute migration" ) from e
147+ n_migrations_executed += 1
148+
149+ if not is_using_temporary_datasets_path ():
150+ if n_migrations_executed > 0 :
151+ project_context .project .version = str (version )
152+ project_gateway .update_project (project_context .project )
153+
154+ communication .echo (f"Successfully applied { n_migrations_executed } migrations." )
155+
156+ _remove_untracked_renku_files (metadata_path = project_context .metadata_path )
157+
158+ # we might not have been able to tell if a docker update is possible due to outstanding migrations.
159+ # so we need to check again here.
160+ skip_docker_update |= not is_docker_update_possible ()
161+
126162 try :
127163 project = project_context .project
128164 except ValueError :
@@ -155,36 +191,6 @@ def migrate_project(
155191 except Exception as e :
156192 raise DockerfileUpdateError ("Couldn't update renku version in Dockerfile." ) from e
157193
158- if skip_migrations :
159- return False , template_updated , docker_updated
160-
161- project_version = project_version or get_project_version ()
162- n_migrations_executed = 0
163-
164- migration_context = MigrationContext (strict = strict , type = migration_type , preserve_identifiers = preserve_identifiers )
165-
166- version = 1
167- for version , path in get_migrations ():
168- if max_version and version > max_version :
169- break
170- if version > project_version :
171- module = importlib .import_module (path )
172- module_name = module .__name__ .split ("." )[- 1 ]
173- communication .echo (f"Applying migration { module_name } ..." )
174- try :
175- module .migrate (migration_context )
176- except (Exception , BaseException ) as e :
177- raise MigrationError ("Couldn't execute migration" ) from e
178- n_migrations_executed += 1
179- if not is_using_temporary_datasets_path ():
180- if n_migrations_executed > 0 :
181- project_context .project .version = str (version )
182- project_gateway .update_project (project_context .project )
183-
184- communication .echo (f"Successfully applied { n_migrations_executed } migrations." )
185-
186- _remove_untracked_renku_files (metadata_path = project_context .metadata_path )
187-
188194 return n_migrations_executed != 0 , template_updated , docker_updated
189195
190196
0 commit comments