Added migration file
This commit is contained in:
@@ -12,6 +12,8 @@ use Medoo\Medoo;
|
||||
use App\Controllers\PostController;
|
||||
use App\Repositories\PostRepository;
|
||||
use App\Services\HtmlSanitizer;
|
||||
use App\Services\HtmlPurifierFactory;
|
||||
use App\Database\Migration;
|
||||
use App\Routes;
|
||||
use App\Config;
|
||||
|
||||
@@ -46,20 +48,15 @@ $db = new Medoo([
|
||||
'database' => $dbFile,
|
||||
]);
|
||||
|
||||
// Créer la table si elle n'existe pas
|
||||
$db->pdo->exec("
|
||||
CREATE TABLE IF NOT EXISTS post (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
title TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
slug TEXT UNIQUE NOT NULL DEFAULT '',
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
");
|
||||
// Exécuter les migrations
|
||||
Migration::run($db);
|
||||
|
||||
// HtmlSanitizer
|
||||
$htmlSanitizer = new HtmlSanitizer();
|
||||
// HtmlPurifier (créé via la factory)
|
||||
$htmlPurifierCacheDir = __DIR__ . '/../var/cache/htmlpurifier';
|
||||
$htmlPurifier = HtmlPurifierFactory::create($htmlPurifierCacheDir);
|
||||
|
||||
// HtmlSanitizer (reçoit HTMLPurifier injecté)
|
||||
$htmlSanitizer = new HtmlSanitizer($htmlPurifier);
|
||||
|
||||
// PostRepository
|
||||
$postRepository = new PostRepository($db);
|
||||
|
||||
Reference in New Issue
Block a user