Skip to content

Commit

Permalink
update schema for azure support
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Avetisyan <[email protected]>
  • Loading branch information
havetisyan committed May 23, 2024
1 parent 802f6df commit e79fcc2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
26 changes: 26 additions & 0 deletions servers/zms/schema/schema_update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ZMS Schema Update Instructions

This document provides instructions on how to update the ZMS schema when new features are
added to the Athenz service.

Athenz Authors are using [MySQLWorkbenc](https://dev.mysql.com/downloads/workbench/) to
manage the ZMS schema. The schema is stored in the `servers/zms/schema/zms_server.mwb` file
and the corresponding SQL script is stored in the `servers/zms/schema/zms_server.sql` file.

## Steps to Update the ZMS Schema

1. Open the `zms_server.mwb` file in MySQLWorkbench.
2. Make the necessary changes to the schema.
3. Save the changes to the `zms_server.mwb` file.
4. Export the SQL script by selecting `File` -> `Export` -> `Forward Engineer SQL CREATE Script..`.
5. Specify `zms_server.sql` file as the value for the `Output SQL Script File` field. Make sure no
other options are selected on this page. Click `Continue`.
6. On the next page, make sure `Export MySQL Table Objects` is selected and click `Continue`.
7. Finally, click `Finish` to complete the export process.

## Steps to Generate the Schema Update SQL Script

1. Create a new file in the updates directory with the name `update-<date>.sql` where `<date>` is
the date is the current date (e.g. update-20240523.sql).
2. Include the necessary SQL statements in the file to update an existing schema (e.g. `ALTER TABLE`, etc.).
3. Include the update file as part of your PR.
2 changes: 2 additions & 0 deletions servers/zms/schema/updates/update-20240523.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE `zms_server`.`domain` ADD `azure_tenant` VARCHAR(128) NOT NULL DEFAULT '';
ALTER TABLE `zms_server`.`domain` ADD `azure_client` VARCHAR(128) NOT NULL DEFAULT '';
Binary file modified servers/zms/schema/zms_server.mwb
Binary file not shown.
4 changes: 3 additions & 1 deletion servers/zms/schema/zms_server.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- MySQL Script generated by MySQL Workbench
-- Mon Mar 25 15:21:04 2024
-- Thu May 23 10:22:50 2024
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering

Expand Down Expand Up @@ -51,6 +51,8 @@ CREATE TABLE IF NOT EXISTS `zms_server`.`domain` (
`feature_flags` INT NOT NULL DEFAULT 0,
`environment` VARCHAR(32) NOT NULL DEFAULT '',
`resource_owner` VARCHAR(256) NOT NULL DEFAULT '',
`azure_tenant` VARCHAR(128) NOT NULL DEFAULT '',
`azure_client` VARCHAR(128) NOT NULL DEFAULT '',
PRIMARY KEY (`domain_id`),
UNIQUE INDEX `uq_name` (`name` ASC),
INDEX `idx_modified` (`modified` ASC),
Expand Down

0 comments on commit e79fcc2

Please sign in to comment.