Skip to content

Commit

Permalink
Replace right_types table with constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Jan 18, 2024
1 parent 72a5bdd commit fbf710f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
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)

0 comments on commit fbf710f

Please sign in to comment.