aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/newmigration
diff options
context:
space:
mode:
authorwinter2024-12-07 21:44:42 +0000
committerwinter2024-12-07 21:44:42 +0000
commita84232811dadccf7047424f27340a7f9847bedff (patch)
treea6a0823c8b9485b6a5b60ea7ae854f9511a6ae1e /bin/newmigration
parente1ad307b531c27ec6bfaf8b4d018991b0d4a78f3 (diff)
many many changes but actors are loaded from db now
Diffstat (limited to 'bin/newmigration')
-rwxr-xr-xbin/newmigration22
1 files changed, 22 insertions, 0 deletions
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