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 2018/05/17 02:34:09 UTC

[GitHub] mitchell852 closed pull request #2214: removed the job_result table because it is not being used

mitchell852 closed pull request #2214: removed the job_result table because it is not being used
URL: https://github.com/apache/incubator-trafficcontrol/pull/2214
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/traffic_ops/app/db/create_tables.sql b/traffic_ops/app/db/create_tables.sql
index b84e886fd..2c18b7fab 100644
--- a/traffic_ops/app/db/create_tables.sql
+++ b/traffic_ops/app/db/create_tables.sql
@@ -568,43 +568,6 @@ ALTER TABLE job_id_seq OWNER TO traffic_ops;
 ALTER SEQUENCE job_id_seq OWNED BY job.id;
 
 
---
--- Name: job_result; Type: TABLE; Schema: public; Owner: traffic_ops
---
-
-CREATE TABLE job_result (
-    id bigint NOT NULL,
-    job bigint NOT NULL,
-    agent bigint NOT NULL,
-    result text NOT NULL,
-    description text,
-    last_updated timestamp with time zone DEFAULT now()
-);
-
-
-ALTER TABLE job_result OWNER TO traffic_ops;
-
---
--- Name: job_result_id_seq; Type: SEQUENCE; Schema: public; Owner: traffic_ops
---
-
-CREATE SEQUENCE job_result_id_seq
-    START WITH 1
-    INCREMENT BY 1
-    NO MINVALUE
-    NO MAXVALUE
-    CACHE 1;
-
-
-ALTER TABLE job_result_id_seq OWNER TO traffic_ops;
-
---
--- Name: job_result_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: traffic_ops
---
-
-ALTER SEQUENCE job_result_id_seq OWNED BY job_result.id;
-
-
 --
 -- Name: job_status; Type: TABLE; Schema: public; Owner: traffic_ops
 --
@@ -1370,13 +1333,6 @@ ALTER TABLE ONLY job ALTER COLUMN id SET DEFAULT nextval('job_id_seq'::regclass)
 ALTER TABLE ONLY job_agent ALTER COLUMN id SET DEFAULT nextval('job_agent_id_seq'::regclass);
 
 
---
--- Name: id; Type: DEFAULT; Schema: public; Owner: traffic_ops
---
-
-ALTER TABLE ONLY job_result ALTER COLUMN id SET DEFAULT nextval('job_result_id_seq'::regclass);
-
-
 --
 -- Name: id; Type: DEFAULT; Schema: public; Owner: traffic_ops
 --
@@ -1625,14 +1581,6 @@ ALTER TABLE ONLY job_agent
     ADD CONSTRAINT idx_89603_primary PRIMARY KEY (id);
 
 
---
--- Name: idx_89614_primary; Type: CONSTRAINT; Schema: public; Owner: traffic_ops
---
-
-ALTER TABLE ONLY job_result
-    ADD CONSTRAINT idx_89614_primary PRIMARY KEY (id);
-
-
 --
 -- Name: idx_89624_primary; Type: CONSTRAINT; Schema: public; Owner: traffic_ops
 --
@@ -2008,20 +1956,6 @@ CREATE INDEX idx_89593_fk_job_status_id1 ON job USING btree (status);
 CREATE INDEX idx_89593_fk_job_user_id1 ON job USING btree (job_user);
 
 
---
--- Name: idx_89614_fk_agent_id1; Type: INDEX; Schema: public; Owner: traffic_ops
---
-
-CREATE INDEX idx_89614_fk_agent_id1 ON job_result USING btree (agent);
-
-
---
--- Name: idx_89614_fk_job_id1; Type: INDEX; Schema: public; Owner: traffic_ops
---
-
-CREATE INDEX idx_89614_fk_job_id1 ON job_result USING btree (job);
-
-
 --
 -- Name: idx_89634_fk_log_1; Type: INDEX; Schema: public; Owner: traffic_ops
 --
@@ -2372,13 +2306,6 @@ CREATE TRIGGER on_update_current_timestamp BEFORE UPDATE ON job FOR EACH ROW EXE
 CREATE TRIGGER on_update_current_timestamp BEFORE UPDATE ON job_agent FOR EACH ROW EXECUTE PROCEDURE on_update_current_timestamp_last_updated();
 
 
---
--- Name: on_update_current_timestamp; Type: TRIGGER; Schema: public; Owner: traffic_ops
---
-
-CREATE TRIGGER on_update_current_timestamp BEFORE UPDATE ON job_result FOR EACH ROW EXECUTE PROCEDURE on_update_current_timestamp_last_updated();
-
-
 --
 -- Name: on_update_current_timestamp; Type: TRIGGER; Schema: public; Owner: traffic_ops
 --
@@ -2484,14 +2411,6 @@ CREATE TRIGGER on_update_current_timestamp BEFORE UPDATE ON tm_user FOR EACH ROW
 CREATE TRIGGER on_update_current_timestamp BEFORE UPDATE ON type FOR EACH ROW EXECUTE PROCEDURE on_update_current_timestamp_last_updated();
 
 
---
--- Name: fk_agent_id1; Type: FK CONSTRAINT; Schema: public; Owner: traffic_ops
---
-
-ALTER TABLE ONLY job_result
-    ADD CONSTRAINT fk_agent_id1 FOREIGN KEY (agent) REFERENCES job_agent(id) ON DELETE CASCADE;
-
-
 --
 -- Name: fk_atsprofile_atsparameters_atsparameters1; Type: FK CONSTRAINT; Schema: public; Owner: traffic_ops
 --
@@ -2740,14 +2659,6 @@ ALTER TABLE ONLY job
     ADD CONSTRAINT fk_job_deliveryservice1 FOREIGN KEY (job_deliveryservice) REFERENCES deliveryservice(id);
 
 
---
--- Name: fk_job_id1; Type: FK CONSTRAINT; Schema: public; Owner: traffic_ops
---
-
-ALTER TABLE ONLY job_result
-    ADD CONSTRAINT fk_job_id1 FOREIGN KEY (job) REFERENCES job(id) ON DELETE CASCADE;
-
-
 --
 -- Name: fk_job_status_id1; Type: FK CONSTRAINT; Schema: public; Owner: traffic_ops
 --
diff --git a/traffic_ops/app/db/migrations/20180501000000_remove_job_result_table.sql b/traffic_ops/app/db/migrations/20180501000000_remove_job_result_table.sql
new file mode 100644
index 000000000..01443f888
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20180501000000_remove_job_result_table.sql
@@ -0,0 +1,29 @@
+/*
+
+    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
+DROP TABLE job_result;
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+CREATE TABLE job_result (
+    id bigint NOT NULL,
+    job bigint NOT NULL,
+    agent bigint NOT NULL,
+    result text NOT NULL,
+    description text,
+    last_updated timestamp with time zone DEFAULT now()
+);
diff --git a/traffic_ops/app/lib/Fixtures/Integration/JobResult.pm b/traffic_ops/app/lib/Fixtures/Integration/JobResult.pm
deleted file mode 100644
index 488cfed59..000000000
--- a/traffic_ops/app/lib/Fixtures/Integration/JobResult.pm
+++ /dev/null
@@ -1,45 +0,0 @@
-package Fixtures::Integration::JobResult;
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-
-# Do not edit! Generated code.
-# See https://github.com/Comcast/traffic_control/wiki/The%20Kabletown%20example
-
-use Moose;
-extends 'DBIx::Class::EasyFixture';
-use namespace::autoclean;
-
-my %definition_for = (
-); 
-
-sub name {
-		return "JobResult";
-}
-
-sub get_definition { 
-		my ( $self, $name ) = @_;
-		return $definition_for{$name};
-}
-
-sub all_fixture_names {
-		return keys %definition_for;
-}
-
-__PACKAGE__->meta->make_immutable;
-1;
diff --git a/traffic_ops/app/lib/Schema/Result/Job.pm b/traffic_ops/app/lib/Schema/Result/Job.pm
index 97d814e16..61186251b 100644
--- a/traffic_ops/app/lib/Schema/Result/Job.pm
+++ b/traffic_ops/app/lib/Schema/Result/Job.pm
@@ -193,8 +193,8 @@ __PACKAGE__->belongs_to(
   {
     is_deferrable => 0,
     join_type     => "LEFT",
-    on_delete     => "NO ACTION",
-    on_update     => "NO ACTION",
+    on_delete     => "CASCADE",
+    on_update     => "CASCADE",
   },
 );
 
@@ -244,8 +244,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-11-18 22:45:19
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LSEFwyL7MpMXHLbKDM288A
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-05-01 14:12:13
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qYN2UzVQx/9lVTv8luPytg
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/traffic_ops/app/lib/Schema/Result/JobAgent.pm b/traffic_ops/app/lib/Schema/Result/JobAgent.pm
index 4c7617d4e..f449266fb 100644
--- a/traffic_ops/app/lib/Schema/Result/JobAgent.pm
+++ b/traffic_ops/app/lib/Schema/Result/JobAgent.pm
@@ -90,6 +90,20 @@ __PACKAGE__->add_columns(
 
 __PACKAGE__->set_primary_key("id");
 
+=head1 UNIQUE CONSTRAINTS
+
+=head2 C<job_agent_name_unique>
+
+=over 4
+
+=item * L</name>
+
+=back
+
+=cut
+
+__PACKAGE__->add_unique_constraint("job_agent_name_unique", ["name"]);
+
 =head1 RELATIONS
 
 =head2 job_results
@@ -123,8 +137,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-11-18 22:45:19
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:V+a0k9GDm5P2qFfo75RoLw
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-05-01 14:12:13
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uCHPqRY2X05m6uuRBMxKrA
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/traffic_ops/app/lib/Schema/Result/JobResult.pm b/traffic_ops/app/lib/Schema/Result/JobResult.pm
deleted file mode 100644
index 895e32a1b..000000000
--- a/traffic_ops/app/lib/Schema/Result/JobResult.pm
+++ /dev/null
@@ -1,154 +0,0 @@
-use utf8;
-package Schema::Result::JobResult;
-
-# Created by DBIx::Class::Schema::Loader
-# DO NOT MODIFY THE FIRST PART OF THIS FILE
-
-=head1 NAME
-
-Schema::Result::JobResult
-
-=cut
-
-use strict;
-use warnings;
-
-use base 'DBIx::Class::Core';
-
-=head1 TABLE: C<job_result>
-
-=cut
-
-__PACKAGE__->table("job_result");
-
-=head1 ACCESSORS
-
-=head2 id
-
-  data_type: 'bigint'
-  is_auto_increment: 1
-  is_nullable: 0
-  sequence: 'job_result_id_seq'
-
-=head2 job
-
-  data_type: 'bigint'
-  is_foreign_key: 1
-  is_nullable: 0
-
-=head2 agent
-
-  data_type: 'bigint'
-  is_foreign_key: 1
-  is_nullable: 0
-
-=head2 result
-
-  data_type: 'text'
-  is_nullable: 0
-
-=head2 description
-
-  data_type: 'text'
-  is_nullable: 1
-
-=head2 last_updated
-
-  data_type: 'timestamp with time zone'
-  default_value: current_timestamp
-  is_nullable: 1
-  original: {default_value => \"now()"}
-
-=cut
-
-__PACKAGE__->add_columns(
-  "id",
-  {
-    data_type         => "bigint",
-    is_auto_increment => 1,
-    is_nullable       => 0,
-    sequence          => "job_result_id_seq",
-  },
-  "job",
-  { data_type => "bigint", is_foreign_key => 1, is_nullable => 0 },
-  "agent",
-  { data_type => "bigint", is_foreign_key => 1, is_nullable => 0 },
-  "result",
-  { data_type => "text", is_nullable => 0 },
-  "description",
-  { data_type => "text", is_nullable => 1 },
-  "last_updated",
-  {
-    data_type     => "timestamp with time zone",
-    default_value => \"current_timestamp",
-    is_nullable   => 1,
-    original      => { default_value => \"now()" },
-  },
-);
-
-=head1 PRIMARY KEY
-
-=over 4
-
-=item * L</id>
-
-=back
-
-=cut
-
-__PACKAGE__->set_primary_key("id");
-
-=head1 RELATIONS
-
-=head2 agent
-
-Type: belongs_to
-
-Related object: L<Schema::Result::JobAgent>
-
-=cut
-
-__PACKAGE__->belongs_to(
-  "agent",
-  "Schema::Result::JobAgent",
-  { id => "agent" },
-  { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
-);
-
-=head2 job
-
-Type: belongs_to
-
-Related object: L<Schema::Result::Job>
-
-=cut
-
-__PACKAGE__->belongs_to(
-  "job",
-  "Schema::Result::Job",
-  { id => "job" },
-  { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
-);
-
-
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-11-18 22:45:19
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NUnA85Q9jjI/gExK42pAzg
-
-
-# You can replace this text with custom code or comments, and it will be preserved on regeneration
-#
-#
-# 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.
-#
-#
-1;
diff --git a/traffic_ops/app/lib/Schema/Result/JobStatus.pm b/traffic_ops/app/lib/Schema/Result/JobStatus.pm
index 5c8a6c317..a3f4ea9c5 100644
--- a/traffic_ops/app/lib/Schema/Result/JobStatus.pm
+++ b/traffic_ops/app/lib/Schema/Result/JobStatus.pm
@@ -82,6 +82,20 @@ __PACKAGE__->add_columns(
 
 __PACKAGE__->set_primary_key("id");
 
+=head1 UNIQUE CONSTRAINTS
+
+=head2 C<job_status_name_unique>
+
+=over 4
+
+=item * L</name>
+
+=back
+
+=cut
+
+__PACKAGE__->add_unique_constraint("job_status_name_unique", ["name"]);
+
 =head1 RELATIONS
 
 =head2 jobs
@@ -100,8 +114,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-11-18 22:45:19
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2DDDF4SIFehss2fsgvDkjg
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-05-01 14:12:13
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8K80djhLKC61MmOhbhyQYA
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/traffic_ops/app/lib/Test/IntegrationTestHelper.pm b/traffic_ops/app/lib/Test/IntegrationTestHelper.pm
index 5480d694a..e86166f4c 100644
--- a/traffic_ops/app/lib/Test/IntegrationTestHelper.pm
+++ b/traffic_ops/app/lib/Test/IntegrationTestHelper.pm
@@ -43,7 +43,6 @@ use Fixtures::Integration::FederationTmuser;
 use Fixtures::Integration::Hwinfo;
 use Fixtures::Integration::JobAgent;
 use Fixtures::Integration::Job;
-use Fixtures::Integration::JobResult;
 use Fixtures::Integration::JobStatus;
 use Fixtures::Integration::Log;
 use Fixtures::Integration::Parameter;
diff --git a/traffic_ops/app/lib/UI/Job.pm b/traffic_ops/app/lib/UI/Job.pm
index 063d3ce9b..2be18108d 100644
--- a/traffic_ops/app/lib/UI/Job.pm
+++ b/traffic_ops/app/lib/UI/Job.pm
@@ -348,78 +348,6 @@ sub readstatus {
 	$self->render( json => \@data );
 }
 
-#### Result subs
-sub readresult {
-
-	#        $r->get('/job/external/result/view/:id')->to('job#readresult');
-	my $self = shift;
-	my $id   = $self->param('id');
-	my @data;
-
-	my $rs_data = $self->db->resultset('JobResult')->search( { job => $self->param('id') }, { prefetch => [ 'job', 'agent' ] } );
-	while ( my $row = $rs_data->next ) {
-		my %hash = (
-			id           => $row->id,
-			job          => $row->job->id,
-			agent        => $row->agent->id,
-			result       => $row->result,
-			description  => $row->description,
-			last_updated => $row->last_updated,
-		);
-		push( @data, \%hash );
-	}
-
-	if ( !@data ) {
-		push( @data, { result => "No data found for this job ID" } );
-	}
-
-	$self->render( json => \@data );
-}
-
-sub newresult {
-
-	#        $r->post('/job/agent/result/new/:id')->to('job#newresult');
-	my $self        = shift;
-	my $agent       = $self->param('agent');
-	my $jobid       = $self->param('job');
-	my $result      = $self->param('result');
-	my $description = $self->param('description');
-
-	my %response;
-	my %err;
-
-	# Check for required fields
-
-	if (%err) {
-
-		# Set error headers and gen message
-		return $self->render( json => \%err );
-	}
-	else {
-		my $insert = $self->db->resultset('JobResult')->create(
-			{
-				job         => $jobid,
-				agent       => $agent,
-				result      => $result,
-				description => $description,
-			}
-		);
-		$insert->insert();
-		$response{"result"} = $insert->id;
-	}
-
-	if ( defined $response{"result"} ) {
-		$response{"status"} = "success";
-
-		# &log( $self, "Created new result...", "UICHANGE" );
-	}
-	else {
-		$response{"status"} = "failure";
-	}
-
-	$self->render( json => \%response );
-}
-
 #### Agent subs
 sub viewagentjob {
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services