@@ -169,7 +169,9 @@ async def rebase_branch(branch: str, context: InfrahubContext, send_events: bool
169169 )
170170
171171 await workflow .submit_workflow (workflow = DIFF_REFRESH_ALL , context = context , parameters = {"branch_name" : obj .name })
172- await workflow .submit_workflow (workflow = BRANCH_MIGRATE , context = context , parameters = {"branch_name" : obj .name })
172+ await workflow .submit_workflow (
173+ workflow = BRANCH_MIGRATE , context = context , parameters = {"branch" : obj .name , "send_events" : send_events }
174+ )
173175
174176 if not send_events :
175177 return
@@ -201,36 +203,38 @@ async def rebase_branch(branch: str, context: InfrahubContext, send_events: bool
201203
202204
203205@flow (name = "migrate_branch" , flow_run_name = "Apply migrations to branch {branch}" )
204- async def migrate_branch (branch_name : str , context : InfrahubContext ) -> None : # noqa: ARG001
206+ async def migrate_branch (branch : str , context : InfrahubContext , send_events : bool = True ) -> None :
207+ await add_tags (branches = [branch ])
208+
205209 db = await get_database ()
206210 log = get_run_logger ()
207211
208- branch = await registry . get_branch (db = db , branch = branch_name )
212+ obj = await Branch . get_by_name (db = db , name = branch )
209213
210- if branch .graph_version == GRAPH_VERSION :
211- log .info (f"Branch '{ branch .name } ' is up-to-date" )
214+ if obj .graph_version == GRAPH_VERSION :
215+ log .info (f"Branch '{ obj .name } ' is up-to-date" )
212216 return
213217
214- migration_runner = MigrationRunner (branch = branch )
218+ migration_runner = MigrationRunner (branch = obj )
215219 if not migration_runner .has_migrations ():
216- log .info (f"No migrations detected for branch '{ branch .name } '" )
220+ log .info (f"No migrations detected for branch '{ obj .name } '" )
217221 return
218222
219223 # Branch status will remain as so if the migration process fails
220224 # This will help user to know that a branch is in an invalid state to be used properly and that actions need to be taken
221- branch .status = BranchStatus .NEED_UPGRADE_REBASE
222- await branch .save (db = db )
225+ obj .status = BranchStatus .NEED_UPGRADE_REBASE
226+ await obj .save (db = db )
223227
224228 try :
225229 await migration_runner .run (db = db )
226230 except MigrationFailureError as exc :
227- log .error (f"Failed to migrate branch '{ branch .name } ': { exc .errors } " )
231+ log .error (f"Failed to migrate branch '{ obj .name } ': { exc .errors } " )
228232 return
229233
230- if branch .status == BranchStatus .NEED_UPGRADE_REBASE :
231- branch .status = BranchStatus .OPEN
232- branch .graph_version = GRAPH_VERSION
233- await branch .save (db = db )
234+ if obj .status == BranchStatus .NEED_UPGRADE_REBASE :
235+ obj .status = BranchStatus .OPEN
236+ obj .graph_version = GRAPH_VERSION
237+ await obj .save (db = db )
234238
235239
236240@flow (name = "branch-merge" , flow_run_name = "Merge branch {branch} into main" )
0 commit comments