-- DentalCare v0.5.9.8.71.2
-- Reconcile System Setup update-pending state after package release/settings repair.
CREATE TABLE IF NOT EXISTS `{{prefix}}settings` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `group_name` VARCHAR(80) NOT NULL,
  `setting_key` VARCHAR(120) NOT NULL,
  `setting_value` LONGTEXT NULL,
  `is_secret` TINYINT(1) NOT NULL DEFAULT 0,
  `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_setting` (`group_name`, `setting_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `{{prefix}}settings` (`group_name`, `setting_key`, `setting_value`, `is_secret`, `created_at`, `updated_at`) VALUES
('system','application_version','0.5.9.8.71.2',0,NOW(),NOW()),
('system','settings_table_repair_ready','1',0,NOW(),NOW()),
('system','long_list_compact_audit_ready','1',0,NOW(),NOW()),
('system','page_long_line_guard_ready','1',0,NOW(),NOW()),
('system','update_chain_reconciliation_0712_ready','1',0,NOW(),NOW()),
('system','latest_update_apply_chain_ready','1',0,NOW(),NOW()),
('system','updates_database_status_reconciled','1',0,NOW(),NOW())
ON DUPLICATE KEY UPDATE `setting_value`=VALUES(`setting_value`), `updated_at`=NOW();
