cdn domain_name migration

Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/de60ccc7
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/de60ccc7
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/de60ccc7

Branch: refs/heads/master
Commit: de60ccc7a1e18584d3122f73087253eb4b7b6d24
Parents: 898611b
Author: Jan van Doorn <jan_vando...@cable.comcast.com>
Authored: Mon Dec 26 10:48:53 2016 -0700
Committer: Jan van Doorn <j...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 .../20161226000000_cdn_domain_name.sql          | 35 ++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/de60ccc7/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql 
b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
new file mode 100644
index 0000000..7b38d64
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20161226000000_cdn_domain_name.sql
@@ -0,0 +1,35 @@
+/*
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+
+ALTER TABLE public.cdn ADD COLUMN domain_name text;
+
+UPDATE cdn SET domain_name=domainlist.value
+  FROM (SELECT distinct cdn_id,value FROM server,parameter WHERE type=(SELECT 
id FROM type WHERE name='EDGE') 
+    AND parameter.id in (select parameter from profile_parameter WHERE 
profile_parameter.profile=server.profile) 
+    AND parameter.name='domain_name' 
+    AND config_file='CRConfig.json') AS domainlist
+WHERE id = domainlist.cdn_id;
+
+UPDATE public.cdn SET domain_name='-' WHERE name='ALL';
+
+ALTER TABLE public.cdn ALTER COLUMN domain_name SET NOT NULL;
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+
+ALTER TABLE public.cdn DROP COLUMN domain_name;
\ No newline at end of file

Reply via email to