-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove duplicate user model * Add base models * Add new views for permission management * Add num_columns to table_stats * Use quotes in full_object_name. Small tweaks to formatting
- Loading branch information
Showing
6 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
select | ||
schemaname as schema_name | ||
, tablename as table_name | ||
, tableowner as table_owner | ||
, tablespace as table_space | ||
, hasindexes as has_indexes | ||
, hasrules as has_rules | ||
, hastriggers as has_triggers | ||
from pg_tables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
select | ||
schemaname as schema_name | ||
, viewname as view_name | ||
, viewowner as view_owner | ||
from pg_views |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
with tables as ( | ||
|
||
select * from {{ref('pg_tables')}} | ||
|
||
), views as ( | ||
|
||
select * from {{ref('pg_views')}} | ||
|
||
), users as ( | ||
|
||
select * from {{ref('pg_user')}} | ||
|
||
), schemas as ( | ||
|
||
select | ||
distinct(schema_name) | ||
from tables | ||
where schema_name not in ('pg_catalog', 'information_schema') | ||
|
||
union | ||
|
||
select | ||
distinct(schema_name) | ||
from views | ||
|
||
where schema_name not in ('pg_catalog', 'information_schema') | ||
|
||
) | ||
|
||
|
||
select | ||
schemas.schema_name | ||
, users.username | ||
, has_schema_privilege(users.username, schemas.schema_name, 'usage') AS has_usage_privilege | ||
, has_schema_privilege(users.username, schemas.schema_name, 'create') AS has_create_privilege | ||
from schemas | ||
cross join users | ||
order by schemas.schema_name, users.username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
with tables as ( | ||
|
||
select * from {{ref('pg_tables')}} | ||
|
||
), views as ( | ||
|
||
select * from {{ref('pg_views')}} | ||
|
||
), users as ( | ||
|
||
select * from {{ref('pg_user')}} | ||
|
||
), objects as ( | ||
|
||
select | ||
schema_name | ||
, 'table' as object_type | ||
, table_name as object_name | ||
, '"' || schema_name || '"."' || table_name || '"' as full_object_name | ||
from tables | ||
where schema_name not in ('pg_catalog', 'information_schema') | ||
|
||
union | ||
|
||
select | ||
schema_name | ||
, 'view' as object_type | ||
, view_name as object_name | ||
, '"' || schema_name || '"."' || view_name || '"' as full_object_name | ||
from views | ||
where schema_name not in ('pg_catalog', 'information_schema') | ||
|
||
) | ||
|
||
select | ||
objects.schema_name | ||
, objects.object_name | ||
, users.username | ||
, has_table_privilege(users.username, objects.full_object_name, 'select') as has_select_privilege | ||
, has_table_privilege(users.username, objects.full_object_name, 'insert') as has_insert_privilege | ||
, has_table_privilege(users.username, objects.full_object_name, 'update') as has_update_privilege | ||
, has_table_privilege(users.username, objects.full_object_name, 'delete') as has_delete_privilege | ||
, has_table_privilege(users.username, objects.full_object_name, 'references') as has_references_privilege | ||
from objects | ||
cross join users | ||
order by objects.full_object_name, users.username |