What database is the server console using?

I have an app with 2 environments linked to two branches and two databases.

The production environment runs the production branch code and uses the production database, which is the default database.
The development environment runs the development branch code and uses the development database.

No matter what branch is checked out or what environment is running the app, the server console always works with the development database.

Is there a way to specify what database I want to use on the console, either explicitly or by checking out one branch or by running one app?

EDIT
And what database is used by branches that are not linked to an environment?

If I understand correctly, if it’s not linked to a run-time environment, then it can’t run, so it isn’t using any database.

I would expect the console to connect to the IDE’s current “DEBUG” database, but I haven’t actually checked.

1 Like

The server console, like everything you run in the editor, always uses the database you’ve selected for your debug environment. So, regardless of what version of the code you’ve checked out in the Editor, it will see the database you’ve selected in the editor (here’s how to switch).

Yes! Click the menu next to the database you want to use, then click Use when debugging, then launch the server console or run your app in the editor. They will now be using this database.

@p.colbert has it exactly right – the only way to run code is in an environment. If you run it in the editor, it runs in your debug environment, with whatever version of the code you’ve got open in the editor. If you use the Publish dialog to point a URL at a branch, then accessing that URL will run your app in that published environment, using the code from that branch.

You could have two environments linked to the same branch, or the same commit – depending on which URL you access, you’ll be running the same version of the code, but in two different environments.

Does that make sense?

4 Likes

Yes, it makes sense.

I assumed that checking out a branch linked to an environment linked to a database and running the app would use that database, regardless of whether the app is running inside the IDE or from the production URL.

My understanding of how multiple databases work was completely wrong. I can finally work without feeling like I’m going to panic and cause a disaster.


PS
Now that I know that databases and branches are not related to each other, I have one more reason to dislike the schema management, more than my previous post suggests :slight_smile:

I spent a chunk of this afternoon in a design discussion about that very experience; I promise we’re making it better! :smiley:

5 Likes