Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
docs: update schema update guide (#1012)
Danny Xu56f0df7112ec
diff --git a/docs/schema-update-guide.md b/docs/schema-update-guide.mdindex 216f7aa071..2fff63ba8e 100644--- a/docs/schema-update-guide.md+++ b/docs/schema-update-guide.md@@ -2,24 +2,22 @@All schemas are located at [store/migration](https://github.com/bytebase/bytebase/tree/main/store/migration). Bytebase schema release follows semantic versioning. This document goes over the scheme update process during development and release.-## Development-We use different schema versions for [dev](https://github.com/bytebase/bytebase/blob/main/bin/server/cmd/profile_dev.go) and [release](https://github.com/bytebase/bytebase/blob/main/bin/server/cmd/profile_release.go).+We use different schemas for [dev](https://github.com/bytebase/bytebase/tree/main/store/migration/dev) and [release](https://github.com/bytebase/bytebase/tree/main/store/migration/release). The `LATEST.sql` and `LATEST_DATA.sql` will be the schema and data to initialize a new database. The version directory such as `1.1` contains all the DDL statements used to migrate from previous version of schema such as `1.0`. There should only one version in dev schema directory.-If schema versions in dev/release profiles are the same (e.g. 1.1.0), which means we are starting a new MINOR version update cycle.-1. Create a new directory under [migration directory](https://github.com/bytebase/bytebase/tree/main/store/migration) with the new version, e.g. 1.2.0.-2. Copy over the schema and data file from the previous version. e.g. [1.1.0/latest.sql](https://github.com/bytebase/bytebase/blob/main/store/migration/1.1.0/latest.sql) and [1.1.0/latest_data.sql](https://github.com/bytebase/bytebase/blob/main/store/migration/1.1.0/latest_data.sql). And make a PR for the changes above.-3. Bump up the MINOR version in the [dev schema version](https://github.com/bytebase/bytebase/blob/main/bin/server/cmd/profile_dev.go), e.g. 1.1.0 will be 1.2.0.-4. Add a new SQL file with DDL statements with a descriptive name, e.g. [0000_github_com.sql](https://github.com/bytebase/bytebase/blob/main/store/migration/1.1.0/0000_github_com.sql).-5. Update latest.sql and latest_data.sql data file w.r.t. DDL changes.-6. Update the demo data in the test directory.+## Development-If schema versions in dev/release profiles are different, which means we are in the middle of a MINOR version update cycle already.-1. Continue from step 4 above. Add DDL file and update latest.sql and latest_data.sql, e.g. [0001_sheet_vcs.sql](https://github.com/bytebase/bytebase/blob/main/store/migration/1.1.0/0001_sheet_vcs.sql).+Let's take an example that our release is at version `1.5` and dev at version `1.6`. There is `1.6/0000__placeholder.sql` file in the dev version directory that does nothing other than letting people to follow it.-Since we use the same code for both dev and release schemas, we should add if-else branching to read storage differently based on schema version.+1. Add a new SQL file for the DDL such as `1.6/0001__roofshot.sql`. The prefix numbers should be in consecutively increasing order such as `0001__rootshot.sql` then `0002__moonshot.sql`.+1. Update `LATEST.sql` and `LATEST_DATA.sql` w.r.t. the DDL changes. (TODO: auto-generate the latest schema)+1. Update [dev demo data](https://github.com/bytebase/bytebase/tree/main/store/demo/dev) if needed.+1. Since we use the same code for both dev and release schemas, we should add if-else branching to read storage differently based on schema version. (TODO: add example later)## Release-We will take the following steps for the release with schema update, at most once a month. Every feature, a DDL file, should stage at least two weeks just in case any plan changes before moving to the release.-1. Bump up the MINOR version in the release schema version.-1. Copy over the demo data under demo/test directory to demo/release directory.-1. Move the DDL files and update latest.sql to the next version (unreleased) if they are not ready yet.+Releaser should take the following steps for schema update release, at most once a month. A DDL file should only be moved forward to release only if the feature is completed and well tested.++1. Create a new version directory in the release directory, such as `release/1.6`.+1. Move DDLs to be released from `dev/1.6` to `release/1.6`. Rename DDL SQL file prefixes in sure the prefixes are in consecutively increasing order starting from `0000`.+2. Rename directory `dev/1.6` to `dev/1.7` which should contain the placeholder SQL file `dev/1.7/0000__placeholder.sql` at least. Rename DDL SQL file prefixes in sure the prefixes are in consecutively increasing order.+3. Update `release/LATEST.sql` and `release/LATEST_DATA.sql` w.r.t. DDLs to be released. This is a [PR example](https://github.com/bytebase/bytebase/pull/1011) so far. (TODO: auto-generate the latest schema)+4. Copy over dev demo data to release demo directory for the changes to be released.