You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/07/28 18:06:00 UTC
[GitHub] [trafficcontrol] shamrickus commented on a change in pull request #6065: TO DB: Collapse <6 migrations
shamrickus commented on a change in pull request #6065:
URL: https://github.com/apache/trafficcontrol/pull/6065#discussion_r678537753
##########
File path: traffic_ops/app/db/create_tables.sql
##########
@@ -2424,6 +2738,121 @@ END IF;
END$$;
+DO $$
+ DECLARE table_names VARCHAR[] := CAST(ARRAY[
+ 'api_capability',
+ 'asn',
+ 'cachegroup',
+ 'cachegroup_fallbacks',
+ 'cachegroup_localization_method',
+ 'cachegroup_parameter',
+ 'capability',
+ 'cdn',
+ 'coordinate',
+ 'deliveryservice',
+ 'deliveryservice_regex',
+ 'deliveryservice_request',
+ 'deliveryservice_request_comment',
+ 'deliveryservice_server',
+ 'deliveryservice_tmuser',
+ 'deliveryservices_required_capability',
+ 'division',
+ 'federation',
+ 'federation_deliveryservice',
+ 'federation_federation_resolver',
+ 'federation_resolver',
+ 'federation_tmuser',
+ 'hwinfo',
+ 'job',
+ 'job_agent',
+ 'job_status',
+ 'log',
+ 'origin',
+ 'parameter',
+ 'phys_location',
+ 'profile',
+ 'profile_parameter',
+ 'regex',
+ 'region',
+ 'role',
+ 'role_capability',
+ 'server',
+ 'server_capability',
+ 'server_server_capability',
+ 'servercheck',
+ 'service_category',
+ 'snapshot',
+ 'staticdnsentry',
+ 'stats_summary',
+ 'status',
+ 'steering_target',
+ 'tenant',
+ 'tm_user',
+ 'to_extension',
+ 'topology',
+ 'topology_cachegroup',
+ 'topology_cachegroup_parents',
+ 'type',
+ 'user_role'
+ ] AS VARCHAR[]);
+ table_name TEXT;
+ trigger_name TEXT := 'on_delete_current_timestamp';
+ trigger_exists BOOLEAN;
+
+BEGIN
+ FOREACH table_name IN ARRAY table_names
+ LOOP
+ EXECUTE FORMAT('SELECT EXISTS (
+ SELECT
+ FROM pg_catalog.pg_trigger
+ WHERE tgname = ''%s''
+ AND tgrelid = CAST(''%s'' AS REGCLASS))
+ ',
+ QUOTE_IDENT(trigger_name),
+ QUOTE_IDENT(table_name)) INTO trigger_exists;
+ IF NOT trigger_exists
+ THEN
+ EXECUTE FORMAT('
+ CREATE TRIGGER %s
+ AFTER DELETE ON %s
+ FOR EACH ROW
+ EXECUTE PROCEDURE %s_last_updated(''%s'');
+ ',
+ QUOTE_IDENT(trigger_name),
+ QUOTE_IDENT(table_name),
+ QUOTE_IDENT(trigger_name),
+ QUOTE_IDENT(table_name)
+ );
+ END IF;
+ IF table_name = 'topology' THEN
Review comment:
Topology index is incorrect, see #6066
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org