Developing with local dev & live production db connections

Here is how I have done it:

  1. Create two publish targets - dev & prod (which you too have probably done)
  2. Make sure dev & prod MySQL db schema are replicas
  3. Create one db connection
  4. When using dev, go to any server action, edit the db connection and set values as per your dev environment. When you save db connection settings, dev MySQL schema is applied.
    Publish your app and everything should work fine.
  5. When using prod, go to any server action, edit the db connection and set values as per your prod env. eg: server would be some IP instead of localhost. Username, password, db name could be different too.
    Save, schema will refresh, but remain same. Publish & everything should work fine on prod.

I did this multiple times while developing my application and found no issues.
Just make sure all server actions use the same db connection.

If you want, you can also create two db connections. Then you will be shown an option to select the connection. But this would require you to edit each and every server action every time you need to switch between dev & prod.