LoginSignup
2
4

More than 5 years have passed since last update.

Fuelphpのmigrationでmysqlのafterを指定した結果

Last updated at Posted at 2016-09-21

fuelphpのoilコマンドでmysqlのafterを指摘できるみたいだった。
http://saihoooooooo.hatenablog.com/entry/2014/02/06/204806

$ php oil g migration add_tablename pref:int\[4]:after\[country], city:varchar\[255]:after\[pref]

やってみた結果できたmigrateファイル

<?php

namespace Fuel\Migrations;

class Add_tablename
{
    public function up()
    {
        \DBUtil::add_fields('', array(
            'pref' => array('constraint' => 4, 'type' => 'int', 'after' => 'country'),
            'city' => array('constraint' => 255, 'type' => 'varchar', 'after' => 'pref'),

        ));
    }

    public function down()
    {
        \DBUtil::drop_fields('', array(
            'pref',
            'city'

        ));
    }
}

このままoil r migrateするとテーブル名が空だよっておこられるのでそこは入れてからする。

2
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4