Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to change data type and remove column in fuelphp
  • I create shops table.
    Now I want to change varchar to text and remove column remarks from shops table.How can I migrate this in fuelphp. Please answer me!
    Old migration file: 004_create_shops.php
    <?php

    namespace Fuel\Migrations;

    class Create_shops
    {
    public function up()
    {
    \DBUtil::create_table('shops', array(
    'id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true, 'unsigned' => true),
    'name' => array('constraint' => 100, 'type' => 'varchar'),
    'prefecture_id' => array('constraint' => 11, 'type' => 'int'),
    'address' => array('constraint' => 300, 'type' => 'varchar'),
    'tel' => array('constraint' => 20, 'type' => 'varchar'),
    'file_id' => array('constraint' => 11, 'type' => 'int'),
    'detail' => array('type' => 'text'),
    'remarks' => array('constraint' => 200, 'type' => 'varchar'),
    'average_rate' => array('constraint' => '13,1', 'type' => 'decimal'),
    'editor_id' => array('constraint' => 11, 'type' => 'int'),
    'opening_hour' => array('constraint' => 100, 'type' => 'varchar'),
    'fee' => array('constraint' => 100, 'type' => 'varchar'),
    'url' => array('constraint' => 100, 'type' => 'varchar'),
    'pickup_flag' => array('constraint' => 4, 'type' => 'tinyint'),
    'national_pickup_flag' => array('constraint' => 4, 'type' => 'tinyint'),
    'event_title' => array('constraint' => 100, 'type' => 'varchar'),
    'event' => array('constraint' => 500, 'type' => 'varchar'),
    'category_id' => array('constraint' => 11, 'type' => 'int'),
    'category_id2' => array('constraint' => 11, 'type' => 'int'),
    'delete_flag' => array('constraint' => 4, 'type' => 'tinyint'),
    'rating_count' => array('constraint' => 11, 'type' => 'int', 'default' => 0),
    'pickup_sort_order' => array('constraint' => 11, 'type' => 'int', 'default' => 0),
    'national_pickup_sort_order' => array('constraint' => 11, 'type' => 'int', 'default' => 0),
    'create_userid' => array('constraint' => 11, 'type' => 'int'),
    'update_userid' => array('constraint' => 11, 'type' => 'int'),
    'created_at' => array('type' => 'datetime', 'null' => false),
    'updated_at' => array('type' => 'datetime', 'null' => false),

    ), array('id'));
    }

    public function down()
    {
    \DBUtil::drop_table('shops');
    }
    }



  • nassermannasserman
    Accepted Answer
    $ php oil generate migration create_users name:text email:string[50] password:string[125]
    $ php oil generate migration rename_table_users_to_accounts
    $ php oil generate migration add_bio_to_accounts bio:text
    $ php oil generate migration delete_bio_from_accounts bio:text
    $ php oil generate migration rename_field_name_to_username_in_accounts
    $ php oil generate migration drop_accounts
    <br><br>fuel_docs/packages/oil/generate.html#models<br>
  • HarroHarro
    Accepted Answer
    Or just code the migration by hand, once you have a few I find it easier to copy and change it than use oil magic, but I prefer to know exactly what is happening...
  • I got it. Thanks :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion