You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2018/07/23 21:08:20 UTC
[trafficcontrol] 01/04: ensure tenant set where needed;
add not null constraint
This is an automated email from the ASF dual-hosted git repository.
dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 38599198c02b4339874e5f7f23966af63046ed4c
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Mon Jul 9 16:11:58 2018 -0600
ensure tenant set where needed; add not null constraint
---
traffic_ops/app/db/patches.sql | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/traffic_ops/app/db/patches.sql b/traffic_ops/app/db/patches.sql
index 6fe87d1..16cbb8f 100644
--- a/traffic_ops/app/db/patches.sql
+++ b/traffic_ops/app/db/patches.sql
@@ -39,3 +39,20 @@ ALTER TABLE deliveryservice ADD CONSTRAINT routing_name_not_empty CHECK (length(
-- altering any enum values within a transaction block and by default
-- goose runs migrations within a transaction.
ALTER TYPE profile_type ADD VALUE IF NOT EXISTS 'GROVE_PROFILE';
+
+-- If tenancy is not needed, simply default to the root tenant. This will help
+-- to eliminate the use_tenancy property
+INSERT INTO tenant (name, active, parent_id) VALUES ('root', true, NULL)
+ON CONFLICT DO NOTHING;
+
+UPDATE tm_user SET tenant_id = (SELECT id FROM tenant WHERE name = 'root')
+WHERE tenant_id IS NULL;
+ALTER TABLE tm_user ALTER COLUMN tenant_id SET NOT NULL;
+
+UPDATE deliveryservice SET tenant_id = (SELECT id FROM tenant WHERE name = 'root')
+WHERE tenant_id IS NULL;
+ALTER TABLE deliveryservice ALTER COLUMN tenant_id SET NOT NULL;
+
+UPDATE origin SET tenant = (SELECT id FROM tenant WHERE name = 'root')
+WHERE tenant IS NULL;
+ALTER TABLE origin ALTER COLUMN tenant SET NOT NULL;