- Created separate MoneyFlix project directory - Copied Node.js redirector from production server - Added CRM PHP code (Redirects module, Core classes, Config, Routes, Views) - Created comprehensive documentation (README_MONEYFLIX.md) - Added sync script to keep CRM code updated (sync-from-crm.sh) - Configured .gitignore for Node.js and PHP - Set up proper project structure for multi-client isolation This separates MoneyFlix from the main CRM to avoid confusion between different client systems and provides a dedicated environment for MoneyFlix-specific development and maintenance.
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Core\Database;
|
|
|
|
use App\Core\Database;
|
|
use App\Core\Logger;
|
|
use Closure;
|
|
|
|
class SchemaManager
|
|
{
|
|
private Database $db;
|
|
private Logger $logger;
|
|
|
|
public function __construct(Database $db, Logger $logger)
|
|
{
|
|
$this->db = $db;
|
|
$this->logger = $logger;
|
|
}
|
|
|
|
public function create(string $tableName, Closure $callback): void
|
|
{
|
|
$builder = new SchemaBuilder($tableName);
|
|
$callback($builder);
|
|
$sql = $builder->getSql();
|
|
|
|
try {
|
|
$this->db->execute($sql);
|
|
$this->logger->info("Tabela {$tableName} criada com sucesso", ['table' => $tableName]);
|
|
} catch (\Exception $e) {
|
|
$this->logger->error("Erro ao criar tabela {$tableName}", ['error' => $e->getMessage(), 'sql' => $sql]);
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
public function dropIfExists(string $tableName): void
|
|
{
|
|
$sql = "DROP TABLE IF EXISTS `{$tableName}`;";
|
|
|
|
try {
|
|
$this->db->execute($sql);
|
|
$this->logger->info("Tabela {$tableName} eliminada com sucesso", ['table' => $tableName]);
|
|
} catch (\Exception $e) {
|
|
$this->logger->error("Erro ao eliminar tabela {$tableName}", ['error' => $e->getMessage()]);
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|