Rename external URLs and move profile fields

Rename the compliance external URL concept to compliance custom links,
and move the public-facing profile fields (description, website, email,
headquarter address) off the organization onto the trust center. Backfill
managed default domains for pages that lack them.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-07-10 15:11:40 +02:00
parent b524e9b497
commit 55a8e72c17
9 changed files with 239 additions and 215 deletions

View File

@@ -0,0 +1,19 @@
-- Copyright (c) 2026 Probo Inc <hello@probo.com>.
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
ALTER TABLE compliance_external_urls RENAME TO compliance_custom_links;
ALTER TABLE compliance_custom_links
RENAME CONSTRAINT compliance_external_urls_trust_center_id_rank_key
TO compliance_custom_links_trust_center_id_rank_key;

View File

@@ -0,0 +1,34 @@
-- Copyright (c) 2026 Probo Inc <hello@probo.com>.
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
ALTER TABLE trust_centers
ADD COLUMN description TEXT,
ADD COLUMN website_url TEXT,
ADD COLUMN email CITEXT,
ADD COLUMN headquarter_address TEXT;
UPDATE trust_centers tc
SET
description = o.description,
website_url = o.website_url,
email = o.email,
headquarter_address = o.headquarter_address
FROM organizations o
WHERE tc.organization_id = o.id;
ALTER TABLE organizations
DROP COLUMN description,
DROP COLUMN website_url,
DROP COLUMN email,
DROP COLUMN headquarter_address;

View File

@@ -0,0 +1,107 @@
-- Copyright (c) 2026 Probo Inc <hello@probo.com>.
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
-- Backfill managed default domains for compliance pages created before
-- default-domain provisioning existed. Hostnames use the managed base domain
-- suffix configured on the database (probo.trust_center_base_domain), falling
-- back to probopage.com for production installs.
WITH pending_pages AS (
SELECT
tc.id AS trust_center_id,
tc.tenant_id,
tc.organization_id,
tc.slug,
tc.created_at,
(
tc.slug || '.' || COALESCE(
NULLIF(current_setting('probo.trust_center_base_domain', true), ''),
'probopage.com'
)
)::citext AS hostname
FROM trust_centers tc
WHERE tc.default_domain_id IS NULL
),
minted_certificates AS (
INSERT INTO certificates (
id,
tenant_id,
hostname,
status,
ssl_retry_count,
created_at,
updated_at
)
SELECT
translate(
encode(
substring(decode(translate(pp.trust_center_id, '-_', '+/'), 'base64') FROM 1 FOR 8)
|| int2send(104::smallint)
|| int8send((floor(extract(epoch FROM clock_timestamp()) * 1000))::bigint)
|| substring(decode(md5(random()::text || pp.trust_center_id), 'hex') FROM 1 FOR 6),
'base64'
),
'+/',
'-_'
),
pp.tenant_id,
pp.hostname,
'PENDING'::custom_domain_ssl_status,
0,
pp.created_at,
clock_timestamp()
FROM pending_pages pp
RETURNING id, hostname, tenant_id
),
minted_domains AS (
INSERT INTO custom_domains (
id,
tenant_id,
organization_id,
domain,
managed,
certificate_id,
created_at,
updated_at
)
SELECT
translate(
encode(
substring(decode(translate(mc.id, '-_', '+/'), 'base64') FROM 1 FOR 8)
|| int2send(37::smallint)
|| int8send((floor(extract(epoch FROM clock_timestamp()) * 1000))::bigint)
|| substring(decode(md5(random()::text || mc.id), 'hex') FROM 1 FOR 6),
'base64'
),
'+/',
'-_'
),
mc.tenant_id,
pp.organization_id,
pp.hostname,
true,
mc.id,
pp.created_at,
clock_timestamp()
FROM minted_certificates mc
JOIN pending_pages pp ON pp.hostname = mc.hostname
RETURNING id, domain
)
UPDATE trust_centers tc
SET
default_domain_id = md.id,
updated_at = clock_timestamp()
FROM minted_domains md
JOIN pending_pages pp ON pp.hostname = md.domain
WHERE tc.id = pp.trust_center_id;