Skip to content

Commit db929a7

Browse files
author
Greg Bowler
authored
Upgrade to CLI (#238)
* build: update dependencies * build: upgrade deps * wip: extract migration into cli command * wip: rename bin script * wip: refactor execture command * feature: integrate migrator class * refactor: remove obsolete functionality * feature: improve exceptions
1 parent a789d6e commit db929a7

10 files changed

Lines changed: 372 additions & 185 deletions

File tree

bin/db-migrate

Lines changed: 0 additions & 81 deletions
This file was deleted.

bin/migrate

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env php
2+
<?php
3+
/**
4+
* Database migration iterates over a set of incremental schema changes and
5+
* stores the currently-migrated schema version within the database itself.
6+
*/
7+
8+
use Gt\Cli\Application;
9+
use Gt\Cli\Argument\CommandArgumentList;
10+
use Gt\Database\Cli\ExecuteCommand;
11+
12+
// The script must be run from the context of a project's root directory.
13+
foreach([ __DIR__ . "/../../..", __DIR__ . "/../vendor" ] as $vendor) {
14+
$autoload = "$vendor/autoload.php";
15+
if(file_exists($autoload)) {
16+
require($autoload);
17+
break;
18+
}
19+
}
20+
21+
$app = new Application(
22+
"Migrate the database",
23+
new CommandArgumentList("execute", ...$argv),
24+
new ExecuteCommand(),
25+
);
26+
$app->run();

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
"require": {
77
"php": ">=7.4",
88
"ext-PDO": "*",
9-
"phpgt/config": "^v1.1.0"
9+
"phpgt/config": "^v1.1.0",
10+
"phpgt/cli": "^1.3"
1011
},
1112

1213
"require-dev": {
13-
"phpunit/phpunit": "^9.4.0",
14-
"phpstan/phpstan": "^0.12.42",
14+
"phpunit/phpunit": "^9.4",
15+
"phpstan/phpstan": "^0.12",
1516
"ext-sqlite3": "*"
1617
},
1718

@@ -45,7 +46,7 @@
4546
},
4647

4748
"bin": [
48-
"bin/db-migrate"
49+
"bin/migrate"
4950
],
5051

5152
"funding": [

0 commit comments

Comments
 (0)