49 lines
1.3 KiB
SQL
49 lines
1.3 KiB
SQL
INSERT INTO e_addresses (
|
|
id, name, public_url, country, region, city, carrier, asn, node_group,
|
|
priority, enabled, healthy, license_valid, allow_user_publish,
|
|
maintenance, description, created_at, updated_at
|
|
)
|
|
SELECT
|
|
node.id,
|
|
node.name,
|
|
rtrim(node.gateway_url, '/'),
|
|
node.country,
|
|
node.region,
|
|
node.city,
|
|
node.carrier,
|
|
node.asn,
|
|
pool.code,
|
|
node.weight,
|
|
node.enabled,
|
|
false,
|
|
false,
|
|
false,
|
|
node.maintenance OR node.draining,
|
|
'Migrated from retired proxy node ' || node.node_id,
|
|
node.created_at,
|
|
node.updated_at
|
|
FROM gateway_nodes AS node
|
|
JOIN gateway_service_pools AS pool ON pool.id = node.pool_id
|
|
WHERE node.gateway_url ~ '^https?://[^/?#[:space:]]+'
|
|
ON CONFLICT (public_url) DO UPDATE SET
|
|
name = EXCLUDED.name,
|
|
country = EXCLUDED.country,
|
|
region = EXCLUDED.region,
|
|
city = EXCLUDED.city,
|
|
carrier = EXCLUDED.carrier,
|
|
asn = EXCLUDED.asn,
|
|
node_group = EXCLUDED.node_group,
|
|
priority = EXCLUDED.priority,
|
|
description = CASE
|
|
WHEN e_addresses.description = '' THEN EXCLUDED.description
|
|
ELSE e_addresses.description
|
|
END,
|
|
updated_at = GREATEST(e_addresses.updated_at, EXCLUDED.updated_at);
|
|
|
|
DROP TABLE gateway_route_events;
|
|
DROP TABLE gateway_settings;
|
|
DROP TABLE gateway_config_versions;
|
|
DROP TABLE gateway_user_routes;
|
|
DROP TABLE gateway_nodes;
|
|
DROP TABLE gateway_service_pools;
|