Files
documentdb/pg_documentdb/sql/rbac/extension_admin_setup--0.10-0.sql
T
Zinan Ren 47ec4231ba Merged PR 1543189: [OSS] Porting type/operator/schema into documentdb - part 1
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactoring
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Yes
### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

Start porting schemas for documentdb api.
Introducing API_SCHEMA_NAME_V2, API_SCHEMA_INTERNAL_NAME_V2, API_CATALOG_SCHEMA_NAME_V2

----
#### AI description  (iteration 1)
#### PR Classification
Porting type/operator/schema into documentdb.

#### PR Summary
This pull request ports various types, operators, and schemas into documentdb as part of an ongoing effort.
- `pg_documentdb/sql/documentdb--0.24-0.sql`: Created multiple schemas and included various SQL files for query functions, operators, and metadata.
- `pg_documentdb/sql/operators/bson_dollar_operators--0.16-0.sql`: Updated operator definitions to use `__API_SCHEMA_INTERNAL_V2__`.
- `pgmongo/sql/operators/bson_dollar_negation_operators--1.15-1.sql` and `pg_documentdb/sql/operators/bson_dollar_negation_operators--0.16-0.sql`: Changed operator definitions to use `__API_SCHEMA_INTERNAL_V2__`.
- `Makefile.cflags`: Added checks for new schema variables `API_SCHEMA_NAME_V2`, `API_SCHEMA_INTERNAL_NAME_V2`, and `API_CATALOG_SCHEMA_NAME_V2`.
- `pg_documentdb/sql/schema/unique_shard_path_operator_class--0.24-0.sql`: Updated operator class definitions to use `__API_SCHEMA_INTERNAL_V2__`.
2025-01-15 07:48:40 +00:00

26 lines
1.3 KiB
SQL

DO
$do$
BEGIN
/*
* The role is a system-wide object which is not dropped if the extension
* is dropped. Therefore, if __API_SCHEMA__ api is repeatedly created and dropped,
* a regular CREATE ROLE would fail since __API_ADMIN_ROLE__ still exists.
* We therefore only create the role if it does not exist.
*/
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = __SINGLE_QUOTED_STRING__(__API_ADMIN_ROLE__)) THEN
CREATE ROLE __API_ADMIN_ROLE__;
END IF;
END
$do$;
GRANT SELECT ON TABLE __API_CATALOG_SCHEMA__.collections TO public;
GRANT SELECT ON TABLE __API_CATALOG_SCHEMA__.collection_indexes TO public;
GRANT USAGE ON SCHEMA __API_CATALOG_SCHEMA__ TO __API_ADMIN_ROLE__;
GRANT USAGE ON SCHEMA __API_SCHEMA_INTERNAL__ TO __API_ADMIN_ROLE__;
GRANT USAGE ON SCHEMA __API_SCHEMA__ TO __API_ADMIN_ROLE__;
GRANT USAGE ON SCHEMA public TO __API_ADMIN_ROLE__;
GRANT ALL ON SCHEMA __API_DATA_SCHEMA__ TO __API_ADMIN_ROLE__;
GRANT ALL ON TABLE __API_CATALOG_SCHEMA__.collections TO __API_ADMIN_ROLE__;
GRANT ALL ON TABLE __API_CATALOG_SCHEMA__.collection_indexes TO __API_ADMIN_ROLE__;
GRANT ALL ON SEQUENCE __API_CATALOG_SCHEMA__.collections_collection_id_seq TO __API_ADMIN_ROLE__;
GRANT ALL ON SEQUENCE __API_CATALOG_SCHEMA__.collection_indexes_index_id_seq TO __API_ADMIN_ROLE__;