[#10770] feat(cache): Add 1.3.0 relational schema#10912
[#10770] feat(cache): Add 1.3.0 relational schema#10912yuqi1129 wants to merge 5 commits intoapache:mainfrom
Conversation
| `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
| `metalake_name` VARCHAR(128) NOT NULL, | ||
| `entity_type` VARCHAR(32) NOT NULL, | ||
| `full_name` VARCHAR(512) NOT NULL, |
There was a problem hiding this comment.
Why do u use full name here?
There was a problem hiding this comment.
Do you have a good suggestion here? I need to recode the name of an entity( in fact, full name).
There was a problem hiding this comment.
Should we use entity id here? Name will change.
There was a problem hiding this comment.
This is the change log, and it's okay to store the name. Using ID will make us query the database to get the names, so I'm relunctant to use ID here.
There was a problem hiding this comment.
Name will involve the order issues. If two tables rename the same table, what will it happen?
There was a problem hiding this comment.
The table will record the old name and invalid the cache related to it
There was a problem hiding this comment.
Just feel that id will be better than name. Name relies on the correct order. It's ok for us now at least.
There was a problem hiding this comment.
Pull request overview
Adds the 1.3.0 relational storage schema/upgrade steps across PostgreSQL, MySQL, and H2 to support upcoming cache consistency improvements (via updated_at tracking and an entity change log table).
Changes:
- Add
updated_atcolumns touser_meta,role_meta,group_meta, andowner_meta. - Add
entity_change_logtable (pluscreated_atindex). - Add additional covering indexes in upgrade scripts to support
updated_at-based polling/lookups.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/postgresql/upgrade-1.2.0-to-1.3.0-postgresql.sql | Adds updated_at columns, new indexes, and entity_change_log for PostgreSQL upgrades. |
| scripts/postgresql/schema-1.3.0-postgresql.sql | Updates PostgreSQL baseline schema with updated_at columns and entity_change_log. |
| scripts/mysql/upgrade-1.2.0-to-1.3.0-mysql.sql | Adds updated_at columns (with detailed comments), new covering indexes, and entity_change_log for MySQL upgrades. |
| scripts/mysql/schema-1.3.0-mysql.sql | Updates MySQL baseline schema with updated_at columns and entity_change_log. |
| scripts/h2/upgrade-1.2.0-to-1.3.0-h2.sql | Adds updated_at columns, new indexes, and entity_change_log for H2 upgrades. |
| scripts/h2/schema-1.3.0-h2.sql | Updates H2 baseline schema with updated_at columns and entity_change_log. |
bee9ef1 to
9a272fa
Compare
Code Coverage Report
|
c0c1be1 to
c9bbd22
Compare
c9bbd22 to
7948604
Compare
- MySQL upgrade: add ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin on entity_change_log so upgraded installs match fresh-install storage engine. - MySQL upgrade and schema: add 'auto increment id' column COMMENT and 'metalake name' column COMMENT for parity with H2. - MySQL upgrade: align table COMMENT with schema-1.3.0. - H2 / PostgreSQL upgrade: fix license header typos in NOTICE line. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Index leads with PK column role_id, so it provides no faster access than the clustered index for the only consumer (batchGetRoleUpdatedAt: WHERE role_id IN (...) AND deleted_at = 0). It also lacks role_name, forcing a bookmark lookup back to the clustered index. The PK already serves this query optimally.
PG schema-1.3.0 carried short generic comments while MySQL/H2 schema and the PG upgrade script carried the descriptive ones. Sync PG schema to use the same comments as the rest, and fix a leftover double-space typo on the license header.
What changes were proposed in this pull request?
Add the 1.3.0 relational schema and upgrade scripts for H2, MySQL, and PostgreSQL, and bump the current script version to 1.3.0.
Why are the changes needed?
This is the database schema foundation for the cache improvement work. It only includes SQL and version changes.
Fix: #
Does this PR introduce any user-facing change?
No user-facing API change. This updates backend relational storage schema scripts.
How was this patch tested?
Ran targeted relational tests in the stacked branches after rebasing on this schema branch.