Skip to content

Commit cebe726

Browse files
authored
Merge pull request #2 from secure-dashboards/feat/add-knex
2 parents bce3c95 + f033042 commit cebe726

File tree

5 files changed

+489
-2
lines changed

5 files changed

+489
-2
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,32 @@ To stop the infrastructure, run the following command:
2828
npm run infra:stop
2929
```
3030

31+
## Database Management
32+
33+
### Running Migrations
34+
35+
To run the latest database migrations, use the following command:
36+
37+
```bash
38+
npm run db:migrate
39+
```
40+
41+
### Rolling Back Migrations
42+
43+
To rollback the last batch of migrations, use the following command:
44+
45+
```bash
46+
npm run db:rollback
47+
```
48+
49+
### Seeding the Database
50+
51+
To seed the database with initial data, use the following command:
52+
53+
```bash
54+
npm run db:seed
55+
```
56+
3157
## License
3258

3359
This project is licensed under the MIT License. See the [LICENSE](/LICENSE) file for details.

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ services:
66
POSTGRES_DB: dashboard
77
POSTGRES_USER: openjs
88
POSTGRES_PASSWORD: password
9+
ports:
10+
- 5432:5432
911
volumes:
1012
- openjs_dashboard_data:/var/lib/postgresql/data
1113

knexfile.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const { normalizeBoolean } = require("@ulisesgascon/normalize-boolean");
2+
const dbSettings = {
3+
client: 'pg',
4+
connection: {
5+
host: process.env.DB_HOST || '0.0.0.0',
6+
user: process.env.DB_USER || 'openjs',
7+
password: process.env.DB_PASSWORD || 'password',
8+
database: process.env.DB_NAME || 'dashboard',
9+
},
10+
ssl: normalizeBoolean(process.env.DB_SSL),
11+
pool: {
12+
min: 2,
13+
max: 10
14+
},
15+
migrations: {
16+
directory: './src/database/migrations'
17+
},
18+
seeds: {
19+
directory: './src/database/seeds'
20+
}
21+
}
22+
23+
module.exports = {
24+
development: dbSettings
25+
}

0 commit comments

Comments
 (0)