This is an automated email from the ASF dual-hosted git repository.
jerryshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 424fce0df2 [#10770] feat(cache): Add 1.3.0 relational schema (#10912)
424fce0df2 is described below
commit 424fce0df22647d01eda6189d7b1bb92f9d562de
Author: Qi Yu <[email protected]>
AuthorDate: Wed May 6 19:01:24 2026 +0800
[#10770] feat(cache): Add 1.3.0 relational schema (#10912)
### 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.
---------
Co-authored-by: Claude Opus 4.7 <[email protected]>
---
scripts/h2/schema-1.3.0-h2.sql | 20 +++++++++++--
scripts/h2/upgrade-1.2.0-to-1.3.0-h2.sql | 22 +++++++++++++--
scripts/mysql/schema-1.3.0-mysql.sql | 20 +++++++++++--
scripts/mysql/upgrade-1.2.0-to-1.3.0-mysql.sql | 32 +++++++++++++++++++--
scripts/postgresql/schema-1.3.0-postgresql.sql | 33 ++++++++++++++++++++--
.../upgrade-1.2.0-to-1.3.0-postgresql.sql | 32 +++++++++++++++++++--
6 files changed, 147 insertions(+), 12 deletions(-)
diff --git a/scripts/h2/schema-1.3.0-h2.sql b/scripts/h2/schema-1.3.0-h2.sql
index 7804869ec1..f1e959a499 100644
--- a/scripts/h2/schema-1.3.0-h2.sql
+++ b/scripts/h2/schema-1.3.0-h2.sql
@@ -175,8 +175,10 @@ CREATE TABLE IF NOT EXISTS `user_meta` (
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'user current
version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'user last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'user deleted
at',
+ `updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`user_id`),
- CONSTRAINT `uk_mid_us_del` UNIQUE (`metalake_id`, `user_name`,
`deleted_at`)
+ CONSTRAINT `uk_mid_us_del` UNIQUE (`metalake_id`, `user_name`,
`deleted_at`),
+ KEY `idx_user_meta_name_del_upd` (`metalake_id`, `user_name`,
`deleted_at`, `updated_at`)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `role_meta` (
@@ -188,6 +190,7 @@ CREATE TABLE IF NOT EXISTS `role_meta` (
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'role current
version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'role last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'role deleted
at',
+ `updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`role_id`),
CONSTRAINT `uk_mid_rn_del` UNIQUE (`metalake_id`, `role_name`,
`deleted_at`)
) ENGINE=InnoDB;
@@ -285,10 +288,12 @@ CREATE TABLE IF NOT EXISTS `owner_meta` (
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'owner relation
current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'owner relation
last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'owner
relation deleted at',
+ `updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_ow_me_del` (`owner_id`, `metadata_object_id`,
`metadata_object_type`, `deleted_at`),
KEY `idx_oid` (`owner_id`),
- KEY `idx_meid` (`metadata_object_id`)
+ KEY `idx_meid` (`metadata_object_id`),
+ KEY `idx_owner_meta_del_upd_obj` (`deleted_at`, `updated_at`,
`metadata_object_id`)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `model_meta` (
@@ -560,3 +565,14 @@ CREATE INDEX IF NOT EXISTS `idx_table_metrics_composite`
ON `table_metrics`(`table_identifier`, `table_partition`, `metric_ts`);
CREATE INDEX IF NOT EXISTS `idx_job_metrics_identifier_metric_ts`
ON `job_metrics`(`job_identifier`, `metric_ts`);
+
+CREATE TABLE IF NOT EXISTS `entity_change_log` (
+ `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto
increment id',
+ `metalake_name` VARCHAR(128) NOT NULL COMMENT 'metalake name',
+ `entity_type` VARCHAR(32) NOT NULL COMMENT 'METALAKE | CATALOG |
SCHEMA | TABLE | FILESET | TOPIC | MODEL | VIEW',
+ `entity_full_name` VARCHAR(512) NOT NULL COMMENT 'Dot-separated full name of
the affected entity. For ALTER, stores the old name. For DROP, stores the
entity name.',
+ `operate_type` TINYINT UNSIGNED NOT NULL COMMENT 'Operate type code:
1=ALTER, 2=DROP, 3=INSERT. Codes are stable and never re-used.',
+ `created_at` BIGINT NOT NULL COMMENT 'timestamp of the change in
millis',
+ PRIMARY KEY (`id`),
+ KEY `idx_ecl_created_at` (`created_at`)
+) ENGINE=InnoDB COMMENT='Append-only log of entity structural changes for
targeted metadataIdCache invalidation';
diff --git a/scripts/h2/upgrade-1.2.0-to-1.3.0-h2.sql
b/scripts/h2/upgrade-1.2.0-to-1.3.0-h2.sql
index 37ef6365f6..055082e836 100644
--- a/scripts/h2/upgrade-1.2.0-to-1.3.0-h2.sql
+++ b/scripts/h2/upgrade-1.2.0-to-1.3.0-h2.sql
@@ -1,7 +1,7 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements. See the NOTICE file--
--- distributed with this work for additional information
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"). You may not use this file except in compliance
@@ -17,6 +17,24 @@
-- under the License.
--
+ALTER TABLE `user_meta` ADD COLUMN `updated_at` BIGINT(20) UNSIGNED NOT NULL
DEFAULT 0 COMMENT 'updated at';
+ALTER TABLE `role_meta` ADD COLUMN `updated_at` BIGINT(20) UNSIGNED NOT NULL
DEFAULT 0 COMMENT 'updated at';
+ALTER TABLE `owner_meta` ADD COLUMN `updated_at` BIGINT(20) UNSIGNED NOT NULL
DEFAULT 0 COMMENT 'updated at';
+
+CREATE INDEX IF NOT EXISTS `idx_user_meta_name_del_upd` ON
`user_meta`(`metalake_id`, `user_name`, `deleted_at`, `updated_at`);
+CREATE INDEX IF NOT EXISTS `idx_owner_meta_del_upd_obj` ON
`owner_meta`(`deleted_at`, `updated_at`, `metadata_object_id`);
+
+CREATE TABLE IF NOT EXISTS `entity_change_log` (
+ `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto
increment id',
+ `metalake_name` VARCHAR(128) NOT NULL COMMENT 'metalake name',
+ `entity_type` VARCHAR(32) NOT NULL COMMENT 'METALAKE | CATALOG |
SCHEMA | TABLE | FILESET | TOPIC | MODEL | VIEW',
+ `entity_full_name` VARCHAR(512) NOT NULL COMMENT 'Dot-separated full name of
the affected entity. For ALTER, stores the old name. For DROP, stores the
entity name.',
+ `operate_type` TINYINT UNSIGNED NOT NULL COMMENT 'Operate type code:
1=ALTER, 2=DROP, 3=INSERT. Codes are stable and never re-used.',
+ `created_at` BIGINT NOT NULL COMMENT 'timestamp of the change in
millis',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB COMMENT='Append-only log of entity structural changes for
targeted metadataIdCache invalidation';
+CREATE INDEX IF NOT EXISTS `idx_ecl_created_at` ON
`entity_change_log`(`created_at`);
+
-- using default '{}' to fill in the new column for compatibility
ALTER TABLE `view_meta`
ADD COLUMN `audit_info` CLOB NOT NULL DEFAULT '{}' COMMENT 'view audit
info';
diff --git a/scripts/mysql/schema-1.3.0-mysql.sql
b/scripts/mysql/schema-1.3.0-mysql.sql
index 460f4d7826..666e7f7f1d 100644
--- a/scripts/mysql/schema-1.3.0-mysql.sql
+++ b/scripts/mysql/schema-1.3.0-mysql.sql
@@ -166,8 +166,10 @@ CREATE TABLE IF NOT EXISTS `user_meta` (
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'user current
version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'user last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'user deleted
at',
+ `updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`user_id`),
- UNIQUE KEY `uk_mid_us_del` (`metalake_id`, `user_name`, `deleted_at`)
+ UNIQUE KEY `uk_mid_us_del` (`metalake_id`, `user_name`, `deleted_at`),
+ KEY `idx_user_meta_name_del_upd` (`metalake_id`, `user_name`,
`deleted_at`, `updated_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'user
metadata';
CREATE TABLE IF NOT EXISTS `role_meta` (
@@ -179,6 +181,7 @@ CREATE TABLE IF NOT EXISTS `role_meta` (
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'role current
version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'role last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'role deleted
at',
+ `updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`role_id`),
UNIQUE KEY `uk_mid_rn_del` (`metalake_id`, `role_name`, `deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'role
metadata';
@@ -276,10 +279,12 @@ CREATE TABLE IF NOT EXISTS `owner_meta` (
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'owner relation
current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'owner relation
last version',
`deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'owner
relation deleted at',
+ `updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_ow_me_del` (`owner_id`, `metadata_object_id`,
`metadata_object_type`,`deleted_at`),
KEY `idx_oid` (`owner_id`),
- KEY `idx_meid` (`metadata_object_id`)
+ KEY `idx_meid` (`metadata_object_id`),
+ KEY `idx_owner_meta_del_upd_obj` (`deleted_at`, `updated_at`,
`metadata_object_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'owner
relation';
CREATE TABLE IF NOT EXISTS `model_meta` (
@@ -547,3 +552,14 @@ CREATE TABLE IF NOT EXISTS `job_metrics` (
KEY `idx_job_metrics_metric_ts` (`metric_ts`),
KEY `idx_job_metrics_identifier_metric_ts` (`job_identifier`(255),
`metric_ts`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'optimizer
job metrics';
+
+CREATE TABLE IF NOT EXISTS `entity_change_log` (
+ `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto
increment id',
+ `metalake_name` VARCHAR(128) NOT NULL COMMENT 'metalake name',
+ `entity_type` VARCHAR(32) NOT NULL COMMENT 'METALAKE | CATALOG |
SCHEMA | TABLE | FILESET | TOPIC | MODEL | VIEW',
+ `entity_full_name` VARCHAR(512) NOT NULL COMMENT 'Dot-separated full name of
the affected entity. For ALTER, stores the old name. For DROP, stores the
entity name.',
+ `operate_type` TINYINT UNSIGNED NOT NULL COMMENT 'Operate type code:
1=ALTER, 2=DROP, 3=INSERT. Codes are stable and never re-used.',
+ `created_at` BIGINT NOT NULL COMMENT 'timestamp of the change in
millis',
+ PRIMARY KEY (`id`),
+ KEY `idx_ecl_created_at` (`created_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT
'Append-only log of entity structural changes for targeted metadataIdCache
invalidation';
diff --git a/scripts/mysql/upgrade-1.2.0-to-1.3.0-mysql.sql
b/scripts/mysql/upgrade-1.2.0-to-1.3.0-mysql.sql
index 458dec18a6..0fe738120e 100644
--- a/scripts/mysql/upgrade-1.2.0-to-1.3.0-mysql.sql
+++ b/scripts/mysql/upgrade-1.2.0-to-1.3.0-mysql.sql
@@ -1,7 +1,7 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements. See the NOTICE file--
--- distributed with this work for additional information
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"). You may not use this file except in compliance
@@ -17,6 +17,34 @@
-- under the License.
--
+ALTER TABLE `user_meta`
+ ADD COLUMN `updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0
+ COMMENT 'updated at';
+
+ALTER TABLE `role_meta`
+ ADD COLUMN `updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0
+ COMMENT 'updated at';
+
+ALTER TABLE `owner_meta`
+ ADD COLUMN `updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0
+ COMMENT 'updated at';
+
+CREATE INDEX idx_user_meta_name_del_upd
+ ON user_meta (metalake_id, user_name, deleted_at, updated_at);
+CREATE INDEX idx_owner_meta_del_upd_obj
+ ON owner_meta (deleted_at, updated_at, metadata_object_id);
+
+CREATE TABLE IF NOT EXISTS `entity_change_log` (
+ `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto
increment id',
+ `metalake_name` VARCHAR(128) NOT NULL COMMENT 'metalake name',
+ `entity_type` VARCHAR(32) NOT NULL COMMENT 'METALAKE | CATALOG |
SCHEMA | TABLE | FILESET | TOPIC | MODEL | VIEW',
+ `entity_full_name` VARCHAR(512) NOT NULL COMMENT 'Dot-separated full name of
the affected entity. For ALTER, stores the old name. For DROP, stores the
entity name.',
+ `operate_type` TINYINT UNSIGNED NOT NULL COMMENT 'Operate type code:
1=ALTER, 2=DROP, 3=INSERT. Codes are stable and never re-used.',
+ `created_at` BIGINT NOT NULL COMMENT 'timestamp of the change in
millis',
+ PRIMARY KEY (`id`),
+ KEY `idx_ecl_created_at` (`created_at`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT
'Append-only log of entity structural changes for targeted metadataIdCache
invalidation';
+
-- add audit_info as nullable first for MySQL 5.7 compatibility
ALTER TABLE `view_meta`
ADD COLUMN `audit_info` MEDIUMTEXT COMMENT 'view audit info' AFTER
`schema_id`;
diff --git a/scripts/postgresql/schema-1.3.0-postgresql.sql
b/scripts/postgresql/schema-1.3.0-postgresql.sql
index 3a6baea72a..dfead0faff 100644
--- a/scripts/postgresql/schema-1.3.0-postgresql.sql
+++ b/scripts/postgresql/schema-1.3.0-postgresql.sql
@@ -1,7 +1,7 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements. See the NOTICE file--
--- distributed with this work for additional information
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"). You may not use this file except in compliance
@@ -290,6 +290,7 @@ CREATE TABLE IF NOT EXISTS user_meta (
current_version INT NOT NULL DEFAULT 1,
last_version INT NOT NULL DEFAULT 1,
deleted_at BIGINT NOT NULL DEFAULT 0,
+ updated_at BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (user_id),
UNIQUE (metalake_id, user_name, deleted_at)
);
@@ -302,6 +303,7 @@ COMMENT ON COLUMN user_meta.audit_info IS 'user audit info';
COMMENT ON COLUMN user_meta.current_version IS 'user current version';
COMMENT ON COLUMN user_meta.last_version IS 'user last version';
COMMENT ON COLUMN user_meta.deleted_at IS 'user deleted at';
+COMMENT ON COLUMN user_meta.updated_at IS 'updated at';
CREATE TABLE IF NOT EXISTS role_meta (
role_id BIGINT NOT NULL,
@@ -312,6 +314,7 @@ CREATE TABLE IF NOT EXISTS role_meta (
current_version INT NOT NULL DEFAULT 1,
last_version INT NOT NULL DEFAULT 1,
deleted_at BIGINT NOT NULL DEFAULT 0,
+ updated_at BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (role_id),
UNIQUE (metalake_id, role_name, deleted_at)
);
@@ -326,6 +329,7 @@ COMMENT ON COLUMN role_meta.audit_info IS 'role audit info';
COMMENT ON COLUMN role_meta.current_version IS 'role current version';
COMMENT ON COLUMN role_meta.last_version IS 'role last version';
COMMENT ON COLUMN role_meta.deleted_at IS 'role deleted at';
+COMMENT ON COLUMN role_meta.updated_at IS 'updated at';
CREATE TABLE IF NOT EXISTS role_meta_securable_object (
@@ -483,12 +487,18 @@ CREATE TABLE IF NOT EXISTS owner_meta (
current_version INT NOT NULL DEFAULT 1,
last_version INT NOT NULL DEFAULT 1,
deleted_at BIGINT NOT NULL DEFAULT 0,
+ updated_at BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (id),
UNIQUE (owner_id, metadata_object_id, metadata_object_type, deleted_at)
);
CREATE INDEX IF NOT EXISTS owner_meta_idx_owner_id ON owner_meta (owner_id);
CREATE INDEX IF NOT EXISTS owner_meta_idx_metadata_object_id ON owner_meta
(metadata_object_id);
+CREATE INDEX IF NOT EXISTS idx_user_meta_name_del_upd
+ ON user_meta (metalake_id, user_name, deleted_at, updated_at);
+CREATE INDEX IF NOT EXISTS idx_owner_meta_del_upd_obj
+ ON owner_meta (deleted_at, updated_at, metadata_object_id);
+
COMMENT ON TABLE owner_meta IS 'owner relation';
COMMENT ON COLUMN owner_meta.id IS 'auto increment id';
COMMENT ON COLUMN owner_meta.metalake_id IS 'metalake id';
@@ -500,6 +510,7 @@ COMMENT ON COLUMN owner_meta.audit_info IS 'owner relation
audit info';
COMMENT ON COLUMN owner_meta.current_version IS 'owner relation current
version';
COMMENT ON COLUMN owner_meta.last_version IS 'owner relation last version';
COMMENT ON COLUMN owner_meta.deleted_at IS 'owner relation deleted at';
+COMMENT ON COLUMN owner_meta.updated_at IS 'updated at';
CREATE TABLE IF NOT EXISTS model_meta (
@@ -964,3 +975,21 @@ COMMENT ON COLUMN job_metrics.job_identifier IS
'normalized job identifier';
COMMENT ON COLUMN job_metrics.metric_name IS 'metric name';
COMMENT ON COLUMN job_metrics.metric_ts IS 'metric timestamp in epoch seconds';
COMMENT ON COLUMN job_metrics.metric_value IS 'metric value payload';
+
+CREATE TABLE IF NOT EXISTS entity_change_log (
+ id BIGSERIAL PRIMARY KEY,
+ metalake_name VARCHAR(128) NOT NULL,
+ entity_type VARCHAR(32) NOT NULL,
+ entity_full_name VARCHAR(512) NOT NULL,
+ -- Operate type code: 1=ALTER, 2=DROP, 3=INSERT. Codes are stable and
never re-used.
+ operate_type SMALLINT NOT NULL,
+ created_at BIGINT NOT NULL
+);
+CREATE INDEX IF NOT EXISTS idx_ecl_created_at ON entity_change_log(created_at);
+COMMENT ON TABLE entity_change_log IS 'Append-only log of entity structural
changes for targeted metadataIdCache invalidation';
+COMMENT ON COLUMN entity_change_log.id IS 'auto increment id';
+COMMENT ON COLUMN entity_change_log.metalake_name IS 'metalake name';
+COMMENT ON COLUMN entity_change_log.entity_type IS 'METALAKE | CATALOG |
SCHEMA | TABLE | FILESET | TOPIC | MODEL | VIEW';
+COMMENT ON COLUMN entity_change_log.entity_full_name IS 'Dot-separated full
name of the affected entity. For ALTER, stores the old name. For DROP, stores
the entity name.';
+COMMENT ON COLUMN entity_change_log.operate_type IS 'Operate type code:
1=ALTER, 2=DROP, 3=INSERT. Codes are stable and never re-used.';
+COMMENT ON COLUMN entity_change_log.created_at IS 'timestamp of the change in
millis';
diff --git a/scripts/postgresql/upgrade-1.2.0-to-1.3.0-postgresql.sql
b/scripts/postgresql/upgrade-1.2.0-to-1.3.0-postgresql.sql
index c7e88c8582..2eff52800b 100644
--- a/scripts/postgresql/upgrade-1.2.0-to-1.3.0-postgresql.sql
+++ b/scripts/postgresql/upgrade-1.2.0-to-1.3.0-postgresql.sql
@@ -1,7 +1,7 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements. See the NOTICE file--
--- distributed with this work for additional information
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"). You may not use this file except in compliance
@@ -17,6 +17,34 @@
-- under the License.
--
+ALTER TABLE user_meta ADD COLUMN IF NOT EXISTS updated_at BIGINT NOT NULL
DEFAULT 0;
+ALTER TABLE role_meta ADD COLUMN IF NOT EXISTS updated_at BIGINT NOT NULL
DEFAULT 0;
+ALTER TABLE owner_meta ADD COLUMN IF NOT EXISTS updated_at BIGINT NOT NULL
DEFAULT 0;
+COMMENT ON COLUMN user_meta.updated_at IS 'updated at';
+COMMENT ON COLUMN role_meta.updated_at IS 'updated at';
+COMMENT ON COLUMN owner_meta.updated_at IS 'updated at';
+
+CREATE INDEX IF NOT EXISTS idx_user_meta_name_del_upd ON user_meta
(metalake_id, user_name, deleted_at, updated_at);
+CREATE INDEX IF NOT EXISTS idx_owner_meta_del_upd_obj ON owner_meta
(deleted_at, updated_at, metadata_object_id);
+
+CREATE TABLE IF NOT EXISTS entity_change_log (
+ id BIGSERIAL PRIMARY KEY,
+ metalake_name VARCHAR(128) NOT NULL,
+ entity_type VARCHAR(32) NOT NULL,
+ entity_full_name VARCHAR(512) NOT NULL,
+ -- Operate type code: 1=ALTER, 2=DROP, 3=INSERT. Codes are stable and
never re-used.
+ operate_type SMALLINT NOT NULL,
+ created_at BIGINT NOT NULL
+);
+CREATE INDEX IF NOT EXISTS idx_ecl_created_at ON entity_change_log(created_at);
+COMMENT ON TABLE entity_change_log IS 'Append-only log of entity structural
changes for targeted metadataIdCache invalidation';
+COMMENT ON COLUMN entity_change_log.id IS 'auto increment id';
+COMMENT ON COLUMN entity_change_log.metalake_name IS 'metalake name';
+COMMENT ON COLUMN entity_change_log.entity_type IS 'METALAKE | CATALOG |
SCHEMA | TABLE | FILESET | TOPIC | MODEL | VIEW';
+COMMENT ON COLUMN entity_change_log.entity_full_name IS 'Dot-separated full
name of the affected entity. For ALTER, stores the old name. For DROP, stores
the entity name.';
+COMMENT ON COLUMN entity_change_log.operate_type IS 'Operate type code:
1=ALTER, 2=DROP, 3=INSERT. Codes are stable and never re-used.';
+COMMENT ON COLUMN entity_change_log.created_at IS 'timestamp of the change in
millis';
+
ALTER TABLE view_meta
ADD COLUMN IF NOT EXISTS audit_info TEXT NOT NULL DEFAULT '{}';