On this page
How do I set up QA and production copies of WORLD to practise environment commands?
What you'll accomplish
Several BroadSQL features only make sense when one application has a database per deployment stage: ENV moves between them, / PROD runs a query once on production, COMPARE TABLE STRUCTURE compares two stages. Your real databases may not be the place to try them for the first time.
You will build a small practice set from the WORLD sample: a fictional application, WORLDAPP, with three connections. WORLD-IN (integration) and WORLD-QA (quality assurance) are copies of the sample file, and the WORLD connection you already have plays the production database. At the end, SHOW GROUP; lists the three connections, and every environment example of these how-tos works on your installation.
Short answer
Copy the sample file twice, create the Environments IN, QA and PROD (only PROD flagged Production) and the Database Group WORLDAPP, add the connections WORLD-IN and WORLD-QA, then move WORLD into WORLDAPP as its PROD connection with EDIT CONNECTION WORLD;.
What exists by default, and what you create
| Name | Exists by default? | In this practice set |
|---|---|---|
Connection WORLD | Yes: the sample, jdbc:h2:./samples/WorldDB, environment LOCAL, no Database Group | The production database of WORLDAPP, environment PROD |
Connections WORLD-IN, WORLD-QA | No | Copies of the sample, environments IN and QA |
Database Group WORLDAPP | No | Ties the three connections together |
Environments IN, QA, PROD | Only if someone created them | PROD is flagged Production, the others are not |
1. Copy the sample database file
The two copies are ordinary H2 database files next to the original. Close BroadSQL first: H2 does not let two programs open the same file, and a file copied while it is open may be incomplete. On Windows:
copy samples\WorldDB.mv.db samples\WorldDB_IN.mv.db
copy samples\WorldDB.mv.db samples\WorldDB_QA.mv.dbOn Linux, the same with cp:
cp samples/WorldDB.mv.db samples/WorldDB_IN.mv.db
cp samples/WorldDB.mv.db samples/WorldDB_QA.mv.db2. Create the Environments and the Database Group
Start BroadSQL again. First list the Environments that already exist, to skip the ones you have:
SHOW ALL ENVIRONMENTS;Then create the missing ones and the Database Group. Each command asks a few questions: give a description such as Integration, answer n to Production [y/n] for IN and QA and y for PROD, then y to save.
ADD ENVIRONMENT IN;
ADD ENVIRONMENT QA;
ADD ENVIRONMENT PROD;
ADD GROUP WORLDAPP;3. Add the two copies as connections
ADD CONNECTION asks for each field in turn. Run it once per copy:
ADD CONNECTION WORLD-IN;
ADD CONNECTION WORLD-QA;Answer with these values; they are the values of the WORLD connection, except the name, the URL, the Database Group and the Environment:
| Field | WORLD-IN | WORLD-QA |
|---|---|---|
| Name | Sample World Database, integration | Sample World Database, QA |
| Type | H2 | H2 |
| URL | jdbc:h2:./samples/WorldDB_IN | jdbc:h2:./samples/WorldDB_QA |
| User Name | sa | sa |
| User Password | empty, as for WORLD | empty, as for WORLD |
| Database Group | WORLDAPP | WORLDAPP |
| Environment | IN | QA |
On Windows, the CONFIG window does the same in its Connections, Database Groups and Environments tabs.
4. Make WORLD the production connection
EDIT CONNECTION shows each current value and asks whether to keep it. Keep every value except the Database Group (WORLDAPP) and the Environment (PROD):
EDIT CONNECTION WORLD;5. Check the result
Open the QA copy and list the connections of its Database Group:
CONNECT WORLD-QA;
SHOW GROUP;SHOW GROUP lists one connection per Environment, in a table like this one:
WORLD-QA> SHOW GROUP;
List of environments for Database Group 'WORLDAPP':
|------------|---------------|--------------------|---------------------------------------------|---------------|
|ENVIRONMENT |ID |USER |NAME |TYPE |
|------------|---------------|--------------------|---------------------------------------------|---------------|
|IN |WORLD-IN | |Sample World Database, integration |H2 |
|PROD |WORLD | |Sample World Database |H2 |
|QA |WORLD-QA | |Sample World Database, QA |H2 |
|------------|---------------|--------------------|---------------------------------------------|---------------|
3 database connections foundWhat changes for the WORLD connection
WORLDis now in an Environment flagged Production: before a statement that can change data on it (INSERT,UPDATE,CREATE TABLEand so on), BroadSQL asks for a confirmation. ASELECTnever asks. See Production confirmation.- When colors are on, the prompt of
WORLDis shown in the Production style. - From
WORLD-INorWORLD-QA,ENV PROD;opensWORLD, and/ PRODruns your last query on it once. - The three databases start identical. Any change you make in one copy stays in that copy, which is how the comparison recipes show differences.
Undo the practice set
To go back to the installation as it was: EDIT CONNECTION WORLD; with the Environment LOCAL and an empty Database Group, then DEL CONNECTION WORLD-IN; and DEL CONNECTION WORLD-QA; (they become inactive), and finally delete samples/WorldDB_IN.mv.db and samples/WorldDB_QA.mv.db while BroadSQL is closed. The Environments and the Database Group can stay; DEL GROUP and DEL ENVIRONMENT remove them.
Watch out
- A connection ID has at most 15 characters, and a Database Group holds at most one connection per Environment.
- The URL is relative to the installation folder, like the URL of
WORLD: start BroadSQL with its launchers. - These names are an example. Your own databases need their own Database Groups and Environments: see Connections, Database Groups and Environments.
Related
- Check a figure in QA, then in production
- Check that a deployment changed a table the same way in QA and production
- Find the rows that differ between two databases
- Run a post-deployment smoke check on every environment
- Verify that a data fix changed only the intended rows
Commands used
Found something wrong or unclear on this page? Tell us, with the page address.