onflow / flow-cli

The Flow CLI is a command-line interface that provides useful utilities for building Flow applications
https://onflow.org
Apache License 2.0
206 stars 66 forks source link

`flow migrate` issue with duplicate deployments #1471

Closed jribbink closed 1 month ago

jribbink commented 6 months ago

Problem

An issue/question was recently encountered with the flow migrate state command. It is as follows: what should the behaviour be if the user has configured their flow.json with multiple deployments for the same contract? Currently, all of the migration commands (i.e. flow migrate stage-contract, flow migrate state) only make an assumption that a contract will only be deployed to one account: this is not true.

It is possible that contracts -> deployments is a one to many relationship & not one to one. In the current form, the first match is chosen & subsequent deployments entries will be skipped. However, this behaviour may not be desirable for some.

Steps to Reproduce

Make flow.json with a contract that appears twice in the deployments section, try using these commands.

Acceptance Criteria

There should be some mechanism in place to handle these conflicts. Some options are as follows:

  1. Apply these commands to every account with the contract's name in their deployments. Logically, this makes sense - if you have an updated version of the contract code, why wouldn't you simply want to update/stage the update for all accounts using this contract?
  2. Require more granular specification of accounts when they are ambiguous --> (i.e. require acct1:Contract syntax if many accounts with this deployment exist?)
  3. Any other ideas? :)

Context

https://discordapp.com/channels/613813861610684416/1123314820763111465/1220759822065078383