Add SQL schema, CLI commands, and initialization logic
This commit is contained in:
parent
bc6e814c42
commit
ff1363c63f
12 changed files with 327 additions and 1 deletions
36
src/Socialbox/Enums/DatabaseObjects.php
Normal file
36
src/Socialbox/Enums/DatabaseObjects.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Enums;
|
||||
|
||||
enum DatabaseObjects : string
|
||||
{
|
||||
case PASSWORD_AUTHENTICATION = 'password_authentication.sql';
|
||||
case REGISTERED_PEERS = 'registered_peers.sql';
|
||||
case SESSIONS = 'sessions.sql';
|
||||
|
||||
/**
|
||||
* Returns the priority of the database object
|
||||
*
|
||||
* @return int The priority of the database object
|
||||
*/
|
||||
public function getPriority(): int
|
||||
{
|
||||
return match ($this)
|
||||
{
|
||||
self::REGISTERED_PEERS => 1,
|
||||
self::PASSWORD_AUTHENTICATION, self::SESSIONS => 2,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of cases ordered by their priority.
|
||||
*
|
||||
* @return array The array of cases sorted by their priority.
|
||||
*/
|
||||
public static function casesOrdered(): array
|
||||
{
|
||||
$cases = self::cases();
|
||||
usort($cases, fn($a, $b) => $a->getPriority() <=> $b->getPriority());
|
||||
return $cases;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue