-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrations.php
More file actions
36 lines (29 loc) · 803 Bytes
/
Copy pathmigrations.php
File metadata and controls
36 lines (29 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
use app\core\Application;
use app\core\Config;
use app\core\Container;
use app\core\Database;
use app\core\facades\DB;
use Dotenv\Dotenv;
require_once __DIR__ . "/vendor/autoload.php";
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
Config::load(__DIR__ . "/config");
$app = new Application(rootPath: __DIR__);
Container::singleton('db', function () {
return new Database();
});
$command = $argv[1] ?? null;
switch ($command) {
case 'migrate':
DB::applyMigrations();
break;
case 'rollback':
DB::rollbackMigrations();
break;
default:
echo "Available commands: \n";
echo " php migrations.php migrate # Apply migrations\n";
echo " php migrations.php rollback # Rollback last batch\n";
break;
}