Fixes log plugin
parent
1f3d331b25
commit
fa3e75f722
|
@ -0,0 +1,14 @@
|
|||
-- --------------------------------------------------------
|
||||
-- Logger Plugin: Create `log` table if it does not exist
|
||||
-- --------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `log` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` INT(11) NOT NULL,
|
||||
`time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`level` VARCHAR(10) NOT NULL DEFAULT 'info',
|
||||
`scope` set('user','system') NOT NULL,
|
||||
`message` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `user_id` (`user_id`),
|
||||
CONSTRAINT `log_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
|
|
@ -15,11 +15,11 @@ class LoggerFactory
|
|||
{
|
||||
// Auto-migration: ensure log table exists
|
||||
$pdo = $db->getConnection();
|
||||
// $migrationFile = __DIR__ . '/../migrations/create_log_table.sql';
|
||||
// if (file_exists($migrationFile)) {
|
||||
// $sql = file_get_contents($migrationFile);
|
||||
// $pdo->exec($sql);
|
||||
// }
|
||||
$migrationFile = __DIR__ . '/../migrations/create_log_table.sql';
|
||||
if (file_exists($migrationFile)) {
|
||||
$sql = file_get_contents($migrationFile);
|
||||
$pdo->exec($sql);
|
||||
}
|
||||
|
||||
// Load models and core IP helper
|
||||
require_once __DIR__ . '/Log.php';
|
||||
|
|
Loading…
Reference in New Issue