Skip to content

Commit 826eeb7

Browse files
authored
confirm passwords match between .env and secrets.json (#597)
* confirm passwords match between .env and secrets.json * add tip to test database connectivity * move confirmation steps into tabs * align headers with #593; add link to migrations page
1 parent cd9baa1 commit 826eeb7

File tree

1 file changed

+65
-55
lines changed
  • docs/getting-started/server/database/ef

1 file changed

+65
-55
lines changed

docs/getting-started/server/database/ef/index.mdx

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ each.
4040

4141
Our EF implementations currently support Postgres, MySQL, and SQLite3.
4242

43-
## Setting Up EF Databases
43+
## Creating the database
4444

45-
The workflow here is broadly the same as with the normal MSSQL implementation: set up the docker
45+
The workflow here is broadly the same as with the normal MSSQL implementation: set up the Docker
4646
container, configure user secrets, and run migrations against their relating databases in
4747
chronological order.
4848

@@ -59,53 +59,6 @@ chronological order.
5959
You can have multiple databases configured and switch between them by changing the value of the
6060
`globalSettings:databaseProvider` user secret. You don’t have to delete your connection strings.
6161

62-
### Database Setup
63-
64-
<Tabs
65-
groupId="provider"
66-
values={providers}>
67-
<TabItem value="postgres">
68-
69-
In the `dev` folder of your server repository, run
70-
71-
```bash
72-
export POSTGRES_PASSWORD='example'
73-
docker compose --profile postgres up
74-
```
75-
76-
:::note
77-
78-
`POSTGRES_PASSWORD` only needs to be defined for database setup. It does not need to be defined to
79-
run the mysql profile.
80-
81-
:::
82-
83-
</TabItem>
84-
<TabItem value="mysql">
85-
86-
In the `dev` folder of your server repository, run
87-
88-
```bash
89-
export MYSQL_ROOT_PASSWORD='example'
90-
docker compose --profile mysql up
91-
```
92-
93-
:::note
94-
95-
`MYSQL_ROOT_PASSWORD` only needs to be defined for database setup. It does not need to be defined to
96-
run the mysql profile.
97-
98-
:::
99-
100-
</TabItem>
101-
<TabItem value="sqlite">
102-
103-
Select a location for your database file. You can use the `dev` folder of your server repository.
104-
Git is configured to ignore `.db` files in this repository for this purpose.
105-
106-
</TabItem>
107-
</Tabs>
108-
10962
### User secrets
11063

11164
Add the following values to your API, Identity, and Admin user secrets.
@@ -138,7 +91,8 @@ sure you update the existing values instead of creating new ones
13891
<TabItem value="sqlite">
13992

14093
Add the following values to your API, Identity, and Admin user secrets. Note, you must set the Data
141-
Source path. Use the file location selected in [Database Setup](#database-setup)
94+
Source path. Git is configured to ignore `.db` files in the server repository so that the sqlite
95+
database can be stored in `dev`. You can use any path with write permissions.
14296

14397
```json
14498
"globalSettings:databaseProvider": "sqlite",
@@ -155,6 +109,62 @@ that the changes take effect.
155109

156110
:::
157111

112+
### Updating the database
113+
114+
<Tabs
115+
groupId="provider"
116+
values={providers}>
117+
<TabItem value="postgres">
118+
119+
1. Confirm that `POSTGRES_PASSWORD` in `dev/.env` matches the password in `dev/secrets.json`.
120+
121+
2. In the `dev` folder of your server repository, run
122+
123+
```bash
124+
docker compose --profile postgres up
125+
```
126+
127+
:::tip[Confirm your database connection!]
128+
129+
If you run into connection errors, double check that your `.env` and `secrets.json` files have
130+
matching passwords. If they do, you may have initialized your database incorrectly. Delete the
131+
Docker storage volume and initialize the database from scratch.
132+
133+
:::
134+
135+
</TabItem>
136+
<TabItem value="mysql">
137+
138+
1. Confirm that `MYSQL_ROOT_PASSWORD` in `dev/.env` matches the password in `dev/secrets.json`.
139+
140+
2. In the `dev` folder of your server repository, run
141+
142+
```bash
143+
docker compose --profile mysql up
144+
```
145+
146+
:::tip[Confirm your database connection!]
147+
148+
If you run into connection errors, double check that your `.env` and `secrets.json` files have
149+
matching passwords. If they do, you may have initialized your database incorrectly. Delete the
150+
Docker storage volume and initialize the database from scratch.
151+
152+
:::
153+
154+
</TabItem>
155+
<TabItem value="sqlite">
156+
157+
:::tip[Confirm your database path!]
158+
159+
The migrator creates the database file if it doesn't exist, but it does not create folders. If you
160+
get an error that the path doesn't exist, double check that the path exists and that the folder
161+
containing the sqlite database has write and/or create permissions.
162+
163+
:::
164+
165+
</TabItem>
166+
</Tabs>
167+
158168
### Migrations
159169

160170
<Tabs
@@ -168,7 +178,7 @@ In the `dev` folder run the following to update the database to the latest migra
168178
pwsh migrate.ps1 -postgres
169179
```
170180

171-
The `-postgres` flag on `migrate.ps1` will run `dotnet ef` commands to perform the migrations.
181+
The `-postgres` flag on `migrate.ps1` runs `dotnet ef` commands to perform the migrations.
172182

173183
</TabItem>
174184
<TabItem value="mysql">
@@ -179,7 +189,7 @@ In the `dev` folder run the following to update the database to the latest migra
179189
pwsh migrate.ps1 -mysql
180190
```
181191

182-
The `-mysql` flag on `migrate.ps1` will run `dotnet ef` commands to perform the migrations.
192+
The `-mysql` flag on `migrate.ps1` runs `dotnet ef` commands to perform the migrations.
183193

184194
</TabItem>
185195
<TabItem value="sqlite">
@@ -190,7 +200,7 @@ In the `dev` folder run the following to update the database to the latest migra
190200
pwsh migrate.ps1 -sqlite
191201
```
192202

193-
The `-sqlite` flag on `migrate.ps1` will run `dotnet ef` commands to perform the migrations.
203+
The `-sqlite` flag on `migrate.ps1` runs `dotnet ef` commands to perform the migrations.
194204

195205
:::note
196206

@@ -208,7 +218,7 @@ You can also run migrations for all database providers at once using
208218
pwsh migrate.ps1 -all
209219
```
210220

211-
### Optional: Verify
221+
### Verifying changes
212222

213223
If you would like to verify that everything worked correctly:
214224

@@ -217,7 +227,7 @@ If you would like to verify that everything worked correctly:
217227
- Note: this requires a configured MSSQL database. You may also need to set up other EF providers
218228
for tests to pass.
219229

220-
## Testing EF Changes
230+
## Testing changes
221231

222232
In your `server/dev/secrets.json` file find or add this block of secrets in the root of the json
223233
structure:

0 commit comments

Comments
 (0)