-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bca95af
commit 53def9e
Showing
13 changed files
with
132 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,3 @@ __pycache__ | |
*.egg-info | ||
.idea | ||
*.pyc | ||
*.iml | ||
flyway.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,23 @@ | ||
# FAForever DB project | ||
|
||
Contains a dockerfile to run our database in a contained environment, along with tools for managing the database. | ||
Provides the Docker container and migration tools for a production-ready FAF database. | ||
|
||
## Set your Database up | ||
## Creating a new database | ||
|
||
Install [docker](http://docker.com). | ||
We highly recommended to use [faf-stack](https://github.com/FAForever/faf-stack) to create a new database container, like so: | ||
|
||
**Make sure your port 3306 is not occupied**. Install and initialize the database: | ||
docker-compose up -d faf-db | ||
|
||
./setup_db.sh | ||
## Updating the database | ||
|
||
Now your FAF database is up and running and contains some dummy data (from `db-data.sql`) | ||
In order to update an existing database to the newest schema version, execute: | ||
|
||
Currently supported flags for `setup_db.sh`: | ||
docker exec -ti faf-db ./migrate.sh | ||
|
||
-d Dump DB schema to container STDOUT. | ||
-c file Dump DB schema to provided file location. If a directory is provided, the file name will be dump.sql. | ||
-h Print script command line options." | ||
## Connecting to the database | ||
|
||
## Update your Database | ||
|
||
If you have an existing database which you need to update, run: | ||
|
||
./migrate.sh faf-db | ||
|
||
## Connect to your Database | ||
|
||
To get a mysql session where you can execute queries conveniently, execute: | ||
In order to connect to the database using the mysql client, execute: | ||
|
||
docker exec -ti faf-db mysql -uroot -pbanana | ||
|
||
Where you have to replace `root` and `banana` with your custom credentials. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ ! "${MYSQL_ROOT_PASSWORD+1}" ]; then | ||
echo "This script is not intended for use outside the docker container (variable MYSQL_ROOT_PASSWORD has not been set)" | ||
echo "Try instead: docker -i faf-db ${0}" | ||
exit 1 | ||
fi | ||
|
||
mysqldump -uroot -p${MYSQL_ROOT_PASSWORD} --no-data faf || exit 1; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
echo "SELECT 1;" | mysql --host="127.0.0.1" --user="root" --password="${MYSQL_ROOT_PASSWORD}" > /dev/null | ||
|
||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
create() { | ||
database=$1 | ||
username=$2 | ||
password=$3 | ||
|
||
mysql --user=root --password=${MYSQL_ROOT_PASSWORD} <<SQL_SCRIPT | ||
CREATE DATABASE IF NOT EXISTS \`${database}\`; | ||
CREATE USER '${username}'@'%' IDENTIFIED BY '${password}'; | ||
GRANT ALL PRIVILEGES ON \`${database}\`.* TO '${username}'@'%'; | ||
FLUSH PRIVILEGES; | ||
SQL_SCRIPT | ||
} | ||
|
||
create "faf" "faf-api" "${MYSQL_API_PASSWORD}" | ||
create "faf" "faf-legacy-apps" "${MYSQL_LEGACY_APPS_PASSWORD}" | ||
create "faf" "faf-legacy-live-replay-server" "${MYSQL_LEGACY_LIVE_REPLAY_SERVER_PASSWORD}" | ||
create "faf" "faf-legacy-secondary-server" "${MYSQL_LEGACY_SECONDARY_SERVER_PASSWORD}" | ||
create "faf" "faf-legacy-updater" "${MYSQL_LEGACY_UPDATER_PASSWORD}" | ||
create "faf-murmur" "faf-murmur" "${MYSQL_MURMUR_PASSWORD}" | ||
create "faf" "faf-server" "${MYSQL_SERVER_PASSWORD}" | ||
create "faf-softvote" "faf-softvote" "${MYSQL_SOFTVOTE_PASSWORD}" | ||
create "faf-anope" "faf-anope" "${MYSQL_ANOPE_PASSWORD}" | ||
create "faf-wiki" "faf-wiki" "${MYSQL_WIKI_PASSWORD}" | ||
create "faf-wordpress" "faf-wordpress" "${MYSQL_WORDPRESS_PASSWORD}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
./migrate.sh |
Oops, something went wrong.