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 for the latest update (#1049)
Danny Xu09be60cc3b4a
diff --git a/docs/schema-update-guide.md b/docs/schema-update-guide.mdindex add6e27423..d99b694d5a 100644--- a/docs/schema-update-guide.md+++ b/docs/schema-update-guide.md@@ -1,23 +1,38 @@# Schema Update Guide-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.+This document goes over the scheme update process during development and production release.-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.+All schemas are located at [store/migration](https://github.com/bytebase/bytebase/tree/main/store/migration). Bytebase schema release follows semantic versioning.-## Development+Prod++- [prod](https://github.com/bytebase/bytebase/tree/main/store/migration/prod) schema.+- `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`. When a prod release binary starts, it will apply all the schema migrations from current version up to the latest schema release version.++Dev++- [dev](https://github.com/bytebase/bytebase/tree/main/store/migration/dev) schema.+- `LATEST.sql` and `LATEST_DATA.sql` will only be used to view the latest schema. This is different Prod.+- When a dev release binary starts, it will use the LATEST.sql in the release directory to initialize the database and then apply all the DDLs in the dev directory if not yet applied.-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.+Demo Data++- When the binary starts in Demo mode, we will seed demo data to provide a better onboarding experience.+- [Dev demo data](https://github.com/bytebase/bytebase/tree/main/store/demo/dev).+- [Prod demo data](https://github.com/bytebase/bytebase/tree/main/store/demo/prod).++## Development-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, such as [this example](https://github.com/bytebase/bytebase/pull/1039).+1. Add a DDL SQL file such as `dev/20220408000000__schema_version_type.sql`. The prefix numbers should be the date time format when the PR is sent.+2. Update `LATEST.sql` and `LATEST_DATA.sql` w.r.t. the DDL changes. (TODO: auto-generate the latest schema)+3. Update Dev Demo data if needed.+4. 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, such as [this example](https://github.com/bytebase/bytebase/pull/1039).## ReleaseReleaser 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.+1. Move DDLs to be released from `dev` to `release/1.6`. Rename DDL SQL file prefixes in sure the prefixes are in consecutively increasing order starting from `0000`.+2. Update `prod/LATEST.sql` and `prod/LATEST_DATA.sql` w.r.t. DDLs to be released. (TODO: auto-generate the latest schema)+3. Copy over Dev Demo data to Prod Demo directory for the changes to be released.