Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace right_types table with constraint #1001

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [#165](https://github.com/LayerManager/layman/issues/165) Add column `role_name` to table `rights` in prime DB schema. Add constraint that exactly one of columns `role_name` and `id_user` is not null.
- [#165](https://github.com/LayerManager/layman/issues/165) Create DB schema `_role_service` that can be used as [role service](doc/security.md#role-service).
- [#165](https://github.com/LayerManager/layman/issues/165) Column `name` in table `workspace` in prime DB schema length is changed to 59 characters.
- Drop DB table `right_types`.
#### Data migrations
- [#165](https://github.com/LayerManager/layman/issues/165) Delete technical roles and user-role relations in GeoServer `default` role service, which is now replaced by JDBC role service.
### Changes
Expand Down
1 change: 1 addition & 0 deletions src/layman/upgrade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
upgrade_v1_23.adjust_db_for_roles,
upgrade_v1_23.restrict_workspace_name_length,
upgrade_v1_23.create_role_service_schema,
upgrade_v1_23.remove_right_types_table,
]),
],
consts.MIGRATION_TYPE_DATA: [
Expand Down
13 changes: 13 additions & 0 deletions src/layman/upgrade/upgrade_v1_23.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,16 @@ def restrict_workspace_name_length():
ALTER COLUMN name TYPE VARCHAR(59) COLLATE pg_catalog."default"
;"""
db_util.run_statement(alter_column)


def remove_right_types_table():
logger.info(f' Remove right_types table')

remove_fk_statement = f"""alter table {settings.LAYMAN_PRIME_SCHEMA}.rights drop constraint rights_type_fkey;"""
db_util.run_statement(remove_fk_statement)

create_check_statement = f"""alter table {settings.LAYMAN_PRIME_SCHEMA}.rights add constraint rights_type check (type in ('read', 'write'));"""
db_util.run_statement(create_check_statement)

drop_table_statement = f"""drop table {settings.LAYMAN_PRIME_SCHEMA}.right_types"""
db_util.run_statement(drop_table_statement)