]> git.andy128k.dev Git - migrations.git/commitdiff
add example queries to template
authorAndrey Kutejko <aku@anahoret.com>
Tue, 20 Jan 2015 14:43:26 +0000 (16:43 +0200)
committerAndrey Kutejko <aku@anahoret.com>
Tue, 20 Jan 2015 14:43:26 +0000 (16:43 +0200)
src/migrations.php
src/template [new file with mode: 0644]

index cf75a8971666d73dee419ec846f0014e9d5d00a0..94baff68eb60bb9de8bfab24abae3bdab265ad01 100644 (file)
@@ -54,7 +54,9 @@ class Migrations
 
         $filename = $path.'/'.$ts.$name.'.php';
 
-        file_put_contents($filename, "<?php\n\nclass Migration_$ts extends \PFF\Migrations\Migration\n{\n    function migrate()\n    {\n    }\n}\n\n");
+        $template = file_get_contents(dirname(__FILE__) . '/template');
+        $content = str_replace('%TS%', $ts, $template);
+        file_put_contents($filename, $content);
 
         return $filename;
     }
diff --git a/src/template b/src/template
new file mode 100644 (file)
index 0000000..8ce16eb
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+class Migration_%TS% extends \PFF\Migrations\Migration
+{
+    function migrate()
+    {
+        // $data = $this->query('SELECT * FROM table WHERE param = ?', array('value'));
+        // $this->connection->exec('CREATE TABLE table (id BIGINT AUTO_INCREMENT, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
+    }
+}
+