Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Database setup

Chris Bras edited this page Jun 7, 2019 · 6 revisions

CTE Database

Requirements

This project requires Docker 1.13.1 or newer, and docker-compose 1.10.0 or newer for hosting the database.

Linux

You can install Docker and docker-compose using your password manager, e.g. sudo apt install docker.io docker-compose.

Note that you will need root rights for everything Docker. It is not recommended to add yourself to the docker group.

macOS

On macOS, it's easiest to install Docker using Homebrew Cask: brew cask install docker. This will also install docker-compose.

Windows

You can get Docker for Windows from the Docker store

After installing Docker, don't forget to run it!

Configuration

Currently, you only need to choose a password for the database by creating a .env file with the following contents:

DATABASE_PASSWORD=...

Just make up a strong, random password here.

Changing Password

You can change it by opening a mysql shell with

docker-compose run database mysql cte -u cte -p

Then, enter the old password and execute the following command:

ALTER USER cte IDENTIFIED BY 'new_random_password';

Close the shell with \q and edit .env to the new password.

Building

Open terminal in the server folder and run docker-compose up -d --build, everything should now be ready for running.

Running

Open a terminal in the server folder, run docker-compose up -d, the database should now be available through adminer at localhost:8080

Database Migration

In order to upgrade or downgrade the database versions, you can use the alembic commands. To make sure your database is at the most recent revision, first run the command

docker-compose run migration alembic upgrade head

To downgrade 1 revision use

docker-compose run migration alembic downgrade -1

And to upgrade 1 revision use

docker-compose run migration alembic upgrade 1

Clone this wiki locally