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 2017/06/09 14:04:04 UTC
[1/2] incubator-trafficcontrol git commit: This closes #650
Repository: incubator-trafficcontrol
Updated Branches:
refs/heads/master 602e88260 -> 7b8171a39
This closes #650
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/7b8171a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/7b8171a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/7b8171a3
Branch: refs/heads/master
Commit: 7b8171a397d8dc562cf5bafa844ea78253c4ca59
Parents: 3323345
Author: Dewayne Richardson <de...@apache.org>
Authored: Fri Jun 9 08:03:56 2017 -0600
Committer: Dewayne Richardson <de...@apache.org>
Committed: Fri Jun 9 08:03:56 2017 -0600
----------------------------------------------------------------------
----------------------------------------------------------------------
[2/2] incubator-trafficcontrol git commit: adds data patch step to
upgrade.pl
Posted by de...@apache.org.
adds data patch step to upgrade.pl
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/33233452
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/33233452
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/33233452
Branch: refs/heads/master
Commit: 332334520a1a75dabac0530bcb6367f1c6e590bd
Parents: 602e882
Author: Derek Gelinas <de...@cable.comcast.com>
Authored: Wed Jun 7 14:55:54 2017 +0000
Committer: Dewayne Richardson <de...@apache.org>
Committed: Fri Jun 9 08:03:56 2017 -0600
----------------------------------------------------------------------
traffic_ops/app/db/admin.pl | 14 +++++++++++++-
traffic_ops/app/db/patches.sql | 17 +++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/33233452/traffic_ops/app/db/admin.pl
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/admin.pl b/traffic_ops/app/db/admin.pl
index e2dbc4e..627ef93 100755
--- a/traffic_ops/app/db/admin.pl
+++ b/traffic_ops/app/db/admin.pl
@@ -62,13 +62,15 @@ my $usage = "\n"
. "dropdb - Execute db 'dropdb' on the database for the current environment.\n"
. "down - Roll back a single migration from the current version.\n"
. "drop_user - Execute 'drop_user' the user for the current environment (traffic_ops).\n"
+ . "patch - Execute sql from db/patches.sql for loading post-migration data patches.\n";
. "redo - Roll back the most recently applied migration, then run it again.\n"
. "reset - Execute db 'dropdb', 'createdb', load_schema, migrate on the database for the current environment.\n"
. "reverse_schema - Reverse engineer the lib/Schema/Result files from the environment database.\n"
. "seed - Execute sql from db/seeds.sql for loading static data.\n"
. "show_users - Execute sql to show all of the user for the current environment.\n"
. "status - Print the status of all migrations.\n"
- . "upgrade - Execute migrate then seed on the database for the current environment.\n";
+ . "upgrade - Execute migrate, seed, and patches on the database for the current environment.\n";
+
my $environment = 'development';
my $db_protocol;
@@ -114,6 +116,7 @@ if ( defined($argument) ) {
elsif ( $argument eq 'upgrade' ) {
migrate('up');
seed();
+ patches();
}
elsif ( $argument eq 'migrate' ) {
migrate('up');
@@ -139,6 +142,8 @@ if ( defined($argument) ) {
elsif ( $argument eq 'reverse_schema' ) {
reverse_schema();
}
+ elsif ( $argument eq 'patch' ) {
+ patches();
else {
print $usage;
}
@@ -187,6 +192,13 @@ sub seed {
}
}
+sub patches {
+ print "Patching database with required data fixes.\n";
+ local $ENV{PGPASSWORD} = $db_password;
+ if ( system("psql -h $host_ip -p $host_port -d $db_name -U $db_user -e < db/patches.sql") != 0 ) {
+ die "Can't patch database w/ required data\n";
+}
+
sub load_schema {
print "Creating database tables.\n";
local $ENV{PGPASSWORD} = $db_password;
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/33233452/traffic_ops/app/db/patches.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/patches.sql b/traffic_ops/app/db/patches.sql
new file mode 100644
index 0000000..79541b7
--- /dev/null
+++ b/traffic_ops/app/db/patches.sql
@@ -0,0 +1,17 @@
+-- -- -- -- -- -- -- /*
+
+ 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.
+*/
+
+
+-- THIS FILE INCLUDES POST-MIGRATION DATA FIXES REQUIRED OF TRAFFIC OPS