Versioning - long running workflow to switch to another workflow

We currently have a long running workflow(with 40k instances) and this is how we schedule our workflow to run monthly with a sleep timer.

      val workflow = Workflow.newContinueAsNewStub(FirstWorkflow::class.java)
        workflow.execute(object)

we want to switch to different workflow. we want all the 40K executions to switch to new workflow after versioning Continue-as-new. Will versioning like this suffices?

  val version = Workflow.getVersion("switchToSecondWorkflow", Workflow.DEFAULT_VERSION, 1)
        if (version == Workflow.DEFAULT_VERSION) {
            val workflow = Workflow.newContinueAsNewStub(FirstWorkflow::class.java)
        workflow.execute(object)
        } else {
           val workflow = Workflow.newContinueAsNewStub(SecondWorkflow::class.java)
        workflow.execute(object)
       }
1 Like

Yes, this looks good to me.