-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idempotentiate Traffic Vault create_tables.sql #6717
Merged
Merged
Conversation
This file contains 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
zrhoffman
added
Traffic Ops
related to Traffic Ops
Traffic Vault
related to Traffic Vault
database
relating to setup/installation/structure of the Traffic Ops database
improvement
The functionality exists but it could be improved in some way.
labels
Apr 4, 2022
zrhoffman
requested changes
May 4, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
database
relating to setup/installation/structure of the Traffic Ops database
improvement
The functionality exists but it could be improved in some way.
Traffic Ops
related to Traffic Ops
Traffic Vault
related to Traffic Vault
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