> For the complete documentation index, see [llms.txt](https://atd-dts.gitbook.io/moped-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atd-dts.gitbook.io/moped-documentation/dev-guides/hasura/hasura-migrations/development.md).

# Development

Before you get started creating migrations, make sure you have read the entirety of the documentation prior to this section.

{% hint style="danger" %}
**DANGER ZONE**: Migrations are developed in the local host only. You do not apply migrations directly against staging or production. Those migrations are applied solely by the DevOps pipeline through [our GitHub Action workflow](https://github.com/cityofaustin/atd-moped/actions/workflows/migrations-metadata-deployment.yml)
{% endhint %}

### Migration Development in your machine

Branching locally is the only way to safely develop migrations.

To create or review a migration:

1. Create a branch (`git branch your-branch-name`). If you are reviewing a migration, update and check out the branch (`git checkout the-branch-name`).  &#x20;
2. Run the local Hasura cluster, enter `./hasura-cluster start` and wait until you see a "migrations finished" message.
3. Once the servers are ready, you may run `./hasura-cluster console` or `hasura console`. Proceed to make changes to the database, then generate the new migration files.&#x20;
4. If you are reviewing the branch, you may do so here. Make sure there are no errors in the terminal, and that the functionality is there.
5. Save and commit your migration files, then push your changes to your branch in GitHub and make it a PR.
6. Wait until another dev checks out your branch, applies your migrations, and makes sure it is safe to be merged to staging.

Once the PR branch is reviewed, then it can be merged to master where [our GitHub Action workflow](https://github.com/cityofaustin/atd-moped/actions/workflows/migrations-metadata-deployment.yml) will run the new migration against staging. Then the same process will apply the changes to production during our release process or during a patch to production.
