-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new view to fecth existing comments
- Loading branch information
Showing
10 changed files
with
241 additions
and
7 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
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 |
---|---|---|
|
@@ -85,6 +85,11 @@ CREATE VIEW @[email protected]_column_comments AS | |
-- | ||
-- | ||
-- | ||
-- | ||
-- schedoc_exclude_tool(tool text) | ||
-- schedoc_exclude_tools_all() | ||
-- schedoc_is_table_excluded(tableoid oid) | ||
-- | ||
-- Set up the exclusion list | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_exclude_tool(tool text) | ||
|
@@ -107,6 +112,26 @@ BEGIN | |
END; | ||
$EOF$; | ||
-- | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_exclude_tools_all() | ||
RETURNS text | ||
LANGUAGE plpgsql AS | ||
$EOF$ | ||
DECLARE | ||
nbrows bigint; | ||
BEGIN | ||
-- | ||
-- | ||
-- | ||
INSERT INTO @[email protected]_table_exclusion (schema_name, table_name, tag) | ||
SELECT schema_name, table_name, tags[0] FROM @[email protected]_table_exclusion_templates; | ||
|
||
SELECT count(1) FROM @[email protected]_table_exclusion INTO nbrows; | ||
|
||
RETURN format ('Inserted %s row(s) in schedoc_table_exclusion', nbrows); | ||
END; | ||
$EOF$; | ||
-- | ||
-- Check if a table is present in the exclusion list | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_is_table_excluded(tableoid oid) | ||
|
@@ -324,6 +349,35 @@ BEGIN | |
END IF; | ||
END; | ||
$EOF$; | ||
DROP VIEW IF EXISTS schedoc_column_existing_comments; | ||
CREATE OR REPLACE VIEW schedoc_column_existing_comments AS | ||
|
||
|
||
WITH descr AS ( | ||
SELECT c.relname, d.description | ||
FROM pg_class c | ||
JOIN pg_namespace n ON n.oid = c.relnamespace | ||
LEFT JOIN pg_description d ON d.objoid = c.oid | ||
LEFT JOIN schedoc_table_exclusion e ON e.table_name = c.relname | ||
WHERE c.relkind = 'r' AND n.nspname='public' | ||
AND e.table_name IS NULL | ||
AND c.relname NOT IN ( | ||
|
||
'ddl_history', | ||
'ddl_history_column', | ||
'ddl_history_schema', | ||
'schedoc_column_log', | ||
'schedoc_column_raw', | ||
'schedoc_table_exclusion', | ||
'schedoc_table_exclusion_templates', | ||
'schedoc_valid', | ||
'schedoc_valid_status') | ||
) | ||
SELECT relname, description, description IS NOT NULL AND description IS JSON as is_ok | ||
FROM descr | ||
|
||
ORDER BY relname | ||
; | ||
-- | ||
-- Debezium | ||
-- | ||
|
@@ -358,7 +412,7 @@ INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_na | |
VALUES | ||
('public', 'auth_group', ARRAY['django']), | ||
('public', 'auth_group_permissions', ARRAY['django']), | ||
('public', 'auth_permissions', ARRAY['django']), | ||
('public', 'auth_permission', ARRAY['django']), | ||
('public', 'auth_user', ARRAY['django']), | ||
('public', 'auth_user_groups', ARRAY['django']), | ||
('public', 'auth_user_user_permissions', ARRAY['django']), | ||
|
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 |
---|---|---|
|
@@ -79,6 +79,11 @@ CREATE VIEW @[email protected]_column_comments AS | |
-- | ||
-- | ||
-- | ||
-- | ||
-- schedoc_exclude_tool(tool text) | ||
-- schedoc_exclude_tools_all() | ||
-- schedoc_is_table_excluded(tableoid oid) | ||
-- | ||
-- Set up the exclusion list | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_exclude_tool(tool text) | ||
|
@@ -101,6 +106,26 @@ BEGIN | |
END; | ||
$EOF$; | ||
-- | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_exclude_tools_all() | ||
RETURNS text | ||
LANGUAGE plpgsql AS | ||
$EOF$ | ||
DECLARE | ||
nbrows bigint; | ||
BEGIN | ||
-- | ||
-- | ||
-- | ||
INSERT INTO @[email protected]_table_exclusion (schema_name, table_name, tag) | ||
SELECT schema_name, table_name, tags[0] FROM @[email protected]_table_exclusion_templates; | ||
|
||
SELECT count(1) FROM @[email protected]_table_exclusion INTO nbrows; | ||
|
||
RETURN format ('Inserted %s row(s) in schedoc_table_exclusion', nbrows); | ||
END; | ||
$EOF$; | ||
-- | ||
-- Check if a table is present in the exclusion list | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_is_table_excluded(tableoid oid) | ||
|
@@ -318,6 +343,35 @@ BEGIN | |
END IF; | ||
END; | ||
$EOF$; | ||
DROP VIEW IF EXISTS schedoc_column_existing_comments; | ||
CREATE OR REPLACE VIEW schedoc_column_existing_comments AS | ||
|
||
|
||
WITH descr AS ( | ||
SELECT c.relname, d.description | ||
FROM pg_class c | ||
JOIN pg_namespace n ON n.oid = c.relnamespace | ||
LEFT JOIN pg_description d ON d.objoid = c.oid | ||
LEFT JOIN schedoc_table_exclusion e ON e.table_name = c.relname | ||
WHERE c.relkind = 'r' AND n.nspname='public' | ||
AND e.table_name IS NULL | ||
AND c.relname NOT IN ( | ||
|
||
'ddl_history', | ||
'ddl_history_column', | ||
'ddl_history_schema', | ||
'schedoc_column_log', | ||
'schedoc_column_raw', | ||
'schedoc_table_exclusion', | ||
'schedoc_table_exclusion_templates', | ||
'schedoc_valid', | ||
'schedoc_valid_status') | ||
) | ||
SELECT relname, description, description IS NOT NULL AND description IS JSON as is_ok | ||
FROM descr | ||
|
||
ORDER BY relname | ||
; | ||
-- | ||
-- Debezium | ||
-- | ||
|
@@ -352,7 +406,7 @@ INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_na | |
VALUES | ||
('public', 'auth_group', ARRAY['django']), | ||
('public', 'auth_group_permissions', ARRAY['django']), | ||
('public', 'auth_permissions', ARRAY['django']), | ||
('public', 'auth_permission', ARRAY['django']), | ||
('public', 'auth_user', ARRAY['django']), | ||
('public', 'auth_user_groups', ARRAY['django']), | ||
('public', 'auth_user_user_permissions', ARRAY['django']), | ||
|
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 |
---|---|---|
|
@@ -79,6 +79,11 @@ CREATE VIEW @[email protected]_column_comments AS | |
-- | ||
-- | ||
-- | ||
-- | ||
-- schedoc_exclude_tool(tool text) | ||
-- schedoc_exclude_tools_all() | ||
-- schedoc_is_table_excluded(tableoid oid) | ||
-- | ||
-- Set up the exclusion list | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_exclude_tool(tool text) | ||
|
@@ -101,6 +106,26 @@ BEGIN | |
END; | ||
$EOF$; | ||
-- | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_exclude_tools_all() | ||
RETURNS text | ||
LANGUAGE plpgsql AS | ||
$EOF$ | ||
DECLARE | ||
nbrows bigint; | ||
BEGIN | ||
-- | ||
-- | ||
-- | ||
INSERT INTO @[email protected]_table_exclusion (schema_name, table_name, tag) | ||
SELECT schema_name, table_name, tags[0] FROM @[email protected]_table_exclusion_templates; | ||
|
||
SELECT count(1) FROM @[email protected]_table_exclusion INTO nbrows; | ||
|
||
RETURN format ('Inserted %s row(s) in schedoc_table_exclusion', nbrows); | ||
END; | ||
$EOF$; | ||
-- | ||
-- Check if a table is present in the exclusion list | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_is_table_excluded(tableoid oid) | ||
|
@@ -318,6 +343,35 @@ BEGIN | |
END IF; | ||
END; | ||
$EOF$; | ||
DROP VIEW IF EXISTS schedoc_column_existing_comments; | ||
CREATE OR REPLACE VIEW schedoc_column_existing_comments AS | ||
|
||
|
||
WITH descr AS ( | ||
SELECT c.relname, d.description | ||
FROM pg_class c | ||
JOIN pg_namespace n ON n.oid = c.relnamespace | ||
LEFT JOIN pg_description d ON d.objoid = c.oid | ||
LEFT JOIN schedoc_table_exclusion e ON e.table_name = c.relname | ||
WHERE c.relkind = 'r' AND n.nspname='public' | ||
AND e.table_name IS NULL | ||
AND c.relname NOT IN ( | ||
|
||
'ddl_history', | ||
'ddl_history_column', | ||
'ddl_history_schema', | ||
'schedoc_column_log', | ||
'schedoc_column_raw', | ||
'schedoc_table_exclusion', | ||
'schedoc_table_exclusion_templates', | ||
'schedoc_valid', | ||
'schedoc_valid_status') | ||
) | ||
SELECT relname, description, description IS NOT NULL AND description IS JSON as is_ok | ||
FROM descr | ||
|
||
ORDER BY relname | ||
; | ||
-- | ||
-- Debezium | ||
-- | ||
|
@@ -352,7 +406,7 @@ INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_na | |
VALUES | ||
('public', 'auth_group', ARRAY['django']), | ||
('public', 'auth_group_permissions', ARRAY['django']), | ||
('public', 'auth_permissions', ARRAY['django']), | ||
('public', 'auth_permission', ARRAY['django']), | ||
('public', 'auth_user', ARRAY['django']), | ||
('public', 'auth_user_groups', ARRAY['django']), | ||
('public', 'auth_user_user_permissions', ARRAY['django']), | ||
|
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
-- | ||
-- schedoc_exclude_tool(tool text) | ||
-- schedoc_exclude_tools_all() | ||
-- schedoc_is_table_excluded(tableoid oid) | ||
-- | ||
-- Set up the exclusion list | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_exclude_tool(tool text) | ||
|
@@ -21,6 +25,26 @@ BEGIN | |
END; | ||
$EOF$; | ||
-- | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_exclude_tools_all() | ||
RETURNS text | ||
LANGUAGE plpgsql AS | ||
$EOF$ | ||
DECLARE | ||
nbrows bigint; | ||
BEGIN | ||
-- | ||
-- | ||
-- | ||
INSERT INTO @[email protected]_table_exclusion (schema_name, table_name, tag) | ||
SELECT schema_name, table_name, tags[0] FROM @[email protected]_table_exclusion_templates; | ||
|
||
SELECT count(1) FROM @[email protected]_table_exclusion INTO nbrows; | ||
|
||
RETURN format ('Inserted %s row(s) in schedoc_table_exclusion', nbrows); | ||
END; | ||
$EOF$; | ||
-- | ||
-- Check if a table is present in the exclusion list | ||
-- | ||
CREATE OR REPLACE FUNCTION @[email protected]_is_table_excluded(tableoid oid) | ||
|
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 |
---|---|---|
|
@@ -78,3 +78,4 @@ CREATE VIEW @[email protected]_column_comments AS | |
|
||
-- | ||
-- | ||
-- |
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,29 @@ | ||
DROP VIEW IF EXISTS schedoc_column_existing_comments; | ||
CREATE OR REPLACE VIEW schedoc_column_existing_comments AS | ||
|
||
|
||
WITH descr AS ( | ||
SELECT c.relname, d.description | ||
FROM pg_class c | ||
JOIN pg_namespace n ON n.oid = c.relnamespace | ||
LEFT JOIN pg_description d ON d.objoid = c.oid | ||
LEFT JOIN schedoc_table_exclusion e ON e.table_name = c.relname | ||
WHERE c.relkind = 'r' AND n.nspname='public' | ||
AND e.table_name IS NULL | ||
AND c.relname NOT IN ( | ||
|
||
'ddl_history', | ||
'ddl_history_column', | ||
'ddl_history_schema', | ||
'schedoc_column_log', | ||
'schedoc_column_raw', | ||
'schedoc_table_exclusion', | ||
'schedoc_table_exclusion_templates', | ||
'schedoc_valid', | ||
'schedoc_valid_status') | ||
) | ||
SELECT relname, description, description IS NOT NULL AND description IS JSON as is_ok | ||
FROM descr | ||
|
||
ORDER BY relname | ||
; |
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,14 @@ | ||
-- | ||
-- | ||
-- | ||
SET search_path=public,pgtap; | ||
|
||
BEGIN; | ||
|
||
SELECT plan(1); | ||
|
||
SELECT has_view('public'::name, 'schedoc_column_existing_comments'::name); | ||
|
||
SELECT finish(); | ||
|
||
ROLLBACK; |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_na | |
VALUES | ||
('public', 'auth_group', ARRAY['django']), | ||
('public', 'auth_group_permissions', ARRAY['django']), | ||
('public', 'auth_permissions', ARRAY['django']), | ||
('public', 'auth_permission', ARRAY['django']), | ||
('public', 'auth_user', ARRAY['django']), | ||
('public', 'auth_user_groups', ARRAY['django']), | ||
('public', 'auth_user_user_permissions', ARRAY['django']), | ||
|