{"id":435,"date":"2007-12-16T01:28:49","date_gmt":"2007-12-15T16:28:49","guid":{"rendered":"http:\/\/ecpplus.net\/weblog\/?p=435"},"modified":"2020-06-26T02:21:37","modified_gmt":"2020-06-25T17:21:37","slug":"akelos%e3%81%aemigration","status":"publish","type":"post","link":"https:\/\/ecpplus.net\/weblog\/akelos%e3%81%aemigration\/","title":{"rendered":"Akelos\u306emigration"},"content":{"rendered":"<p>PHP \u306e Rails\u30b3\u30d4\u30fc\u306eAkelos\u3092\u89e6\u3063\u3066\u308b\u3002\u307e\u3060Versin0.8\u3060\u3051\u3069\u3001\u826f\u3055\u305d\u3046\u306a\u306e\u3067\u4f7f\u3063\u3066\u307f\u305f\u3044\u3002CakePHP\u306fRails\u30b3\u30d4\u30fc\u304b\u3068\u601d\u3063\u305f\u3089\u5168\u7136\u9055\u3063\u305f\u306e\u3067\u4f7f\u3046\u306e\u3084\u3081\u305f\u3002<\/p>\n<h3>migration<\/h3>\n<pre>$ php script\/generate model Book<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3001Book\u30e2\u30c7\u30eb\u304c\u4f5c\u3089\u308c\u308b\u3002\u305d\u3046\u3059\u308b\u3068\u3001migrate\u30d5\u30a1\u30a4\u30eb\u306b\u3042\u305f\u308b\u3082\u306e\u304c app\/installers\/book_installesr.php \u306b\u51fa\u6765\u308b\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u3060\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5f62\u306b\u306a\u3063\u3066\u3001\u30d0\u30fc\u30b8\u30e7\u30f3UP\u3068DOWN\u306b\u5bfe\u5fdc\u3057\u305f\u51e6\u7406\u3092\u66f8\u304f\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n<pre lang=\"php-brief\">< ?php\nclass DrinkInstaller extends AkInstaller\n{\n    function up_1()\n    {\n        $this->createTable('drinks', \"\n          id,\n          name\n        \");\n    }\n\n    function down_1()\n    {\n        $this->dropTable('drinks');\n    }\n}\n?>\n<\/pre>\n<p>createTable\u306e\u7b2c\u4e00\u5f15\u6570\u304c\u30c6\u30fc\u30d6\u30eb\u540d\u3001\u7b2c\u4e8c\u5f15\u6570\u304c\u30c6\u30fc\u30d6\u30eb\u306e\u4e2d\u8eab\u306b\u306a\u308b\u3002\u7b2c\u4e8c\u5f15\u6570\u306f\u3001\u30ab\u30f3\u30de\u3067\u30ab\u30e9\u30e0\u540d\u3092\u533a\u5207\u3063\u3066\u3044\u304f\u3002\u578b\u3092\u6307\u5b9a\u3057\u306a\u3044\u3068\u3001\u81ea\u52d5\u7684\u306b\u6700\u9069\u306a\u578b\u306b\u3057\u3066\u304f\u308c\u308b\u3068\u3044\u3046\u3053\u3068\u3060\u304c\u3001\u602a\u3057\u3044\u306e\u3067\u6307\u5b9a\u3057\u305f\u307b\u3046\u304c\u826f\u3055\u305d\u3046\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304f\u3002<\/p>\n<pre lang=\"php\">        $this->createTable('drinks', \"\n          id,\n          name varchar(255),\n          descrption text,\n          isbn varchar(20) not null\n        \");\n<\/pre>\n<p>\u3053\u308c\u3092DB\u306b\u53cd\u6620\u3055\u305b\u308b\u306b\u306f script\/migrate book install \u3068\u66f8\u304f\u3002install \u3092\u3084\u308b\u3068 up \u304c\u9806\u306b\u5b9f\u884c\u3055\u308c\u3001 uninstall \u3092\u5b9f\u884c\u3059\u308b\u3068 down \u304c\u5b9f\u884c\u3055\u308c\u308b\u3002<\/p>\n<pre>chu@chu-mac:~\/Sites\/sample$ php script\/migrate book install\nUpgrading-----\n(mysqlt): SET AUTOCOMMIT=0\n-----\n-----\n(mysqlt): BEGIN\n-----\n-----\n(mysqlt): SHOW COLUMNS FROM books\n-----\n1146: Table 'sample_dev.books' doesn't exist\nADOConnection._Execute(SHOW COLUMNS FROM books, false)% line  854, file: \/Users\/chu\/Sites\/akelos\/vendor\/adodb\/adodb.inc.php\nADOConnection.Execute(SHOW COLUMNS FROM books)% line  393, file: \/Users\/chu\/Sites\/akelos\/vendor\/adodb\/drivers\/adodb-mysql.inc.php\nADODB_mysql.MetaColumns(books, true, false)% line  202, file: \/Users\/chu\/Sites\/akelos\/vendor\/adodb\/adodb-datadict.inc.php\nADODB_DataDict.MetaColumns(books)% line  723, file: \/Users\/chu\/Sites\/akelos\/vendor\/adodb\/adodb-datadict.inc.php\nADODB_DataDict.ChangeTableSQL(books, id I NOTNULL AUTO KEY,\nname varchar(255),\ndesctipntion XL,\nisbn varchar(20) NOTNULL,\nupdated_at T,\ncreated_at T, Array[1])% line  279, file: \/Users\/chu\/Sites\/akelos\/lib\/AkInstaller.php\n-----\n(mysqlt): CREATE TABLE books (\nid                       INTEGER NOT NULL AUTO_INCREMENT,\nname                     VARCHAR(255),\ndesctipntion             LONGTEXT,\nisbn                     VARCHAR(20) NOT NULL,\nupdated_at               DATETIME,\ncreated_at               DATETIME,\n                 PRIMARY KEY (id)\n)TYPE=InnoDB\n-----\n-----\n(mysqlt): COMMIT\n-----\n-----\n(mysqlt): SET AUTOCOMMIT=1\n-----\nSmart Commit occurred<\/pre>\n<p>\u9014\u4e2d\u306b\u30a8\u30e9\u30fc\u3063\u307d\u3044\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u3042\u308b\u304c\u3001\u516c\u5f0f\u306eScreenshot\u898b\u3066\u3082\u3053\u308c\u304c\u6b63\u5e38\u306a\u52d5\u4f5c\u306e\u3088\u3046\u3060\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u3044\u3066\u304a\u304f\u3068 migration \u3092 uninstall \u3057\u305f\u6642\u306bbooks\u30c6\u30fc\u30d6\u30eb\u304cdrop\u3055\u308c\u307e\u3059\u3002Rails\u3060\u3068\u3001\u30c7\u30d5\u30a9\u3058\u3083\u30c6\u30fc\u30d6\u30eb\u3084\u30d0\u30fc\u30b8\u30e7\u30f3\u5225\u306emigration\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u306a\u3044\u304b\u3089\u3053\u308c\u306f\u7d50\u69cb\u4fbf\u5229\u304b\u3082\u3002\u305f\u3060\u3001\u307f\u3093\u306a\u3067\u5225\u3005\u306b\u3084\u3063\u3066\u305f\u3089\u3069\u3046\u306a\u308b\u306e\u304b\u3002\u5168\u90e8\u4e00\u6c17\u306b\u3084\u308b\u65b9\u6cd5\u304c\u307e\u3060\u308f\u304b\u3089\u306a\u3044\u3002\u540c\u3058\u30d5\u30a1\u30a4\u30eb\u306b\u5168\u90e8\u66f8\u3044\u3066\u304a\u3051\u3070\u554f\u984c\u306f\u306a\u3044\u3068\u601d\u3046\u3051\u3069\u3001\u8981\u8abf\u67fb\u3002<\/p>\n<pre lang=\"php\">    function down_1()\n    {\n        $this->dropTable('books');\n    }<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u306e Rails\u30b3\u30d4\u30fc\u306eAkelos\u3092\u89e6\u3063\u3066\u308b\u3002\u307e\u3060Versin0.8\u3060\u3051\u3069\u3001\u826f\u3055\u305d\u3046\u306a\u306e\u3067\u4f7f\u3063\u3066\u307f\u305f\u3044\u3002CakePHP\u306fRails\u30b3\u30d4\u30fc\u304b\u3068\u601d\u3063\u305f\u3089\u5168\u7136\u9055\u3063\u305f\u306e\u3067\u4f7f\u3046\u306e\u3084\u3081\u305f\u3002 migration $ php s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2903,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[17],"class_list":["post-435","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","tag-php"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/comments?post=435"}],"version-history":[{"count":2,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/435\/revisions"}],"predecessor-version":[{"id":2909,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/435\/revisions\/2909"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media\/2903"}],"wp:attachment":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media?parent=435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/categories?post=435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/tags?post=435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}