|
|
@@ -14,9 +14,31 @@ You will need...
|
|
14
|
14
|
## :package: Installation
|
|
15
|
15
|
|
|
16
|
16
|
1. Install dependencies with `npm install`
|
|
17
|
|
-2. Fill out your database connection details in `./config/dev.js`
|
|
18
|
|
-3. A test database container is provided and can be started with `docker-compose up -d`
|
|
19
|
|
-4. Populate some basic tables for your database using `npx knex migrate:latest`
|
|
|
17
|
+2. Copy the environments sample file from `./server/.env.sample` and rename it to `./server/.env`
|
|
|
18
|
+3. Fill out your database connection details in `./server/.env`
|
|
|
19
|
+4. A test database container is provided and can be started with `docker-compose --env-file ./backend/server/.env up -d`
|
|
|
20
|
+5. Populate some basic tables for your database using `npx knex migrate:latest`
|
|
|
21
|
+
|
|
|
22
|
+## :package: Migrations
|
|
|
23
|
+
|
|
|
24
|
+We use Knex.js,which comes with a couple nice database migration and seeding tools.
|
|
|
25
|
+Migrating tracks changes in schema. Migration steps are contained in the `./db/migrations` folder. Seeding adds dummy data once our database tables have been created and schemas are set. Starting seed steps are contained in `./db/seeds` and use the `mock.js` file as the main dummy data source.
|
|
|
26
|
+
|
|
|
27
|
+### Migrating
|
|
|
28
|
+* Run `npm run migrate` to run all migrations and establish the base schema
|
|
|
29
|
+* Run `npm run unmigrate` to roll back one migration
|
|
|
30
|
+
|
|
|
31
|
+### Seeding
|
|
|
32
|
+* Run `npm run seed` to seed the database with dummy data
|
|
|
33
|
+
|
|
|
34
|
+### Restarting
|
|
|
35
|
+Since we can't unseed the database, it's best to destroy the `dev` database and rebuild it.
|
|
|
36
|
+
|
|
|
37
|
+1. Stop the database by navigating to the project root directory `cd ../` and running `docker-compose down`
|
|
|
38
|
+2. Destroy the database volume `docker volume rm siimee_db`. BE CAREFUL.
|
|
|
39
|
+3. Restart the database while still at the project root with `docker-compose --env-file ./backend/server/.env up -d`
|
|
|
40
|
+4. Recreate schemas and tables but navigating to `./backend` and running `npm run migrate`
|
|
|
41
|
+5. Reseed the dummy data with `npm run seed`
|
|
20
|
42
|
|
|
21
|
43
|
## :electric_plug: Run
|
|
22
|
44
|
|