# royalty_accounting DB

The royalty_accounting MySQL database is primarily used by the abacus applications [in the inventory](https://docs.google.com/spreadsheets/d/16x-qfzHrdJkwQ-Xfa16vhh8V1YTHFNgVNL80Gj_qLuM/edit#gid=0)

## Creating a New File

Create a new file according to [Formatting and Best Practices](#formatting-and-best-practices).

For example:

- changelog/ddl/db-change-you-want-to-run.sql
- changelog/dml/db-data-change-you-want-to-run.sql

## The Database Changelog

The [db.changelog-master.xml](./db.changelog-master.xml) is used by the above
services to migrate the database on docker builds and deploys.
It is important to keep the schema up-to-date to ensure these services
have the latest DB changes.

> Please omit PRs that contain actual data or permission grants. The
changelog should only be used to build to correct schema in standalone environments.

## Creating a PR

PRs normally consist of a new *ddl* or *dml* file and an associated
entry in the changelog. Add the label *royalty_accounting* like in the
example ![Github PR label royalty_accounting](./github_pr_label_example.png)
This will run the PR using the
[royalty-accounting-db-pull-request job](https://pipeline.theorchard.io/job/royalty-accounting-db-pull-request/)

## Deploying the changelog to QA

Use the
[royalty-accounting-db-deploy job](https://pipeline.theorchard.io/job/royalty-accounting-db-deploy/)
to run the latest version of the changelog against the QA database.

Use the [db-deploy job](https://pipeline.theorchard.io/job/db-deploy/) to
run data or permissions migrations.
