You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by fr...@apache.org on 2017/06/14 19:36:37 UTC

[6/9] incubator-trafficcontrol git commit: initial version of the traffic_ops_db top level project

initial version of the traffic_ops_db top level project

(cherry picked from commit ac0d7d761cfe8266a39e53d7687598f03eb8fdb7)


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

Branch: refs/heads/2.0.x
Commit: d20484de7c6e233780511dcdd4d2609e975e6456
Parents: dde8674
Author: Dewayne Richardson <de...@apache.org>
Authored: Thu May 11 11:06:00 2017 -0600
Committer: Eric Friedrich <fr...@apache.org>
Committed: Wed Jun 14 15:35:59 2017 -0400

----------------------------------------------------------------------
 traffic_ops_db/bin/install_systemd_unit.sh      |  16 +++
 traffic_ops_db/docker/Dockerfile                |  25 ++++
 traffic_ops_db/docker/docker-compose.yml        |  42 +++++++
 traffic_ops_db/docker/todb.sh                   |  51 ++++++++
 traffic_ops_db/pg-migration/Dockerfile-convert  |  28 +++++
 traffic_ops_db/pg-migration/Dockerfile-mysql    |  26 ++++
 .../pg-migration/Dockerfile-mysql-to-postgres   |  38 ++++++
 traffic_ops_db/pg-migration/Dockerfile-pgloader |  19 +++
 traffic_ops_db/pg-migration/Dockerfile-postgres |  29 +++++
 traffic_ops_db/pg-migration/Dockerfile-waiter   |  24 ++++
 traffic_ops_db/pg-migration/README.md           |  16 +++
 traffic_ops_db/pg-migration/convert.yml         |  23 ++++
 traffic_ops_db/pg-migration/convert_bools.sql   | 112 +++++++++++++++++
 traffic_ops_db/pg-migration/migrate.sh          | 120 +++++++++++++++++++
 .../pg-migration/mysql-to-postgres.env          |  43 +++++++
 .../pg-migration/mysql-to-postgres.sh           |  65 ++++++++++
 .../pg-migration/mysql-to-postgres.yml          |  24 ++++
 .../pg-migration/mysql/conf.d/mysql.cnf         |  21 ++++
 traffic_ops_db/pg-migration/mysql_host.yml      |  24 ++++
 traffic_ops_db/pg-migration/pgloader.yml        |  23 ++++
 traffic_ops_db/pg-migration/postgres.yml        |  34 ++++++
 traffic_ops_db/pg-migration/runconvert.sh       |  15 +++
 traffic_ops_db/pg-migration/runmysql.sh         |  16 +++
 traffic_ops_db/pg-migration/runpgloader.sh      |  24 ++++
 traffic_ops_db/pg-migration/runwaiter.sh        |  13 ++
 traffic_ops_db/pg-migration/waiter.yml          |  24 ++++
 26 files changed, 895 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/bin/install_systemd_unit.sh
----------------------------------------------------------------------
diff --git a/traffic_ops_db/bin/install_systemd_unit.sh b/traffic_ops_db/bin/install_systemd_unit.sh
new file mode 100644
index 0000000..321a101
--- /dev/null
+++ b/traffic_ops_db/bin/install_systemd_unit.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+#
+#  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.
+#
+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/docker/Dockerfile
----------------------------------------------------------------------
diff --git a/traffic_ops_db/docker/Dockerfile b/traffic_ops_db/docker/Dockerfile
new file mode 100644
index 0000000..23556d6
--- /dev/null
+++ b/traffic_ops_db/docker/Dockerfile
@@ -0,0 +1,25 @@
+#
+#  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.
+#
+FROM postgres:latest
+
+MAINTAINER Dan Kirkwood
+
+# Postgres Access
+ENV POSTGRES_USER=$POSTGRES_USER
+ENV POSTGRES_HOST=$POSTGRES_HOST
+ENV POSTGRES_PORT=$POSTGRES_PORT
+ENV POSTGRES_DATABASE=$POSTGRES_DATABASE
+#COPY docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d
+
+EXPOSE "5432:5432"

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/docker/docker-compose.yml
----------------------------------------------------------------------
diff --git a/traffic_ops_db/docker/docker-compose.yml b/traffic_ops_db/docker/docker-compose.yml
new file mode 100644
index 0000000..494c154
--- /dev/null
+++ b/traffic_ops_db/docker/docker-compose.yml
@@ -0,0 +1,42 @@
+#
+#  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.
+#
+version: '2'
+
+services:
+  db:
+    build:
+      context: .
+      dockerfile: Dockerfile
+    environment:
+      - POSTGRES_HOST=localhost
+      - POSTGRES_PORT=5432
+      - POSTGRES_DATABASE=traffic_ops
+      - POSTGRES_USER=postgres
+      - POSTGRES_USER_UID=9999
+      - POSTGRES_USER_GID=9999
+      - PGDATA=${PGDATA}
+    ports:
+      - 5432:5432
+    volumes:
+      - ./pgdata:/pgdata
+      - ./logs:/var/log/postgresql
+    networks:
+      - default
+
+networks:
+  default:
+     driver: bridge
+
+volumes:
+  pgdata:

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/docker/todb.sh
----------------------------------------------------------------------
diff --git a/traffic_ops_db/docker/todb.sh b/traffic_ops_db/docker/todb.sh
new file mode 100755
index 0000000..7a6e6e4
--- /dev/null
+++ b/traffic_ops_db/docker/todb.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+#
+#  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.
+#
+
+# Docker wrapper script to start/manage your Postgres container
+
+ACTION=$1
+
+PROJECT_NAME=trafficops
+CONTAINER_NAME=trafficops_db_1
+
+if [[ "$ACTION" == "setup" ]];then
+  createuser traffic_ops -U postgres -h localhost
+  createdb traffic_ops --owner traffic_ops -U postgres -h localhost 
+  psql -c "\l" -U postgres -h localhost
+  echo "Setup complete"
+
+elif [[ "$ACTION" == "run" ]];then
+  docker-compose -p $PROJECT_NAME up -d
+  echo "Started Docker container: $CONTAINER_NAME"
+
+elif [[ "$ACTION" == "stop" ]];then
+  docker-compose -p $PROJECT_NAME down -v
+  echo "Stopping Docker container: $CONTAINER_NAME"
+
+elif [[ "$ACTION" == "clean" ]];then
+  rm -rf pgdata
+  docker stop $CONTAINER_NAME
+  docker rm $CONTAINER_NAME
+  docker rmi $PROJECT_NAME
+
+elif [[ "$ACTION" == "seed" ]];then
+  docker-compose -p $PROJECT_NAME down -v
+else
+  echo "Valid actions: 'setup', 'run', 'stop', 'clean'"
+  exit 0
+fi
+
+docker ps

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/Dockerfile-convert
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/Dockerfile-convert b/traffic_ops_db/pg-migration/Dockerfile-convert
new file mode 100644
index 0000000..454f58a
--- /dev/null
+++ b/traffic_ops_db/pg-migration/Dockerfile-convert
@@ -0,0 +1,28 @@
+#
+#  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.
+#
+FROM dewrich/postgres:latest
+
+MAINTAINER Dan Kirkwood
+
+# Postgres Access
+ENV POSTGRES_HOST=$POSTGRES_HOST
+ENV POSTGRES_PORT=$POSTGRES_PORT
+ENV POSTGRES_DATABASE=$POSTGRES_DATABASE
+ENV POSTGRES_PASSWORD=$POSTGRES_PASSWORD
+
+RUN apt-get update 
+ADD pg-migration/runconvert.sh .
+ADD pg-migration/convert_bools.sql .
+
+CMD ./runconvert.sh

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/Dockerfile-mysql
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/Dockerfile-mysql b/traffic_ops_db/pg-migration/Dockerfile-mysql
new file mode 100644
index 0000000..0b3d0df
--- /dev/null
+++ b/traffic_ops_db/pg-migration/Dockerfile-mysql
@@ -0,0 +1,26 @@
+#
+#  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.
+#
+FROM mysql:5.6
+
+MAINTAINER Dan Kirkwood
+
+# Mysql Access
+ENV MYSQL_HOST=$MYSQL_HOST
+ENV MYSQL_PORT=$MYSQL_PORT
+ENV MYSQL_PASSWORD=$MYSQL_PASSWORD
+ENV MYSQL_DATABASE=$MYSQL_DATABASE
+
+EXPOSE 3306
+ADD runmysql.sh /
+CMD /runmysql.sh

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/Dockerfile-mysql-to-postgres
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/Dockerfile-mysql-to-postgres b/traffic_ops_db/pg-migration/Dockerfile-mysql-to-postgres
new file mode 100644
index 0000000..b1da689
--- /dev/null
+++ b/traffic_ops_db/pg-migration/Dockerfile-mysql-to-postgres
@@ -0,0 +1,38 @@
+#
+#  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.
+#
+FROM dimitri/pgloader:latest
+MAINTAINER Dan Kirkwood <da...@apache.org>
+
+# Traffic Ops Access
+ENV TO_SERVER=$TO_SERVER
+ENV TO_USER=$TO_USER
+ENV TO_PASSWORD=$TO_PASSWORD
+
+# Mysql Access
+ENV MYSQL_HOST=$MYSQL_HOST
+ENV MYSQL_PORT=$MYSQL_PORT
+ENV MYSQL_PASSWORD=$MYSQL_PASSWORD
+ENV MYSQL_DATABASE=$MYSQL_DATABASE
+
+# Postgres Access
+ENV POSTGRES_HOST=$POSTGRES_HOST
+ENV POSTGRES_PORT=$POSTGRES_PORT
+ENV POSTGRES_DATABASE=$POSTGRES_DATABASE
+ENV POSTGRES_PASSWORD=$POSTGRES_PASSWORD
+
+# install the tools for getting data
+RUN apt-get -y update && apt-get -y install curl mysql-client
+
+ADD mysql-to-postgres.sh .
+CMD ./mysql-to-postgres.sh

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/Dockerfile-pgloader
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/Dockerfile-pgloader b/traffic_ops_db/pg-migration/Dockerfile-pgloader
new file mode 100644
index 0000000..fec7f97
--- /dev/null
+++ b/traffic_ops_db/pg-migration/Dockerfile-pgloader
@@ -0,0 +1,19 @@
+#
+#  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.
+#
+FROM dimitri/pgloader:latest
+MAINTAINER Dan Kirkwood <da...@apache.org>
+
+ADD pg-migration/runpgloader.sh .
+ADD create_tables.sql .
+CMD ./runpgloader.sh

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/Dockerfile-postgres
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/Dockerfile-postgres b/traffic_ops_db/pg-migration/Dockerfile-postgres
new file mode 100644
index 0000000..6f3c634
--- /dev/null
+++ b/traffic_ops_db/pg-migration/Dockerfile-postgres
@@ -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.
+#
+FROM dewrich/postgres:latest
+
+MAINTAINER Dan Kirkwood
+
+# Postgres Access
+ENV POSTGRES_HOST=$POSTGRES_HOST
+ENV POSTGRES_PORT=$POSTGRES_PORT
+ENV POSTGRES_DATABASE=$POSTGRES_DATABASE
+ENV POSTGRES_PASSWORD=$POSTGRES_PASSWORD
+
+# Adjust PostgreSQL configuration so that remote connections to the
+# database are possible.
+RUN echo "host all  all    0.0.0.0/0  md5" >> $PGDATA/pg_hba.conf
+RUN echo "listen_addresses='*'" >> $PGDATA/postgresql.conf
+
+EXPOSE "5432:5432"

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/Dockerfile-waiter
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/Dockerfile-waiter b/traffic_ops_db/pg-migration/Dockerfile-waiter
new file mode 100644
index 0000000..0531c71
--- /dev/null
+++ b/traffic_ops_db/pg-migration/Dockerfile-waiter
@@ -0,0 +1,24 @@
+#
+#  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.
+#
+FROM dimitri/pgloader:latest
+
+MAINTAINER Dewayne Richardson
+
+RUN apt-get -y update && apt-get -y install netcat
+
+ENV WAITER_HOST=$WAITER_HOST
+ENV WAITER_PORT=$WAITER_PORT
+
+ADD pg-migration/runwaiter.sh .
+CMD ./runwaiter.sh

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/README.md
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/README.md b/traffic_ops_db/pg-migration/README.md
new file mode 100644
index 0000000..005e6e5
--- /dev/null
+++ b/traffic_ops_db/pg-migration/README.md
@@ -0,0 +1,16 @@
+# Converts existing mysql `traffic_ops` database to postgres
+
+* Requires a fairly recent ( 17.05.0-ce ) version of `docker-engine` and `docker-compose`.
+
+* Modify the mysql-to-postgres.env file for the parameters in your Traffic Ops environment
+
+* Ensure that your new Postgres service is running (local or remote)
+
+* A sample Postgres Docker container has been provided for testing
+  1. `cd ../docker`
+  2. `$ sh todb.sh run` - to download/start your Postgres Test Docker container
+  3. `$ sh todb.sh setup` - to create your new 'traffic_ops' role and 'traffic_ops' database
+
+* Run the Mysql to Postgres Migration Docker flow
+  1. `$ cd ../pg-migration`
+  2. `$ sh migrate.sh`

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/convert.yml
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/convert.yml b/traffic_ops_db/pg-migration/convert.yml
new file mode 100644
index 0000000..fb130e9
--- /dev/null
+++ b/traffic_ops_db/pg-migration/convert.yml
@@ -0,0 +1,23 @@
+#
+#  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.
+#
+version: '2'
+
+services:
+  # convert runs necessary post-import conversion(s) in postgres
+  convert:
+    build:
+      context: ..
+      dockerfile: pg-migration/Dockerfile-convert
+    env_file:
+      - mysql-to-postgres.env

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/convert_bools.sql
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/convert_bools.sql b/traffic_ops_db/pg-migration/convert_bools.sql
new file mode 100755
index 0000000..5835e6c
--- /dev/null
+++ b/traffic_ops_db/pg-migration/convert_bools.sql
@@ -0,0 +1,112 @@
+-- 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.
+
+ALTER TABLE cdn
+  ALTER COLUMN dnssec_enabled DROP DEFAULT,
+	ALTER COLUMN dnssec_enabled TYPE boolean
+		USING CASE WHEN dnssec_enabled = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN dnssec_enabled SET DEFAULT FALSE;
+
+ALTER TABLE deliveryservice
+  ALTER COLUMN active DROP DEFAULT,
+	ALTER COLUMN active TYPE boolean
+		USING CASE WHEN active = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN active SET DEFAULT FALSE;
+
+ALTER TABLE deliveryservice
+  ALTER COLUMN signed DROP DEFAULT,
+	ALTER COLUMN signed TYPE boolean
+		USING CASE WHEN signed = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN signed SET DEFAULT FALSE;
+
+ALTER TABLE deliveryservice
+  ALTER COLUMN ipv6_routing_enabled DROP DEFAULT,
+	ALTER COLUMN ipv6_routing_enabled TYPE boolean
+		USING CASE WHEN ipv6_routing_enabled = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN ipv6_routing_enabled SET DEFAULT FALSE;
+
+ALTER TABLE deliveryservice
+  ALTER COLUMN multi_site_origin DROP DEFAULT,
+	ALTER COLUMN multi_site_origin TYPE boolean
+		USING CASE WHEN multi_site_origin = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN multi_site_origin SET DEFAULT FALSE;
+
+ALTER TABLE deliveryservice
+  ALTER COLUMN regional_geo_blocking DROP DEFAULT,
+	ALTER COLUMN regional_geo_blocking TYPE boolean
+		USING CASE WHEN regional_geo_blocking = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN regional_geo_blocking SET DEFAULT FALSE;
+
+ALTER TABLE deliveryservice
+  ALTER COLUMN logs_enabled DROP DEFAULT,
+	ALTER COLUMN logs_enabled TYPE boolean
+		USING CASE WHEN logs_enabled = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN logs_enabled SET DEFAULT FALSE;
+
+  ALTER TABLE goose_db_version
+  ALTER COLUMN is_applied DROP DEFAULT,
+	ALTER COLUMN is_applied TYPE boolean
+		USING CASE WHEN is_applied = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN is_applied SET DEFAULT FALSE;
+
+ALTER TABLE parameter
+  ALTER COLUMN secure DROP DEFAULT,
+	ALTER COLUMN secure TYPE boolean
+		USING CASE WHEN secure = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN secure SET DEFAULT FALSE;
+
+ALTER TABLE server
+  ALTER COLUMN upd_pending DROP DEFAULT,
+	ALTER COLUMN upd_pending TYPE boolean
+		USING CASE WHEN upd_pending = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN upd_pending SET DEFAULT FALSE;
+
+ALTER TABLE tm_user
+  ALTER COLUMN new_user DROP DEFAULT,
+	ALTER COLUMN new_user TYPE boolean
+		USING CASE WHEN new_user = 1 THEN TRUE
+			ELSE FALSE
+			END,
+  ALTER COLUMN new_user SET DEFAULT FALSE;
+
+ALTER TABLE to_extension
+  ALTER COLUMN isactive DROP DEFAULT,
+	ALTER COLUMN isactive TYPE boolean
+		USING CASE WHEN isactive = 1 THEN TRUE
+			ELSE FALSE
+			END,
+    ALTER COLUMN isactive SET DEFAULT FALSE;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/migrate.sh
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/migrate.sh b/traffic_ops_db/pg-migration/migrate.sh
new file mode 100755
index 0000000..f5b4388
--- /dev/null
+++ b/traffic_ops_db/pg-migration/migrate.sh
@@ -0,0 +1,120 @@
+#!/bin/bash 
+#
+#  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.
+#
+
+. mysql-to-postgres.env
+
+#Traffic Ops Settings
+# The following configs should be configured to point to the 
+# Traffic Ops instances that is connected to the MySQL that 
+# you want to convert
+separator="---------------------------------------"
+docker_project="pgmigration"
+
+function display_env() {
+
+  echo "TO_SERVER: $TO_SERVER"
+  echo "TO_USER: $TO_USER"
+  echo "TO_PASSWORD: $TO_PASSWORD"
+  echo "MYSQL_HOST: $MYSQL_HOST"
+  echo "MYSQL_PORT: $MYSQL_PORT"
+  echo "MYSQL_DATABASE: $MYSQL_DATABASE"
+  echo "MYSQL_USER: $MYSQL_USER"
+  echo "MYSQL_PASSWORD: $MYSQL_PASSWORD"
+
+  echo "POSTGRES_HOST: $POSTGRES_HOST"
+  echo "POSTGRES_PORT: $POSTGRES_PORT"
+  echo "POSTGRES_DATABASE: $POSTGRES_DATABASE"
+  echo "POSTGRES_USER: $POSTGRES_USER"
+  echo "POSTGRES_PASSOWRD: $POSTGRES_PASSWORD"
+  echo "PGDATA: $PGDATA"
+  echo "PGDATA_VOLUME: $PGDATA_VOLUME"
+  echo "PGLOGS_VOLUME: $PGLOGS_VOLUME"
+
+}
+
+
+function start_staging_mysql_server() {
+
+  docker-compose -p $docker_project -f mysql_host.yml down --remove-orphans
+  docker-compose -p $docker_project -f mysql_host.yml up --build -d
+
+  #Wait for MySQL to come up
+  export WAITER_HOST=$MYSQL_HOST
+  export WAITER_PORT=$MYSQL_PORT
+  docker-compose -p $docker_project -f waiter.yml up --build
+  echo $separator
+  echo "Mysql Host is started..."
+  echo $separator
+
+  #Ensure the Postgres instance is up
+  export WAITER_HOST=$POSTGRES_HOST
+  export WAITER_PORT=$POSTGRES_PORT
+  docker-compose -p $docker_project -f waiter.yml up --build
+  echo $separator
+  echo "Postgres Host is started..."
+  echo $separator
+
+}
+
+function migrate_data_from_mysql_to_postgres() {
+
+  echo $separator
+  echo "Starting Mysql to Postgres Migration..."
+  echo $separator
+  docker-compose -p $docker_project -f mysql-to-postgres.yml down
+  docker-compose -p $docker_project -f mysql-to-postgres.yml up --build
+}
+
+
+function run_postgres_datatypes_conversion() {
+  echo $separator
+  echo "Starting Mysql to Postgres Datatype Conversion..."
+  echo $separator
+  docker-compose -p $docker_project -f convert.yml up --build
+}
+
+
+function clean() {
+  echo $separator
+  echo "Cleaning up..."
+  echo $separator
+
+  # Powerdown the containers (to remove them)
+  docker-compose -p $docker_project -f mysql-to-postgres.yml down --remove-orphans
+  docker-compose -p $docker_project -f convert.yml down --remove-orphans
+
+  # Cleanup any temporary images
+  IMAGE=$docker_project"_mysql-to-postgres"
+  echo "IMAGE: $IMAGE"
+  docker rmi $IMAGE
+  IMAGE=$docker_project"_convert"
+  docker rmi $IMAGE
+  docker rmi mysql:5.6 
+  docker rmi dimitri/pgloader:latest
+  IMAGE=$docker_project"_mysql_host"
+  docker rmi $IMAGE --force
+  IMAGE=$docker_project"_waiter"
+  docker rmi $IMAGE --force
+
+  # Cleanup any dangling volumes
+  docker volume rm $(docker volume ls -qf dangling=true)
+}
+
+clean
+start_staging_mysql_server
+#display_env
+migrate_data_from_mysql_to_postgres
+run_postgres_datatypes_conversion
+clean

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/mysql-to-postgres.env
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/mysql-to-postgres.env b/traffic_ops_db/pg-migration/mysql-to-postgres.env
new file mode 100644
index 0000000..086e68e
--- /dev/null
+++ b/traffic_ops_db/pg-migration/mysql-to-postgres.env
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+#  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.
+#
+
+#Traffic Ops Settings
+# The following configs should be configured to point to the 
+# Traffic Ops instances that is connected to the MySQL that 
+# you want to convert
+TO_SERVER=to_url
+TO_USER=(your_user)
+TO_PASSWORD=(your_password)
+
+# Staging Mysql 
+# These variables are for the "staging" Docker MySQL instance that is used
+# to load the Traffic Ops "dbdump" into.  ONLY change the MYSQL_HOST variable
+# Leave the other variables.
+MYSQL_HOST=( the_ip_address_running_this_migration )
+MYSQL_PORT=3306
+MYSQL_DATABASE=traffic_ops_db
+MYSQL_USER=to_user
+MYSQL_PASSWORD=twelve
+MYSQL_RANDOM_ROOT_PASSWORD=yes
+
+# New production Postgres Settings, these variables should be changed for the Postgres 
+# instance that will contain the existing MySQL data converted
+POSTGRES_HOST=( the_ip_address_running_this_migration )
+POSTGRES_PORT=5432
+# NOTE: The new database name for Traffic Ops
+POSTGRES_DATABASE=traffic_ops
+POSTGRES_USER=traffic_ops
+POSTGRES_PASSWORD=( your_new_postgres_password )
+PGDATA=/opt/postgresql/data/pgdata

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/mysql-to-postgres.sh
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/mysql-to-postgres.sh b/traffic_ops_db/pg-migration/mysql-to-postgres.sh
new file mode 100755
index 0000000..7ab7013
--- /dev/null
+++ b/traffic_ops_db/pg-migration/mysql-to-postgres.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+#
+#  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.
+#
+# ------------------------------------------------------
+
+echo "Dumping Data from Traffic Ops Instance: $TO_SERVER" 
+output=/tmp/trafficops_init.sql
+[[ -n $output ]] && output="-o $output"
+
+cookiejar=/tmp/cookiejar
+cred=/tmp/cred.json
+
+echo "----------------------------------------"
+echo "Migrating Mysql data from:"
+echo "----------------------------------------"
+echo "MYSQL_HOST: $MYSQL_HOST"
+echo "MYSQL_USER: $MYSQL_USER"
+echo "MYSQL_DATABASE: $MYSQL_DATABASE"
+echo "----------------------------------------"
+
+echo "----------------------------------------"
+echo "To Postgres..."
+echo "----------------------------------------"
+echo "POSTGRES_HOST: $POSTGRES_HOST"
+echo "POSTGRES_USER: $POSTGRES_USER"
+echo "POSTGRES_DATABASE: $POSTGRES_DATABASE"
+echo "----------------------------------------"
+
+cat >$cred <<-CREDS
+	{ "u" : "$TO_USER", "p" : "$TO_PASSWORD" }
+CREDS
+
+curl -f -k -H "Accept: application/json" --cookie "$cookiejar" --cookie-jar "$cookiejar" -X POST --data @"$cred" "$TO_SERVER/api/1.2/user/login"  || exit 1
+curl $output -f -k -s --cookie "$cookiejar" -X GET "$TO_SERVER/dbdump"  || exit 1
+
+echo  "[client]" > /root/.my.cnf
+echo  "user=$MYSQL_USER" >> /root/.my.cnf 
+echo  "password=$MYSQL_PASSWORD" >> /root/.my.cnf 
+chmod 0600 /root/.my.cnf
+mysql -h $MYSQL_HOST $MYSQL_DATABASE < /tmp/trafficops_init.sql
+
+pgloader -v \
+	--cast 'type tinyint to smallint drop typemod' \
+	--cast 'type varchar to text drop typemod' \
+	--cast 'type double to numeric drop typemod' \
+	mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST/$MYSQL_DATABASE \
+	postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DATABASE
+
+# For debugging
+#while true; do
+#    echo "Waiting.."
+#    sleep 3
+#done
+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/mysql-to-postgres.yml
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/mysql-to-postgres.yml b/traffic_ops_db/pg-migration/mysql-to-postgres.yml
new file mode 100644
index 0000000..b5c99df
--- /dev/null
+++ b/traffic_ops_db/pg-migration/mysql-to-postgres.yml
@@ -0,0 +1,24 @@
+#
+#  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.
+#
+version: '2'
+
+services:
+  # dataimport reads data from an existing traffic_ops server running mysql thru the API
+  mysql-to-postgres:
+    build:
+        context: .
+        dockerfile: Dockerfile-mysql-to-postgres
+    restart: "no"
+    env_file:
+      - mysql-to-postgres.env

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/mysql/conf.d/mysql.cnf
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/mysql/conf.d/mysql.cnf b/traffic_ops_db/pg-migration/mysql/conf.d/mysql.cnf
new file mode 100755
index 0000000..c2c94fe
--- /dev/null
+++ b/traffic_ops_db/pg-migration/mysql/conf.d/mysql.cnf
@@ -0,0 +1,21 @@
+#
+#  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 is custom config file attached from docker host
+
+[mysql]
+default_character_set = utf8
+
+[mysqld]
+character_set_server = utf8          # If you prefer utf8
+collation_server = utf8_general_ci

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/mysql_host.yml
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/mysql_host.yml b/traffic_ops_db/pg-migration/mysql_host.yml
new file mode 100644
index 0000000..fb02e3b
--- /dev/null
+++ b/traffic_ops_db/pg-migration/mysql_host.yml
@@ -0,0 +1,24 @@
+#
+#  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.
+#
+version: '2'
+
+services:
+  mysql_host:
+    build:
+      context: .
+      dockerfile: Dockerfile-mysql
+    env_file:
+      - mysql-to-postgres.env
+    ports:
+      - "3306:3306"

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/pgloader.yml
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/pgloader.yml b/traffic_ops_db/pg-migration/pgloader.yml
new file mode 100644
index 0000000..d9e3149
--- /dev/null
+++ b/traffic_ops_db/pg-migration/pgloader.yml
@@ -0,0 +1,23 @@
+#
+#  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.
+#
+version: '2'
+
+services:
+  # pgloader converts the data from mysql to postgres
+  pgloader:
+    build:
+      context: ..
+      dockerfile: pg-migration/Dockerfile-pgloader
+    env_file:
+      - mysql-to-postgres.env

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/postgres.yml
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/postgres.yml b/traffic_ops_db/pg-migration/postgres.yml
new file mode 100644
index 0000000..72a765e
--- /dev/null
+++ b/traffic_ops_db/pg-migration/postgres.yml
@@ -0,0 +1,34 @@
+#
+#  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.
+#
+version: '2'
+
+services:
+  db:
+    build:
+      context: ..
+      dockerfile: pg-migration/Dockerfile-postgres
+    env_file:
+      - mysql-to-postgres.env
+    ports:
+      - 5432:5432
+    volumes:
+      - ./pgdata:/opt/postgresql/data/pgdata
+      - ./postgres_logs:/var/log/postgresql
+    networks:
+      - default
+
+networks:
+  default:
+     driver: bridge
+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/runconvert.sh
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/runconvert.sh b/traffic_ops_db/pg-migration/runconvert.sh
new file mode 100755
index 0000000..59b1afb
--- /dev/null
+++ b/traffic_ops_db/pg-migration/runconvert.sh
@@ -0,0 +1,15 @@
+#!/bin/bash -x
+#
+#  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.
+# Load required conversion of booleans
+psql postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DATABASE < ./convert_bools.sql

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/runmysql.sh
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/runmysql.sh b/traffic_ops_db/pg-migration/runmysql.sh
new file mode 100755
index 0000000..0c29dee
--- /dev/null
+++ b/traffic_ops_db/pg-migration/runmysql.sh
@@ -0,0 +1,16 @@
+#!/bin/bash -x
+#
+#  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.
+#
+
+docker-entrypoint.sh mysqld

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/runpgloader.sh
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/runpgloader.sh b/traffic_ops_db/pg-migration/runpgloader.sh
new file mode 100755
index 0000000..f6a7d7d
--- /dev/null
+++ b/traffic_ops_db/pg-migration/runpgloader.sh
@@ -0,0 +1,24 @@
+#!/bin/bash -x
+#
+#  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.
+#
+
+pgloader -v \
+	--before create_tables.sql \
+	--cast 'type tinyint to smallint drop typemod' \
+	--cast 'type varchar to text drop typemod' \
+	--cast 'type double to numeric drop typemod' \
+        --with truncate \
+	mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST/traffic_ops_db \
+	postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DATABASE
+exit 0

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/runwaiter.sh
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/runwaiter.sh b/traffic_ops_db/pg-migration/runwaiter.sh
new file mode 100755
index 0000000..7cf2222
--- /dev/null
+++ b/traffic_ops_db/pg-migration/runwaiter.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+
+echo "WAITER_HOST: $WAITER_HOST"
+echo "WAITER_PORT: $WAITER_PORT"
+
+for c in "$WAITER_HOST $WAITER_PORT" ; do
+  while true; do
+     echo "Waiting 3 seconds for Host and Port: $c "
+     sleep 3
+     nc -z $c && break
+  done
+done

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d20484de/traffic_ops_db/pg-migration/waiter.yml
----------------------------------------------------------------------
diff --git a/traffic_ops_db/pg-migration/waiter.yml b/traffic_ops_db/pg-migration/waiter.yml
new file mode 100644
index 0000000..2796737
--- /dev/null
+++ b/traffic_ops_db/pg-migration/waiter.yml
@@ -0,0 +1,24 @@
+#
+#  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.
+#
+version: '2'
+
+services:
+  # waits for a port to be available
+  waiter:
+    build:
+      context: ..
+      dockerfile: pg-migration/Dockerfile-waiter
+    environment:
+      - WAITER_HOST
+      - WAITER_PORT