Skip to content

Commit

Permalink
Add data for table exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
rodo committed Dec 12, 2024
1 parent 897384a commit 815cb65
Show file tree
Hide file tree
Showing 14 changed files with 447 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
schedoc.control
*.zip
test/sql/*.sql
test/*.sql
test/*.sql
exclude.sql
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ INTETESTS = $(shell find test/ -type f -name '*.sql.in' | sed -e 's/.in$$//')

EXTENSION = schedoc

TOOLSEXC = $(wildcard tools_exclusion/*.sql)

EXTVERSION = $(shell grep -m 1 '[[:space:]]\{3\}"version":' META.json | \
sed -e 's/[[:space:]]*"version":[[:space:]]*"\([^"]*\)",\{0,1\}/\1/')

Expand All @@ -31,14 +33,19 @@ all: $(DIST) $(PGTLEOUT) $(EXTENSION).control $(UNITTESTS) $(INTETESTS)
clean:
rm -f $(PGTLEOUT) $(DIST) $(UNITTESTS)

$(DIST): $(FILES)
$(DIST): $(FILES) exclude.sql
cat sql/table.sql > $@
cat sql/management.sql >> $@
cat sql/function.sql >> $@
cat sql/function-stop.sql >> $@
cat sql/function-status.sql >> $@
cat exclude.sql >> $@
cat sql/start.sql >> $@
cat $@ > dist/$(EXTENSION).sql

exclude.sql: $(TOOLSEXC)
cat $(TOOLSEXC) > exclude.sql

test:
pg_prove -f test/sql/*.sql

Expand Down
102 changes: 102 additions & 0 deletions dist/pgtle.schedoc--0.0.2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,27 @@ CREATE TABLE @[email protected]_column_log (
--
--
--
CREATE TABLE @[email protected]_table_exclusion (
schema_name name,
table_name name,
tag text,
created_at timestamp with time zone DEFAULT current_timestamp,
created_by text DEFAULT current_user,
PRIMARY KEY (schema_name, table_name)
);

CREATE TABLE @[email protected]_table_exclusion_templates (
schema_name name,
table_name name,
tags text[],
created_at timestamp with time zone DEFAULT current_timestamp,
created_by text DEFAULT current_user,
PRIMARY KEY (schema_name, table_name)
);

--
--
--
CREATE VIEW @[email protected]_column_comments AS

SELECT current_database() as databasename, c.relname as tablename, a.attname as columnname, status
Expand All @@ -67,6 +87,28 @@ CREATE VIEW @[email protected]_column_comments AS
--
--
--
CREATE OR REPLACE FUNCTION @[email protected]_exclude_tool(tool text)
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, tool FROM @[email protected]_table_exclusion_templates
WHERE tags @> ARRAY[tool];

SELECT count(1) FROM @[email protected]_table_exclusion WHERE tag = tool INTO nbrows;

RETURN format ('Inserted %s row(s) in schedoc_table_exclusion', nbrows);
END;
$EOF$;
--
--
--
CREATE OR REPLACE FUNCTION @[email protected]_start()
RETURNS void
LANGUAGE plpgsql AS
Expand Down Expand Up @@ -238,6 +280,66 @@ BEGIN
END;
$EOF$;
--
-- Debezium
--

INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_name, tags)
VALUES

('public', 'celery_results_taskresult', ARRAY['celery']),
('public', 'celery_taskmeta', ARRAY['celery']),
('public', 'celery_tasksetmeta', ARRAY['celery']),

('public', 'djcelery_crontabschedule', ARRAY['celery']),
('public', 'djcelery_intervalschedule', ARRAY['celery']),
('public', 'djcelery_periodictask', ARRAY['celery']),
('public', 'djcelery_taskstate', ARRAY['celery']),
('public', 'djcelery_workerstate', ARRAY['celery']);
--
-- Debezium
--

INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_name, tags)
VALUES

('public', 'dbz_signal', ARRAY['debezium']),
('public', 'dbz_heartbeat', ARRAY['debezium']);
--
-- Exclude tables created by Django Framework
--
-- https://www.djangoproject.com/
--
INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_name, tags)
VALUES
('public', 'auth_group', ARRAY['django']),
('public', 'auth_group_permissions', ARRAY['django']),
('public', 'auth_permissions', ARRAY['django']),
('public', 'auth_user', ARRAY['django']),
('public', 'auth_user_user_permissions', ARRAY['django']),
('public', 'django_admin_log', ARRAY['django']),
('public', 'django_content_type', ARRAY['django']),
('public', 'django_migrations', ARRAY['django']),
('public', 'django_session', ARRAY['django']);
--
-- Debezium
--

INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_name, tags)
VALUES

('public', 'procrastinate_events', ARRAY['procrastinate']),
('public', 'procrastinate_jobs', ARRAY['procrastinate']),
('public', 'procrastinate_periodic_defers', ARRAY['procrastinate']);
--
--
--

INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_name, tags)
VALUES

('public', 'tastypie_apiaccess', ARRAY['tastypie']),
('public', 'tastypie_apikey', ARRAY['tastypie']);
--
-- Check the schema of installation for schedoc
--
DO
Expand Down
102 changes: 102 additions & 0 deletions dist/schedoc--0.0.2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,27 @@ CREATE TABLE @[email protected]_column_log (
--
--
--
CREATE TABLE @[email protected]_table_exclusion (
schema_name name,
table_name name,
tag text,
created_at timestamp with time zone DEFAULT current_timestamp,
created_by text DEFAULT current_user,
PRIMARY KEY (schema_name, table_name)
);

CREATE TABLE @[email protected]_table_exclusion_templates (
schema_name name,
table_name name,
tags text[],
created_at timestamp with time zone DEFAULT current_timestamp,
created_by text DEFAULT current_user,
PRIMARY KEY (schema_name, table_name)
);

--
--
--
CREATE VIEW @[email protected]_column_comments AS

SELECT current_database() as databasename, c.relname as tablename, a.attname as columnname, status
Expand All @@ -61,6 +81,28 @@ CREATE VIEW @[email protected]_column_comments AS
--
--
--
CREATE OR REPLACE FUNCTION @[email protected]_exclude_tool(tool text)
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, tool FROM @[email protected]_table_exclusion_templates
WHERE tags @> ARRAY[tool];

SELECT count(1) FROM @[email protected]_table_exclusion WHERE tag = tool INTO nbrows;

RETURN format ('Inserted %s row(s) in schedoc_table_exclusion', nbrows);
END;
$EOF$;
--
--
--
CREATE OR REPLACE FUNCTION @[email protected]_start()
RETURNS void
LANGUAGE plpgsql AS
Expand Down Expand Up @@ -232,6 +274,66 @@ BEGIN
END;
$EOF$;
--
-- Debezium
--

INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_name, tags)
VALUES

('public', 'celery_results_taskresult', ARRAY['celery']),
('public', 'celery_taskmeta', ARRAY['celery']),
('public', 'celery_tasksetmeta', ARRAY['celery']),

('public', 'djcelery_crontabschedule', ARRAY['celery']),
('public', 'djcelery_intervalschedule', ARRAY['celery']),
('public', 'djcelery_periodictask', ARRAY['celery']),
('public', 'djcelery_taskstate', ARRAY['celery']),
('public', 'djcelery_workerstate', ARRAY['celery']);
--
-- Debezium
--

INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_name, tags)
VALUES

('public', 'dbz_signal', ARRAY['debezium']),
('public', 'dbz_heartbeat', ARRAY['debezium']);
--
-- Exclude tables created by Django Framework
--
-- https://www.djangoproject.com/
--
INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_name, tags)
VALUES
('public', 'auth_group', ARRAY['django']),
('public', 'auth_group_permissions', ARRAY['django']),
('public', 'auth_permissions', ARRAY['django']),
('public', 'auth_user', ARRAY['django']),
('public', 'auth_user_user_permissions', ARRAY['django']),
('public', 'django_admin_log', ARRAY['django']),
('public', 'django_content_type', ARRAY['django']),
('public', 'django_migrations', ARRAY['django']),
('public', 'django_session', ARRAY['django']);
--
-- Debezium
--

INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_name, tags)
VALUES

('public', 'procrastinate_events', ARRAY['procrastinate']),
('public', 'procrastinate_jobs', ARRAY['procrastinate']),
('public', 'procrastinate_periodic_defers', ARRAY['procrastinate']);
--
--
--

INSERT INTO @[email protected]_table_exclusion_templates (schema_name, table_name, tags)
VALUES

('public', 'tastypie_apiaccess', ARRAY['tastypie']),
('public', 'tastypie_apikey', ARRAY['tastypie']);
--
-- Check the schema of installation for schedoc
--
DO
Expand Down
Loading

0 comments on commit 815cb65

Please sign in to comment.