This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Idempotentiate Traffic Vault create_tables.sql#6717
Merged
zrhoffman merged 5 commits intoapache:masterfrom May 16, 2022
Merged
Conversation
zrhoffman
suggested changes
May 4, 2022
Member
zrhoffman
left a comment
There was a problem hiding this comment.
This is close, but the indices are missing:
--- upstream.sql 2022-05-04 08:20:44.952817606 -0600
+++ davidc0le.sql 2022-05-04 08:21:45.057162887 -0600
@@ -155,27 +155,6 @@
--
--- Name: sslkey_cdn_idx; Type: INDEX; Schema: public; Owner: traffic_ops
---
-
-CREATE INDEX sslkey_cdn_idx ON public.sslkey USING btree (cdn);
-
-
---
--- Name: sslkey_deliveryservice_idx; Type: INDEX; Schema: public; Owner: traffic_ops
---
-
-CREATE INDEX sslkey_deliveryservice_idx ON public.sslkey USING btree (deliveryservice);
-
-
---
--- Name: sslkey_version_idx; Type: INDEX; Schema: public; Owner: traffic_ops
---
-
-CREATE INDEX sslkey_version_idx ON public.sslkey USING btree (version);
-
-
---
-- Name: dnssec dnssec_last_updated; Type: TRIGGER; Schema: public; Owner: traffic_ops
--checked using
import_and_dump_tv_schema() {
output_file="$1";
<<'DOCKER_COMMANDS' docker run --rm -i \
-v "$(pwd)/traffic_ops/app/db/trafficvault/create_tables.sql:/create_tables.sql" \
-e POSTGRES_USER=traffic_ops \
-e POSTGRES_PASSWORD=twelve \
-e PGPASSWORD=twelve \
-e POSTGRES_DB=traffic_ops \
postgres:13.6-alpine bash >"$output_file";
trap 'echo "Error on line ${LINENO} of ${0}" >/dev/stderr; exit 1' ERR;
set -o errexit;
docker-entrypoint.sh postgres >/dev/stderr &
echo 'Waiting for Postgres to start...' >/dev/stderr;
sleep 10;
psql -Utraffic_ops -fcreate_tables.sql >/dev/stderr;
pg_dump -Utraffic_ops;
DOCKER_COMMANDS
};
4 tasks
zrhoffman
approved these changes
May 16, 2022
Member
zrhoffman
left a comment
There was a problem hiding this comment.
Look good. Thank you for your contribution!
zrhoffman
pushed a commit
to zrhoffman/trafficcontrol
that referenced
this pull request
Oct 2, 2022
* Idempotentiate TV create_tables.sql * CHANGELOG * Correcting issues identified by zrhoffman
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR (Pull Request) do?
Closes: #6712
Related: #4984
This PR makes changes to the Traffic Vault 'seed' schema file create_tables.sql to allow it to be run more than once. Even if db/admin --trafficvault load_schema is run more than once (for example, installing TO, with a shared database, on more than 1 host simultaneously), an SQL error should not result.
Which Traffic Control components are affected by this PR?
What is the best way to verify this PR?
A test as implemented previously in 9250b20 has been added to the Traffic Vault DB test script https://github.com/apache/trafficcontrol/blob/master/traffic_ops/app/db/trafficvault/test/run-tvdb-test.sh . Running the test as described in https://github.com/apache/trafficcontrol/blob/master/traffic_ops/app/db/trafficvault/test/README.md
PR submission checklist