{"id":19571637,"url":"https://github.com/serlo/db-migrations","last_synced_at":"2025-04-27T03:32:32.117Z","repository":{"id":152143576,"uuid":"589734385","full_name":"serlo/db-migrations","owner":"serlo","description":null,"archived":true,"fork":false,"pushed_at":"2024-07-01T11:01:26.000Z","size":443907,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-05T01:33:49.236Z","etag":null,"topics":["database-migrations","serlo","service"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serlo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-16T20:11:01.000Z","updated_at":"2024-07-01T11:07:33.000Z","dependencies_parsed_at":"2023-10-02T07:56:14.061Z","dependency_job_id":"a2a3a68d-5b42-4985-a544-5b51bf394cb6","html_url":"https://github.com/serlo/db-migrations","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serlo%2Fdb-migrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serlo%2Fdb-migrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serlo%2Fdb-migrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serlo%2Fdb-migrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serlo","download_url":"https://codeload.github.com/serlo/db-migrations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251085145,"owners_count":21533821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-migrations","serlo","service"],"created_at":"2024-11-11T06:19:38.033Z","updated_at":"2025-04-27T03:32:27.107Z","avatar_url":"https://github.com/serlo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Repo deprecated: code was moved to `serlo/api.serlo.org`\n\n\u003cimg width=\"688\" alt=\"image\" src=\"https://github.com/serlo/db-migrations/assets/1258870/e19d4bc1-977c-4327-ab06-7b187e4dc8ab\"\u003e\n\n# DB migrations\n\nparticularly for the legacy database\n\n## Prerequisites\n\n- [Node.js](https://nodejs.org/) and [yarn cli](https://yarnpkg.com/cli/)\n  versions from [.tool-versions](.tool-versions)\n  - You may use [asdf](https://asdf-vm.com/) for the installation.\n- Docker and Docker Compose\n\nNote: Also make sure you have `cmake` installed on your machine (e.g.\n`sudo apt install cmake`).\n\n## Add a new migration\n\n1. Run `yarn new` to create a new file with the migration timestamp. You can\n   copy and paste one of the existing migrations as a template for the new one.\n\nExample:\n\n- [`src/20220614111600-make-subjects-in-construction-a-subject.ts`](./src/20220614111600-make-subjects-in-construction-a-subject.ts)\n  when you just want to execute SQL statements.\n- [`src/20210923231900-add-transformation-target-to-equations.ts`](./src/20210923231900-add-transformation-target-to-equations.ts)\n  when you want to migrate edtr-io plugins\n\n2. You need to build a migration by running\n   `yarn build src/YYYYMMDDHHMMSS-xyz.ts` in the `src` directory. This creates a\n   new file in `migrations`. Both files in `migrations` and `src` need to be\n   added in the PR. _Notice that any changes in other directories that are\n   imported by the file will be built together!_\n\n## Test a new migration\n\nStart a local version of the mysql database via `yarn start`. There are the\nfollowing helper functions:\n\n- `yarn mysql` – Open a shell to MySQL\n- `yarn migrate:run [path]` – Run a certain migration (like\n  `yarn migrate:run src/20201023104526-update-subjects.ts`)\n- `yarn migrate:down` – Run the down function of the migrations that were run\n- `yarn mysql:rollback` – Rollback database before any applied migrations\n- `yarn mysql:list-migrations` – List all migrations which have been already run\n- `yarn migrate:ts` – Run all migrations directly from `src` directory (no build\n  needed)\n- `yarn migrate:docker` – Build docker container and run migrations\n- `yarn mysql:delete-last-migration` – Delete information that last migration\n  was already executed (will be thus executed the next time again)\n- `yarn mysql:import-anonymous-data` – Import last anonymized dump\n\n### Test on staging\n\nOnce it seems to work as desired locally, it can be deployed to staging and will\nthen be run every night after the new anonymous data import. If you then find an\nerror and want to deploy a fixed version of the migration, run the `dbsetup` job\non the staging cluster to undo the changes of the erroneous migration first\nbefore deploying the fixed version of `db-migrations`.\n\n### Deployment\n\nBefore running `yarn push-image`, make sure that you are authenticated with\ngcloud and have run `gcloud auth configure-docker`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserlo%2Fdb-migrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserlo%2Fdb-migrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserlo%2Fdb-migrations/lists"}