2020-03-08 07:41:23 -05:00
|
|
|
# Backend Developer Guide #
|
2019-12-09 10:28:15 -05:00
|
|
|
|
|
|
|
This guide intends to explain the essential details of the backend
|
|
|
|
application.
|
2020-03-08 07:41:23 -05:00
|
|
|
|
|
|
|
|
|
|
|
## Fixtures ##
|
|
|
|
|
|
|
|
This is a development feature that allows populate the database with a
|
2020-06-23 07:00:16 -05:00
|
|
|
good amount of content (usually used for just test the application or
|
|
|
|
perform performance tweaks on queries).
|
2020-03-08 07:41:23 -05:00
|
|
|
|
|
|
|
In order to load fixtures, enter to the REPL environment executing the
|
2020-08-18 12:40:49 -05:00
|
|
|
`bin/repl` script, and then execute `(app.cli.fixtures/run {:preset :small})`.
|
2020-03-08 07:41:23 -05:00
|
|
|
|
|
|
|
You also can execute this as a standalone script with:
|
|
|
|
|
|
|
|
```bash
|
2020-08-17 08:04:21 -05:00
|
|
|
clojure -Adev -X:fn-fixtures
|
2020-03-08 07:41:23 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
NOTE: It is an optional step because the application can start with an
|
|
|
|
empty database.
|
|
|
|
|
|
|
|
This by default will create a bunch of users that can be used to login
|
|
|
|
in the aplication. All users uses the following pattern:
|
|
|
|
|
|
|
|
- Username: `profileN.test@uxbox.io`
|
|
|
|
- Password: `123123`
|
|
|
|
|
|
|
|
Where `N` is a number from 0 to 49 on the default fixture parameters.
|
2020-04-13 08:38:25 -05:00
|
|
|
|
2020-06-23 07:00:16 -05:00
|
|
|
If you have a REPL access to the running process, you can execute it
|
|
|
|
from there:
|
2020-04-13 08:38:25 -05:00
|
|
|
|
2020-06-23 07:00:16 -05:00
|
|
|
```clojure
|
2020-08-18 12:40:49 -05:00
|
|
|
(require 'app.cli.fixtures)
|
|
|
|
(app.cli.fixtures/run :small)
|
2020-04-13 08:38:25 -05:00
|
|
|
```
|
2020-08-17 08:04:21 -05:00
|
|
|
|
|
|
|
To access to the running process repl you usually will execute this
|
|
|
|
command:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
rlwrap netcat localhost 5555
|
|
|
|
```
|
|
|
|
|
2020-09-21 08:58:56 -05:00
|
|
|
## Migrations
|
|
|
|
|
|
|
|
The database migrations are located in two directories:
|
|
|
|
|
|
|
|
- `src/app/migrations` (contains migration scripts in clojure)
|
|
|
|
- `src/app/migrations/sql` (contains the pure SQL migrations)
|
|
|
|
|
|
|
|
The SQL migration naming consists in the following:
|
|
|
|
|
|
|
|
```
|
|
|
|
XXXX-<add|mod|del|drop|[...verb...]>-<table-name>-<any-additional-text>
|
|
|
|
```
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
```
|
|
|
|
0025-del-generic-tokens-table
|
|
|
|
0026-mod-profile-table-add-is-active-field
|
|
|
|
```
|
|
|
|
|
|
|
|
**NOTE**: if table name has more than one words, we still use `-` as a separator.
|
|
|
|
|
|
|
|
If you need to have a global overview of the all schema of the database you can extract it
|
|
|
|
using postgresql:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# (in the devenv environment)
|
|
|
|
pg_dump -h postgres -s > schema.sql
|
|
|
|
```
|