Repo deprecated: code was moved to serlo/api.serlo.org
particularly for the legacy database
- Node.js and yarn cli
versions from .tool-versions
- You may use asdf for the installation.
- Docker and Docker Compose
Note: Also make sure you have cmake
installed on your machine (e.g.
sudo apt install cmake
).
- Run
yarn new
to create a new file with the migration timestamp. You can copy and paste one of the existing migrations as a template for the new one.
Example:
src/20220614111600-make-subjects-in-construction-a-subject.ts
when you just want to execute SQL statements.src/20210923231900-add-transformation-target-to-equations.ts
when you want to migrate edtr-io plugins
- You need to build a migration by running
yarn build src/YYYYMMDDHHMMSS-xyz.ts
in thesrc
directory. This creates a new file inmigrations
. Both files inmigrations
andsrc
need to be added in the PR. Notice that any changes in other directories that are imported by the file will be built together!
Start a local version of the mysql database via yarn start
. There are the
following helper functions:
yarn mysql
– Open a shell to MySQLyarn migrate:run [path]
– Run a certain migration (likeyarn migrate:run src/20201023104526-update-subjects.ts
)yarn migrate:down
– Run the down function of the migrations that were runyarn mysql:rollback
– Rollback database before any applied migrationsyarn mysql:list-migrations
– List all migrations which have been already runyarn migrate:ts
– Run all migrations directly fromsrc
directory (no build needed)yarn migrate:docker
– Build docker container and run migrationsyarn mysql:delete-last-migration
– Delete information that last migration was already executed (will be thus executed the next time again)yarn mysql:import-anonymous-data
– Import last anonymized dump
Once it seems to work as desired locally, it can be deployed to staging and will
then be run every night after the new anonymous data import. If you then find an
error and want to deploy a fixed version of the migration, run the dbsetup
job
on the staging cluster to undo the changes of the erroneous migration first
before deploying the fixed version of db-migrations
.
Before running yarn push-image
, make sure that you are authenticated with
gcloud and have run gcloud auth configure-docker
.