-- Seed default reference/catalog data that existing servers can be missing.
--
-- Background: a rebuilt server (DB recreated from complete-database-setup.sql)
-- or a fresh install loses any catalog whose seed lived only in an older
-- migration. Two such catalogs were found empty on rebuilt whp02:
--   * container_env_templates — system env-var reference shown in the container
--     env-variable editor (libs/mysqlmgmt.php). Its original seed migration was
--     trimmed out of the repo, so NO server could re-seed it; only long-lived
--     hosts that ran it historically still have the rows.
--   * wp_recommended_plugins — default recommended-plugins catalog for the WP
--     management UI; its seed previously lived only in the 2025.07.1 migration.
--
-- Both seeds are also added to complete-database-setup.sql so fresh installs
-- get them at DB-creation time; this migration backfills already-deployed hosts.
--
-- INSERT IGNORE keyed on the unique columns (variable_name / slug) makes this
-- idempotent and non-destructive: rows that already exist (and any admin edits
-- or additions) are preserved.
USE `whp`;

INSERT IGNORE INTO `container_env_templates` (`variable_name`, `description`, `example_value`, `category`) VALUES
  ('${WHP_USER}',           'System username of the container owner',            'john',                            'user'),
  ('${WHP_UID}',            'User ID (UID) of the container owner',              '1001',                            'user'),
  ('${WHP_GID}',            'Group ID (GID) of the container owner',             '1001',                            'user'),
  ('${WHP_HOME}',           'Home directory path of the user',                  '/docker/users/john',              'path'),
  ('${WHP_DOMAIN}',         'Primary domain name assigned to the container',     'example.com',                     'domain'),
  ('${WHP_SUBDOMAIN}',      'Subdomain (if applicable)',                         'www',                             'domain'),
  ('${WHP_DOMAIN_LIST}',    'Comma-separated list of all domains for this user', 'example.com,test.com',            'domain'),
  ('${WHP_CONTAINER_NAME}', 'Unique container name',                             'john-example-com',                'system'),
  ('${WHP_PUBLIC_HTML}',    'Public HTML directory path',                        '/docker/users/john/public_html',  'path'),
  ('${WHP_LOGS_DIR}',       'Logs directory path',                               '/docker/users/john/logs',         'path'),
  ('${WHP_DATA_DIR}',       'User data directory path',                          '/docker/users/john/data',         'path');

INSERT IGNORE INTO `wp_recommended_plugins` (`slug`, `name`, `description`, `category`, `install_url`, `sort_order`) VALUES
  ('wordfence',         'Wordfence Security',  'Comprehensive security plugin with firewall and malware scanner', 'Security',    'wordfence',         10),
  ('updraftplus',       'UpdraftPlus Backup',  'Complete backup solution with remote storage options',            'Backup',      'updraftplus',       20),
  ('wp-optimize',       'WP-Optimize',         'Database optimization and caching plugin',                        'Performance', 'wp-optimize',       30),
  ('contact-form-7',    'Contact Form 7',      'Simple but flexible contact form plugin',                         'Forms',       'contact-form-7',    40),
  ('really-simple-ssl', 'Really Simple SSL',   'Lightweight SSL and security hardening plugin',                   'Security',    'really-simple-ssl', 50);
