Files
2026-09-11 18:06:17 +07:00

52 lines
1.3 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* One-way legacy database cutover utility.
*
* This controller is deliberately CLI-only. Credentials are read from the
* environment and are never stored in the application source.
*/
class Databasesync extends CI_Controller
{
public function __construct()
{
parent::__construct();
if (!$this->input->is_cli_request()) {
show_error('Database sync hanya dapat dijalankan melalui CLI.', 403, 'Akses ditolak');
}
if (!filter_var(app_env('DBSYNC_ENABLED', 'false'), FILTER_VALIDATE_BOOLEAN)) {
fwrite(STDERR, "DBSYNC_ENABLED belum diaktifkan.\n");
exit(2);
}
$this->load->library('DatabaseSyncService');
}
public function check()
{
$this->render($this->databasesyncservice->check());
}
public function snapshot()
{
$this->render($this->databasesyncservice->snapshot());
}
public function bootstrap()
{
$this->render($this->databasesyncservice->bootstrap());
}
public function verify()
{
$this->render($this->databasesyncservice->verify());
}
private function render($result)
{
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL;
}
}