Skip to content

Commit

Permalink
Upgrade to CLI (#238)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
g105b authored Sep 23, 2021
1 parent a789d6e commit db929a7
Show file tree
Hide file tree
Showing 10 changed files with 372 additions and 185 deletions.
81 changes: 0 additions & 81 deletions bin/db-migrate

This file was deleted.

26 changes: 26 additions & 0 deletions bin/migrate
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env php
<?php
/**
* Database migration iterates over a set of incremental schema changes and
* stores the currently-migrated schema version within the database itself.
*/

use Gt\Cli\Application;
use Gt\Cli\Argument\CommandArgumentList;
use Gt\Database\Cli\ExecuteCommand;

// The script must be run from the context of a project's root directory.
foreach([ __DIR__ . "/../../..", __DIR__ . "/../vendor" ] as $vendor) {
$autoload = "$vendor/autoload.php";
if(file_exists($autoload)) {
require($autoload);
break;
}
}

$app = new Application(
"Migrate the database",
new CommandArgumentList("execute", ...$argv),
new ExecuteCommand(),
);
$app->run();
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"require": {
"php": ">=7.4",
"ext-PDO": "*",
"phpgt/config": "^v1.1.0"
"phpgt/config": "^v1.1.0",
"phpgt/cli": "^1.3"
},

"require-dev": {
"phpunit/phpunit": "^9.4.0",
"phpstan/phpstan": "^0.12.42",
"phpunit/phpunit": "^9.4",
"phpstan/phpstan": "^0.12",
"ext-sqlite3": "*"
},

Expand Down Expand Up @@ -45,7 +46,7 @@
},

"bin": [
"bin/db-migrate"
"bin/migrate"
],

"funding": [
Expand Down
Loading

0 comments on commit db929a7

Please sign in to comment.