zrhoffman commented on a change in pull request #4730: URL: https://github.com/apache/trafficcontrol/pull/4730#discussion_r452356835
########## File path: traffic_ops/app/db/migrations/20200607000000_remove_redundancy.sql ########## @@ -0,0 +1,70 @@ +/* + 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. +*/ + +-- +goose Up +ALTER TABLE server DROP CONSTRAINT need_at_least_one_ip; +ALTER TABLE server DROP CONSTRAINT need_gateway_if_ip; +ALTER TABLE server DROP CONSTRAINT need_netmask_if_ip; + +ALTER TABLE server DROP COLUMN interface_name; +ALTER TABLE server DROP COLUMN ip_address; +ALTER TABLE server DROP COLUMN ip_netmask; +ALTER TABLE server DROP COLUMN ip_gateway; +ALTER TABLE server DROP COLUMN ip6_address; +ALTER TABLE server DROP COLUMN ip6_gateway; +ALTER TABLE server DROP COLUMN interface_mtu; +ALTER TABLE server DROP COLUMN ip_address_is_service; +ALTER TABLE server DROP COLUMN ip6_address_is_service; + + +-- +goose Down +ALTER TABLE server ADD COLUMN interface_name text DEFAULT '' NOT NULL; +ALTER TABLE server ADD COLUMN ip_address text DEFAULT ''; +ALTER TABLE server ADD COLUMN ip_netmask text DEFAULT ''; +ALTER TABLE server ADD COLUMN ip_gateway text DEFAULT ''; +ALTER TABLE server ADD COLUMN ip6_address text DEFAULT ''; +ALTER TABLE server ADD COLUMN ip6_gateway text DEFAULT ''; +ALTER TABLE server ADD COLUMN interface_mtu bigint DEFAULT '9000'::bigint NOT NULL; +ALTER TABLE server ADD COLUMN ip_address_is_service boolean DEFAULT true; +ALTER TABLE server ADD COLUMN ip6_address_is_service boolean DEFAULT true; + +ALTER TABLE server ADD CONSTRAINT need_at_least_one_ip CHECK (ip_address IS NOT NULL OR ip6_address IS NOT NULL OR ip_address = '' OR ip6_address = ''); +ALTER TABLE server ADD CONSTRAINT need_gateway_if_ip CHECK (ip_address IS NULL OR ip_address = '' OR ip_gateway IS NOT NULL); +ALTER TABLE server ADD CONSTRAINT need_netmask_if_ip CHECK (ip_address IS NULL OR ip_address = '' OR ip_netmask IS NOT NULL); + +UPDATE server SET ip_address = host(ip_address.address), + ip_netmask = host(netmask(ip_address.address)), + ip_gateway = host(ip_address.gateway), Review comment: Getting SQL error: ```sql SQL Error [42804]: ERROR: CASE types inet and text cannot be matched Position: 92 ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
