zrhoffman commented on code in PR #6802:
URL: https://github.com/apache/trafficcontrol/pull/6802#discussion_r878577547
##########
traffic_ops/app/db/create_tables.sql:
##########
@@ -656,6 +824,45 @@ CREATE TABLE IF NOT EXISTS deliveryservice_server (
ALTER TABLE deliveryservice_server OWNER TO traffic_ops;
+--
+-- Name: deliveryservice_tls_version; Type: TABLE; Schema: public; Owner:
traffic_ops
+--
+
+CREATE TABLE IF NOT EXISTS deliveryservice_tls_version (
+ deliveryservice bigint NOT NULL,
+ tls_version text NOT NULL,
+ CONSTRAINT deliveryservice_tls_version_pkey PRIMARY KEY (deliveryservice,
tls_version),
+ CONSTRAINT deliveryservice_tls_version_tls_version_check CHECK
(tls_version <> '')
+);
+
+ALTER TABLE deliveryservice_tls_version OWNER TO traffic_ops;
+
+--
+-- Name: fast_forward_schema_migrations_trigger; Type: TRIGGER; Schema:
public; Owner: traffic_ops
+--
+DROP TRIGGER IF EXISTS fast_forward_schema_migrations_trigger on
schema_migrations;
+CREATE TRIGGER fast_forward_schema_migrations_trigger
+ AFTER UPDATE
+ ON schema_migrations
+ EXECUTE PROCEDURE fast_forward_schema_migrations_version();
Review Comment:
More `schema_migrations` stuff that should be completely removed
##########
traffic_ops/app/db/create_tables.sql:
##########
@@ -37,6 +37,30 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA
pg_catalog;
SET search_path = public, pg_catalog;
+--
+-- Name: fast_forward_schema_migrations_version(); Type: FUNCTION; Schema:
public; Owner: traffic_ops
+--
+
+CREATE OR REPLACE FUNCTION fast_forward_schema_migrations_version()
+ RETURNS TRIGGER
+ LANGUAGE PLPGSQL
+AS $$
+BEGIN
+ IF EXISTS (SELECT FROM information_schema.columns WHERE table_name =
'goose_db_version') THEN
+ UPDATE schema_migrations SET "version" = (SELECT version_id
FROM goose_db_version
+ ORDER BY TSTAMP DESC
+ LIMIT 1);
+ ALTER TABLE goose_db_version
+ RENAME TO goose_db_version_unused;
+ END IF;
+ DROP TRIGGER fast_forward_schema_migrations_trigger ON
schema_migrations;
+ DROP FUNCTION fast_forward_schema_migrations_version();
+ RETURN NULL;
+END$$;
+
+ALTER FUNCTION public.fast_forward_schema_migrations_version OWNER TO
traffic_ops;
Review Comment:
This `schema_migrations` functions should not be added to
`create_tables.sql`, it should be completely removed. It only existed to
migrate from goose to Migrate, and keeping the function breaks
`create_tables.sql`. From `trafficops.log` within the `ciab-logs.zip` artifact
of the *CDN-in-a-Box CI* workflow:
```shell
CREATE TRIGGER fast_forward_schema_migrations_trigger
AFTER UPDATE
ON schema_migrations
EXECUTE PROCEDURE fast_forward_schema_migrations_version();
ERROR: relation "schema_migrations" does not exist
ERROR:root:Failed to set up database: Database load_schema failed
ERROR:root:Can't connect to the database. Use the script
`/opt/traffic_ops/install/bin/todb_bootstrap.sh` on the db server to create it
and run `postinstall` again.
Error on line 38 of /opt/traffic_ops/install/bin/postinstall
+++ echo 'Error on line 217 of /run-go.sh'
+++ exit 1
+ cleanup
+ rm -f /tmp/tmp.AzSOeC5roH /tmp/tmp.Cw8OexrngA
Error on line 217 of /run-go.sh
```
##########
traffic_ops/app/db/trafficvault/migrations/2021042200000000_init.up.sql:
##########
@@ -1,16 +0,0 @@
-/*
Review Comment:
Now that the `db/trafficvault/migrations` directory is empty, `git` does not
create it. This breaks our db tests:
> ```shell
> ./.github/actions/todb-tests/entrypoint.sh: line 35: pushd:
traffic_ops/app/db/trafficvault/migrations: No such file or directory
> ```
Maybe add a `.gitkeep` or `.gitignore` file to ensure the directory exists?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]