|
1 | 1 | # FAForever DB project |
2 | 2 |
|
3 | | -Provides the Docker container and migration tools for a production-ready FAF database. |
| 3 | +This project contains the FAF database structure for the core faf database used by API and server. (Other databases like forums or wiki are not part of this repository.) |
4 | 4 |
|
5 | | -## Creating a new database |
6 | | - |
7 | | -We highly recommended to use [faf-stack](https://github.com/FAForever/faf-stack) to create a new database container, like so: |
| 5 | +## Usage with faf-stack |
| 6 | +We highly recommended to use [faf-stack](https://github.com/FAForever/faf-stack) to interact with the database! |
8 | 7 |
|
| 8 | +### Creating a new database |
9 | 9 | docker-compose up -d faf-db |
10 | 10 |
|
11 | | -## Updating the database |
12 | | - |
| 11 | +### Updating the database |
13 | 12 | In order to update an existing database to the newest schema version, execute: |
14 | 13 |
|
15 | | - docker exec -ti faf-db ./migrate.sh |
16 | | - |
17 | | -## Connecting to the database |
| 14 | + docker-compose run faf-db-migrations migrate |
18 | 15 |
|
| 16 | +### Connecting to the database |
19 | 17 | In order to connect to the database using the mysql client, execute: |
20 | 18 |
|
21 | 19 | docker exec -ti faf-db mysql -uroot -pbanana |
22 | 20 |
|
23 | 21 | Where you have to replace `root` and `banana` with your custom credentials. |
24 | 22 |
|
25 | 23 |
|
| 24 | +## Usage with plain docker |
| 25 | + |
| 26 | +### Create a network |
| 27 | +Create a network to connect the docker containers to each other. The old `--link` method is deprecated. |
| 28 | + |
| 29 | + docker network create faf |
| 30 | + |
| 31 | +If you want to connect other docker containers to connect to the database, put them into the same network. |
| 32 | + |
| 33 | +### Creating a new database |
| 34 | + docker run --network="faf" --network-alias="faf-db" -p 3306:3306 \ |
| 35 | + -e MYSQL_ROOT_PASSWORD=banana \ |
| 36 | + -e MYSQL_DATABASE=faf \ |
| 37 | + -d --name faf-db \ |
| 38 | + mysql:5.7 |
| 39 | + |
| 40 | +### Updating the database |
| 41 | +In order to update an existing database to the newest schema version, execute: |
| 42 | + |
| 43 | + docker run --network="faf" \ |
| 44 | + -e FLYWAY_URL=jdbc:mysql://faf-db/faf?useSSL=false \ |
| 45 | + -e FLYWAY_USER=root \ |
| 46 | + -e FLYWAY_PASSWORD=banana \ |
| 47 | + faf-db-migrations migrate |
| 48 | + |
26 | 49 | ## How to Contribute |
27 | | -https://github.com/FAForever/db/wiki/How-to-Contribute |
| 50 | + |
| 51 | +To make changes to the database, add a new .sql file to the migrations folder. Each file needs to have a unique version prefix and be one version higher than the latest one. |
| 52 | + |
| 53 | +For more information how the migration works please consult the [flyway tutorial](https://flywaydb.org/getstarted/how). |
| 54 | + |
| 55 | +Please also follow our [general contribution guidelines](https://github.com/FAForever/db/wiki/How-to-Contribute). |
0 commit comments