-- Seed the base container_types rows that were originally inserted by
-- setup-schema.sql. setup-schema.sql is no longer applied by setup.sh
-- (replaced by the canonical complete-database-setup.sql), and the
-- canonical regen only captures DML from migrations — so these rows
-- never made it into fresh-install state and the panel could not create
-- any sites on a clean box (cpanel import on whp02 surfaced this).
--
-- INSERT IGNORE keeps this safe on servers (whp01) where the rows have
-- existed since the setup-schema.sql era. The `name` column is a UNIQUE
-- KEY, so duplicates are silently skipped — IDs may differ between
-- servers and that's fine: foreign keys store the assigned id.
USE whp;

INSERT IGNORE INTO container_types
    (name, description, base_image, min_cpu, min_memory,
     startup_env, user_variables, mount_options, listen_port, listen_port_tls, active)
VALUES
('PHP 7.4', 'Apache with PHP 7.4', 'repo.anhonesthost.net/cloud-hosting-platform/cac:php74', 0.25, 256,
 '{"uid": "${WHP_UID}", "user": "${WHP_USER}", "domain": "${WHP_DOMAIN}"}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/home/${WHP_USER}", "type": "bind"}]}',
 443, 1, 1),

('PHP 8.0', 'Apache with PHP 8.0', 'repo.anhonesthost.net/cloud-hosting-platform/cac:php80', 0.25, 256,
 '{"uid": "${WHP_UID}", "user": "${WHP_USER}", "domain": "${WHP_DOMAIN}"}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/home/${WHP_USER}", "type": "bind"}]}',
 443, 1, 1),

('PHP 8.1', 'Apache with PHP 8.1', 'repo.anhonesthost.net/cloud-hosting-platform/cac:php81', 0.25, 256,
 '{"uid": "${WHP_UID}", "user": "${WHP_USER}", "domain": "${WHP_DOMAIN}"}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/home/${WHP_USER}", "type": "bind"}]}',
 443, 1, 1),

('PHP 8.2', 'Apache with PHP 8.2', 'repo.anhonesthost.net/cloud-hosting-platform/cac:php82', 0.25, 256,
 '{"uid": "${WHP_UID}", "user": "${WHP_USER}", "domain": "${WHP_DOMAIN}"}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/home/${WHP_USER}", "type": "bind"}]}',
 443, 1, 1),

('PHP 8.3', 'Apache with PHP 8.3', 'repo.anhonesthost.net/cloud-hosting-platform/cac:php83', 0.25, 256,
 '{"uid": "${WHP_UID}", "user": "${WHP_USER}", "domain": "${WHP_DOMAIN}"}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/home/${WHP_USER}", "type": "bind"}]}',
 443, 1, 1),

('PHP 8.4', 'Apache with PHP 8.4', 'repo.anhonesthost.net/cloud-hosting-platform/cac:php84', 0.25, 256,
 '{"uid": "${WHP_UID}", "user": "${WHP_USER}", "domain": "${WHP_DOMAIN}"}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/home/${WHP_USER}", "type": "bind"}]}',
 443, 1, 1),

('PHP 8.5', 'Apache with PHP 8.5', 'repo.anhonesthost.net/cloud-hosting-platform/cac:php85', 0.25, 256,
 '{"uid": "${WHP_UID}", "user": "${WHP_USER}", "domain": "${WHP_DOMAIN}"}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/home/${WHP_USER}", "type": "bind"}]}',
 443, 1, 1),

('Static Apache', 'Default Apache container for static content only', 'repo.anhonesthost.net/cloud-hosting-platform/whp-default:latest', 0.25, 256,
 '{}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/usr/local/apache2/htdocs", "type": "bind"}]}',
 80, 0, 1),

('Node18', 'Node.js 18 runtime', 'repo.anhonesthost.net/cloud-hosting-platform/cnoc:node18', 0.25, 256,
 '{"uid": "${WHP_UID}", "user": "${WHP_USER}", "domain": "${WHP_DOMAIN}"}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/home/${WHP_USER}", "type": "bind"}]}',
 3000, 0, 1),

('Node20', 'Node.js 20 runtime', 'repo.anhonesthost.net/cloud-hosting-platform/cnoc:node20', 0.25, 256,
 '{"uid": "${WHP_UID}", "user": "${WHP_USER}", "domain": "${WHP_DOMAIN}"}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/home/${WHP_USER}", "type": "bind"}]}',
 3000, 0, 1),

('Node22', 'Node.js 22 runtime', 'repo.anhonesthost.net/cloud-hosting-platform/cnoc:node22', 0.25, 256,
 '{"uid": "${WHP_UID}", "user": "${WHP_USER}", "domain": "${WHP_DOMAIN}"}',
 '{}',
 '{"volumes": [{"source": "${WHP_HOME}/${WHP_DOMAIN}", "target": "/home/${WHP_USER}", "type": "bind"}]}',
 3000, 0, 1);

-- Bring eol_date in line with 2026.04.10/add-eol-date-to-container-types.sql
-- for any of the rows we just inserted (the older PHP versions). UPDATE is a
-- no-op if rows already had eol_date set (e.g. on whp01).
UPDATE container_types SET eol_date = '2022-11-28' WHERE name = 'PHP 7.4' AND eol_date IS NULL;
UPDATE container_types SET eol_date = '2023-11-26' WHERE name = 'PHP 8.0' AND eol_date IS NULL;
UPDATE container_types SET eol_date = '2025-12-31' WHERE name = 'PHP 8.1' AND eol_date IS NULL;
