diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/migrate | 10 | ||||
| -rwxr-xr-x | bin/newmigration | 22 |
2 files changed, 32 insertions, 0 deletions
diff --git a/bin/migrate b/bin/migrate new file mode 100755 index 0000000..29d2001 --- /dev/null +++ b/bin/migrate @@ -0,0 +1,10 @@ +#!/usr/bin/env php +<?php + +require __DIR__ . '/../vendor/autoload.php'; + +foreach (glob(__DIR__ . '/../migrations/*.php') as $file) { + require $file; +} + +\WpfTest\Db\Migrator::getInstance()->migrate();
\ No newline at end of file diff --git a/bin/newmigration b/bin/newmigration new file mode 100755 index 0000000..9417726 --- /dev/null +++ b/bin/newmigration @@ -0,0 +1,22 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo 'usage: bin/newmigration <name>' + exit 1 +fi + +cd "$(dirname "$0")" || exit 2 +cd ../migrations || exit 2 + +version="$(date +'%Y%m%d_%H%M%S')" +migratorFullClassName="$(find .. -name Migrator.php | sed 's_/_\\_g;s/^\.*//;s/\.php$//')" + +cat > "${version}_$1.php" << EOT +<?php + +use $migratorFullClassName; + +Migrator::getInstance()->register($version, function (PDO \$db) { + // your code here +}); +EOT |
