]> git.andy128k.dev Git - ipf.git/commitdiff
migrations
authorAndrey Kutejko <andy128k@gmail.com>
Fri, 1 Aug 2014 20:13:44 +0000 (23:13 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Fri, 1 Aug 2014 20:13:44 +0000 (23:13 +0300)
composer.json
ipf/cli.php
ipf/command/createmigration.php [new file with mode: 0644]
ipf/command/migrate.php [new file with mode: 0644]

index ca6f24246e10f5838cf15c38a6378ee4dc7f6324..21b91603ec956285335f7859013cab5e255b465d 100644 (file)
@@ -19,6 +19,7 @@
     "pear/archive_tar": "1.3.*",
     "mustangostang/spyc": "0.5.*",
     "andy128k/missing-tools": "0.2.*@dev",
+    "andy128k/migrations": "dev-master",
     "andy128k/pegp": "0.1.*@dev",
     "andy128k/routeexpression": "dev-master",
     "andy128k/ipf-template": "dev-master"
index dfecfba13c42542cc03f07556a7c895c8aa4543a..1f52c1c9116edb215ddc34a08e514df7852215e6 100644 (file)
@@ -21,6 +21,8 @@ class IPF_Cli
             new IPF_Command_Pack,
             new IPF_Command_Unpack,
             new IPF_Command_CreateSuperUser,
+            new IPF_Command_CreateMigration,
+            new IPF_Command_Migrate,
             new IPF_Command_SyncPerms,
         );
         
diff --git a/ipf/command/createmigration.php b/ipf/command/createmigration.php
new file mode 100644 (file)
index 0000000..adca2d9
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+
+class IPF_Command_CreateMigration
+{
+    public $command = 'createmigration';
+    public $description = 'Create migration';
+
+    public function run($args=null)
+    {
+        $m = new \PFF\Migrations\Migrations;
+        $filename = $m->createMigration(IPF::get('project_path').'/db/migrations', implode('_', $args));
+        echo "Create new migration $filename\n";
+    }
+}
+
diff --git a/ipf/command/migrate.php b/ipf/command/migrate.php
new file mode 100644 (file)
index 0000000..10c9264
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+
+class IPF_Command_Migrate
+{
+    public $command = 'migrate';
+    public $description = 'Migrate DB schema';
+
+    public function run($args=null)
+    {
+        $connection = IPF_ORM_Manager::getInstance()->getCurrentConnection()->getDbh();
+        $m = new \PFF\Migrations\Migrations;
+        $m->migrate($connection, IPF::get('project_path').'/db/migrations');
+    }
+}
+