Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note to check liquibase command run correctly #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions maintainer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ New releases are made every set period of time (typically every week), in which
* Before release day:
* [Create an issue for the release](https://github.com/TEAMMATES/teammates/issues/new?template=release.md) to announce the scheduled release time.
* Update the "about page" with the names of new contributors, if any.
* Check if any schema change is needed for this release. If so, inform PM that this release requires maintainance mode and generate Liquibase changelog (refer to [Schema Migration](#schema-migration)).
* Check if any schema change is needed for this release. If so, generate Liquibase changelog (refer to [Schema Migration](#schema-migration)) and inform PM that this release requires maintainance mode.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is maintenance mode needed? I thought that prod should never go down for schema changes, we could correct this here

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully, most schema changes are backward compatible (i.e., no need to go into maintenance mode) but some might not be. So, should cover both cases in the docs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@damithc schema changes + data migration in SQL is no different than that in Datastore. There is no need for any additional concern.


* Release day:
* Ensure all PRs included in the release are tagged with the correct milestone, correct assignee(s), and appropriate `c.*` label.
* Ensure all schema change is captured in the Liquibase changelog.
Expand Down Expand Up @@ -156,18 +157,25 @@ Since the detail of such vulnerability cannot be disclosed until it is fixed, an
The complete details can be filled in just before merging and/or after the fix is deployed.

### Schema migration
Schema migration is necessary when tables/ columns are amended/ added. Refer to TEAMMATES repo [docs/schema-migration.md](https://github.com/TEAMMATES/teammates/tree/master/docs/schema-migration.md)
Schema migration is necessary when tables / columns are amended/ added. Refer to TEAMMATES repo [docs/schema-migration.md](https://github.com/TEAMMATES/teammates/tree/master/docs/schema-migration.md)

**Role: RL**
Note on release number: Since Liquibase runs changelogs in the order included in the `db.changelog-root.xml` irrespective of lexicographical order, so include the newest changelog at the bottom of the file
* Follow dev guide to create new changelog with name `db.changelog-<release_number>.xml`. The previous release is the base and the new release is the target branch.
* Manually add a new changeset to the bottom of changelog file, to tag the database (Refer to [official liquibase documentation](https://docs.liquibase.com/change-types/tag-database.html)).
* Ensure new changelog is in `src/main/resources/db/changelog` and add it as the last entry in `src/main/resources/db/changelog/db.changelog-root.xml`
* Notify PM of schema change for them to run on production database.

Note on release number: Since Liquibase runs changelogs in the order included in the `db.changelog-root.xml` irrespective of lexicographical order, so include the newest changelog at the bottom of the file.

Before Release:

1. Follow dev guide to create new changelog with name `db.changelog-<release_number>.xml`. The previous release is the base and the new release is the target branch.
2. Manually add a new changeset to the bottom of changelog file, to tag the database (Refer to [official liquibase documentation](https://docs.liquibase.com/change-types/tag-database.html)).
3. Ensure new changelog is in `src/main/resources/db/changelog` and add it as the last entry in `src/main/resources/db/changelog/db.changelog-root.xml`
4. Notify PM of schema change for them to run on production database.

**Role: PM**
* In `gradle.properties` amend the fields `liquibaseDbUrl`, `liquibaseUsername` and `liquibasePassword` to match the IP and the username and password for the role (i.e. super user) used to run command on Cloud SQL
* Run `./gradlew liquibaseUpdateToTag -PliquibaseCommandValue="<release-num>"`
1. In `gradle.properties` amend the fields `liquibaseDbUrl`, `liquibaseUsername` and `liquibasePassword` to match the IP and the username and password for the role (i.e. super user) used to run command on Cloud SQL
2. Run `./gradlew liquibaseUpdateToTag -PliquibaseCommandValue="<release-num>"`
3. To double check that database has updated to the tag, use database query tool (e.g. DBeaver) to check the latest entry of table `DATABASECHANGELOG`, which should be about adding the new tag `<release-num>`.

Refer to TEAMMATES repo `src/main/resources/db/changelog/db.changelog-<release-num>.xml` for the exact schema changes.

### Data migration

Expand Down
Loading