Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added table schema checks to linearite demo triggers. #449

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions demos/linearlite/db/migrations-client/01-create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ BEGIN
FOR col_name IN SELECT column_name
FROM information_schema.columns
WHERE table_name = TG_TABLE_NAME AND
table_schema = TG_TABLE_SCHEMA AND
column_name NOT IN ('id', 'synced', 'modified_columns', 'backup', 'deleted', 'new', 'sent_to_server', 'search_vector') LOOP
EXECUTE format('SELECT $1.%I', col_name) USING NEW INTO new_value;
EXECUTE format('SELECT %I FROM %I WHERE id = $1', col_name, TG_TABLE_NAME) USING NEW.id INTO old_value;
Expand Down Expand Up @@ -207,6 +208,7 @@ BEGIN
FOR column_name IN SELECT columns.column_name
FROM information_schema.columns
WHERE columns.table_name = TG_TABLE_NAME
AND columns.table_schema = TG_TABLE_SCHEMA
AND columns.column_name NOT IN ('id', 'synced', 'modified_columns', 'backup', 'deleted', 'new', 'sent_to_server', 'search_vector') LOOP
IF column_name != ANY(OLD.modified_columns) THEN
EXECUTE format('SELECT ($1).%I', column_name) USING NEW INTO new_value;
Expand All @@ -224,6 +226,7 @@ BEGIN
FOR column_name IN SELECT columns.column_name
FROM information_schema.columns
WHERE columns.table_name = TG_TABLE_NAME
AND columns.table_schema = TG_TABLE_SCHEMA
AND columns.column_name NOT IN ('id', 'synced', 'modified_columns', 'backup', 'deleted', 'new', 'sent_to_server', 'search_vector') LOOP
EXECUTE format('SELECT ($1).%I', column_name) USING NEW INTO new_value;
EXECUTE format('SELECT ($1).%I', column_name) USING OLD INTO old_value;
Expand Down
Loading