Less home code more F3
This commit is contained in:
@@ -7,14 +7,18 @@ class Post extends DB\SQL\Mapper
|
||||
public const TITLE_MAX_LENGTH = 120;
|
||||
public const EXCERPT_MAX_LENGTH = 240;
|
||||
|
||||
public function __construct(DB\SQL $db)
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($db, 'posts');
|
||||
parent::__construct(Base::instance()->get('DB'), 'posts');
|
||||
}
|
||||
|
||||
public static function bootstrap(DB\SQL $db): void
|
||||
{
|
||||
$db->exec('CREATE TABLE IF NOT EXISTS posts (
|
||||
if ($db->schema('posts', null, 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db->exec('CREATE TABLE posts (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
title TEXT NOT NULL,
|
||||
slug TEXT NOT NULL UNIQUE,
|
||||
@@ -26,7 +30,7 @@ class Post extends DB\SQL\Mapper
|
||||
updated_at TEXT NOT NULL,
|
||||
FOREIGN KEY (cover_media_id) REFERENCES media(id) ON DELETE SET NULL
|
||||
)');
|
||||
$db->exec('CREATE INDEX IF NOT EXISTS idx_posts_created_at ON posts(created_at DESC)');
|
||||
$db->exec('CREATE INDEX idx_posts_created_at ON posts(created_at DESC)');
|
||||
}
|
||||
|
||||
public static function emptyForm(): array
|
||||
|
||||
Reference in New Issue
Block a user