graphql-engine: Cannot drop column from table that has update permissions

Version Information

Server Version: 2.6.0-beta.1

Environment

Cloud / OSS

What is the expected behaviour?

Users should be able to drop columns from tables, as long as the column is not explicitly used in any of the table permissions.

Keywords

Hasura drop inconsistency permissions

What is the current behaviour?

When update permissions exist on a table, columns cannot be dropped from the table. An error is throw cannot drop due to the following dependent objects : permission talbe_name.role_name.update in source "pg1" The user is allowed to “continue by dropping dependent items”, but this will delete the entire update permission for the table.

How to reproduce the issue?

  1. Create and track the following table
CREATE TABLE test (id INT, name TEXT);
  1. Create update permissions for it. Do not reference the name column image
  2. Attempt to delete the name column
  3. An error is thrown cannot drop due to the following dependent objects : permission test.user.update in source "pg1"

Possibly related, but choosing to delete the inconsistent metadata as well runs into #8414 and the entire update permission is deleted.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 9
  • Comments: 22 (6 by maintainers)

Most upvoted comments

Facing this issue in 2.8.4

Fixed by https://github.com/hasura/graphql-engine/commit/7634be3216b6ef16a7983ca3d2f043fddf47bc6d. Closing this now, please feel free to re-open if the issue still exists.

Also facing this in v2.9.0

Fixed in 2.10.0

@srflorea1 there are two ways to work around this:

Option 1

  1. Back up your metadata by exporting it (either with cli or as a json file from the console)
  2. Ensure the column is not mentioned in insert, select, update, or delete permissions, either as a selected column or part of the permission check
  3. Drop the column using a third party sql client, (this bypasses the consistency check hasura does).
  4. From the hasura console settings, reload all databases
  5. Hasura should now be consistent and your column should be gone

Keep in mind that if you mess up step 1 your metadata will be inconsistent and you will need to fix it by removing any references to the column.

Option 2

  1. Back up your metadata by exporting it (either with cli or as a json file from the console)
  2. Remove all update permissions from the concerned table
  3. Drop your column from the console UI
  4. Add your update permissions back
    • (if your permissions don’t mention the dropped column, you can restore the metadata from step 0)

@tirumaraiselvan - Additional info v2.6.2-cloud

Problem: Dropped column is still referenced in mutation root result.

{“exec_status”:“FatalError”,“hint”:null,“message”:“column _0_root.base.settings does not exist”,“status_code”:“42703”,“description”:null}

Steps:

  1. Delete all update permissions (to allow column to be dropped due to update dependency issue)
  2. Drop column ‘settings’
  3. Add new column ‘manager_email’ to user table
  4. Recreate update permissions

Thanks!

Also facing this in v2.9.0

@BenoitRanque Looking into this.

@BenoitRanque I checked it again today and either the issue was resolved by recent updates or else it was user error to begin with. Thanks for following up.

Experiencing this on v2.5.1 as well