需要在删除表时撤销权限吗?

huangapple go评论52阅读模式
英文:

Do I need to REVOKE permissions when a table is dropped

问题

需要在降级迁移中添加以下内容吗?
```sql
REVOKE SELECT, INSERT, DELETE ON table1 FROM user;
英文:

As part of a migration I create a table and grant permissions to a user. Do I need to REVOKE the permissions on my downgrade migration which already drops the table?

--- up.sql

CREATE TABLE IF NOT EXISTS table1 (id int primary key);

GRANT SELECT, INSERT, DELETE ON TABLE table1 TO user1;
--- down.sql

DROP TABLE IF EXISTS table1;

Do I need to add the following or is it implicit?

REVOKE SELECT, INSERT, DELETE ON table1 FROM user;

答案1

得分: 1

如果您丢弃一个对象,它的所有权限也会丢失。这是因为权限存储在对象本身上:在表的情况下,权限存储在pg_class表的relacl列中(其中存储了所有表)。

英文:

If you drop an object, all its privileges are also gone. That is because privileges are stored on the object itself: in the case of a table, the privileges are stored in the relacl column of the pg_class table (where all tables are stored).

huangapple
  • 本文由 发表于 2023年7月20日 17:45:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76728612.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定