trafficcontrol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mitchell...@apache.org
Subject [04/14] incubator-trafficcontrol git commit: Add tenancy to delivery service table
Date Mon, 10 Jul 2017 20:49:56 GMT
Add tenancy to delivery service table


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

Branch: refs/heads/master
Commit: c04129197aaac163113f08f58be0e0b44ae018c3
Parents: 4e4eac8
Author: nir-sopher <nirsopher@gmail.com>
Authored: Mon Mar 20 19:33:28 2017 +0200
Committer: Jeremy Mitchell <mitchell852@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600

----------------------------------------------------------------------
 .../20170315000003_delivery_service_tenancy.sql | 30 +++++++++++++
 traffic_ops/app/lib/Fixtures/Deliveryservice.pm | 13 ++++++
 .../lib/Fixtures/Integration/Deliveryservice.pm |  8 ++++
 .../app/lib/Schema/Result/Deliveryservice.pm    | 47 +++++++++++++++++---
 traffic_ops/app/lib/Schema/Result/Tenant.pm     | 16 ++++++-
 5 files changed, 107 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c0412919/traffic_ops/app/db/migrations/20170315000003_delivery_service_tenancy.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170315000003_delivery_service_tenancy.sql b/traffic_ops/app/db/migrations/20170315000003_delivery_service_tenancy.sql
new file mode 100644
index 0000000..a737d0c
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20170315000003_delivery_service_tenancy.sql
@@ -0,0 +1,30 @@
+/*
+
+    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 deliveryservice
+    ADD tenant_id BIGINT,
+    ADD CONSTRAINT fk_tenantid FOREIGN KEY (tenant_id) REFERENCES tenant (id) MATCH FULL,
+    ALTER COLUMN tenant_id SET DEFAULT NULL;
+CREATE INDEX idx_k_deliveryservice_tenant_idx ON deliveryservice USING btree (tenant_id);
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+
+ALTER TABLE deliveryservice
+DROP COLUMN tenant_id;
+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c0412919/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
index 28953d0..0f91ede 100644
--- a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
@@ -25,6 +25,7 @@ my %definition_for = (
 			id                    => 100,
 			xml_id                => 'test-ds1',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -63,6 +64,7 @@ my %definition_for = (
 			id                    => 200,
 			xml_id                => 'test-ds2',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -101,6 +103,7 @@ my %definition_for = (
 			id                    => 300,
 			xml_id                => 'test-ds3',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -139,6 +142,7 @@ my %definition_for = (
 			id                    => 400,
 			xml_id                => 'test-ds4',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -177,6 +181,7 @@ my %definition_for = (
 			id                    => 500,
 			xml_id                => 'test-ds5',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -215,6 +220,7 @@ my %definition_for = (
 			id                    => 600,
 			xml_id                => 'test-ds6',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -253,6 +259,7 @@ my %definition_for = (
 			id                    => 700,
 			xml_id                => 'steering-ds1',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -289,6 +296,7 @@ my %definition_for = (
 			id                    => 800,
 			xml_id                => 'steering-ds2',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -325,6 +333,7 @@ my %definition_for = (
 			id                    => 900,
 			xml_id                => 'steering-ds3',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -361,6 +370,7 @@ my %definition_for = (
 			id                    => 1000,
 			xml_id                => 'steering-target-ds1',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -397,6 +407,7 @@ my %definition_for = (
 			id                    => 1100,
 			xml_id                => 'steering-target-ds2',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -433,6 +444,7 @@ my %definition_for = (
 			id                    => 1200,
 			xml_id                => 'steering-target-ds3',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,
@@ -469,6 +481,7 @@ my %definition_for = (
 			id                    => 1300,
 			xml_id                => 'steering-target-ds4',
 			active                => 1,
+			tenant_id             => undef,
 			dscp                  => 40,
 			signed                => 0,
 			qstring_ignore        => 0,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c0412919/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
index 80f475d..c41f7c5 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
@@ -63,6 +63,7 @@ my %definition_for = (
 			global_max_tps              => '0',
 			max_dns_answers             => '0',
 			tr_response_headers         => undef,
+			tenant_id                   => undef,
 			cdn_id                      => '2',
 			dns_bypass_ttl              => undef,
 			initial_dispersion          => '1',
@@ -99,6 +100,7 @@ my %definition_for = (
 			type                        => '10',
 			ipv6_routing_enabled        => undef,
 			tr_response_headers         => undef,
+			tenant_id                   => undef,
 			cdn_id                      => '1',
 			global_max_mbps             => '0',
 			global_max_tps              => '0',
@@ -167,6 +169,7 @@ my %definition_for = (
 			remap_text                  => undef,
 			ssl_key_version             => '0',
 			tr_request_headers          => undef,
+			tenant_id                   => undef,
 			cdn_id                      => '1',
 			global_max_tps              => '0',
 			http_bypass_fqdn            => '',
@@ -192,6 +195,7 @@ my %definition_for = (
 			last_updated                => '2015-12-10 15:44:37',
 			signed                      => '0',
 			ccr_dns_ttl                 => '3600',
+			tenant_id                   => undef,
 			cdn_id                      => '1',
 			display_name                => 'movies-c1',
 			protocol                    => '0',
@@ -268,6 +272,7 @@ my %definition_for = (
 			global_max_tps              => '0',
 			http_bypass_fqdn            => '',
 			origin_shield               => undef,
+			tenant_id                   => undef,
 			cdn_id                      => '1',
 			dns_bypass_ttl              => undef,
 		},
@@ -286,6 +291,7 @@ my %definition_for = (
 			mid_header_rewrite          => undef,
 			signed                      => '0',
 			ssl_key_version             => '0',
+			tenant_id                   => undef,
 			cdn_id                      => '2',
 			long_desc                   => 'test-ds3 long_desc',
 			max_dns_answers             => '0',
@@ -333,6 +339,7 @@ my %definition_for = (
 			origin_shield               => undef,
 			range_request_handling      => '0',
 			remap_text                  => undef,
+			tenant_id                   => undef,
 			cdn_id                      => '2',
 			long_desc_2                 => 'test long_desc_2',
 			tr_request_headers          => undef,
@@ -393,6 +400,7 @@ my %definition_for = (
 			active                      => '1',
 			cacheurl                    => undef,
 			ccr_dns_ttl                 => '3600',
+			tenant_id                   => undef,
 			cdn_id                      => '2',
 			dns_bypass_ip               => '',
 			dns_bypass_ttl              => undef,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c0412919/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
index a179d7f..9889a7e 100644
--- a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
@@ -278,11 +278,22 @@ __PACKAGE__->table("deliveryservice");
   default_value: false
   is_nullable: 1
 
+=head2 multi_site_origin_algorithm
+
+  data_type: 'smallint'
+  is_nullable: 1
+
 =head2 geolimit_redirect_url
 
   data_type: 'text'
   is_nullable: 1
 
+=head2 tenant_id
+
+  data_type: 'bigint'
+  is_foreign_key: 1
+  is_nullable: 1
+
 =cut
 
 __PACKAGE__->add_columns(
@@ -390,8 +401,12 @@ __PACKAGE__->add_columns(
   { data_type => "text", is_nullable => 1 },
   "logs_enabled",
   { data_type => "boolean", default_value => \"false", is_nullable => 1 },
+  "multi_site_origin_algorithm",
+  { data_type => "smallint", is_nullable => 1 },
   "geolimit_redirect_url",
   { data_type => "text", is_nullable => 1 },
+  "tenant_id",
+  { data_type => "bigint", is_foreign_key => 1, is_nullable => 1 },
 );
 
 =head1 PRIMARY KEY
@@ -410,7 +425,7 @@ __PACKAGE__->set_primary_key("id", "type");
 
 =head1 UNIQUE CONSTRAINTS
 
-=head2 C<idx_101208_ds_id_unique>
+=head2 C<idx_89502_ds_id_unique>
 
 =over 4
 
@@ -420,9 +435,9 @@ __PACKAGE__->set_primary_key("id", "type");
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_101208_ds_id_unique", ["id"]);
+__PACKAGE__->add_unique_constraint("idx_89502_ds_id_unique", ["id"]);
 
-=head2 C<idx_101208_ds_name_unique>
+=head2 C<idx_89502_ds_name_unique>
 
 =over 4
 
@@ -432,7 +447,7 @@ __PACKAGE__->add_unique_constraint("idx_101208_ds_id_unique", ["id"]);
 
 =cut
 
-__PACKAGE__->add_unique_constraint("idx_101208_ds_name_unique", ["xml_id"]);
+__PACKAGE__->add_unique_constraint("idx_89502_ds_name_unique", ["xml_id"]);
 
 =head1 RELATIONS
 
@@ -591,6 +606,26 @@ __PACKAGE__->has_many(
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
+=head2 tenant
+
+Type: belongs_to
+
+Related object: L<Schema::Result::Tenant>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "tenant",
+  "Schema::Result::Tenant",
+  { id => "tenant_id" },
+  {
+    is_deferrable => 0,
+    join_type     => "LEFT",
+    on_delete     => "NO ACTION",
+    on_update     => "NO ACTION",
+  },
+);
+
 =head2 type
 
 Type: belongs_to
@@ -607,8 +642,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-01-02 16:07:07
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qCU9AxWN09+5k2ETT6tqSQ
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-03-20 18:24:11
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/w+omk3X6k2RKjoI6IDlFw
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 #

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c0412919/traffic_ops/app/lib/Schema/Result/Tenant.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Tenant.pm b/traffic_ops/app/lib/Schema/Result/Tenant.pm
index 9f11084..da89550 100644
--- a/traffic_ops/app/lib/Schema/Result/Tenant.pm
+++ b/traffic_ops/app/lib/Schema/Result/Tenant.pm
@@ -113,6 +113,21 @@ __PACKAGE__->add_unique_constraint("tenant_name_key", ["name"]);
 
 =head1 RELATIONS
 
+=head2 deliveryservices
+
+Type: has_many
+
+Related object: L<Schema::Result::Deliveryservice>
+
+=cut
+
+__PACKAGE__->has_many(
+  "deliveryservices",
+  "Schema::Result::Deliveryservice",
+  { "foreign.tenant_id" => "self.id" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
 =head2 parent
 
 Type: belongs_to
@@ -167,6 +182,5 @@ __PACKAGE__->has_many(
 # Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-03-20 09:11:40
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:W4nbCNSj6N1gMar0mRvQ5Q
 
-
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 1;


Mime
View raw message