Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
oil migrate problem Error - SQLSTATE[42S21]: Column already exists:
  • I added a field to my table using this oil command:
    php oil generate migration add_bio_to_accounts bio:text

    . now i want to add another field to the  same table and I keep getting the following error:

    Error - SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name ...

    I dont understand why it keeps going back to the previous migration and not the new one?
  • Have a look at the migration file generated, what does it contain?
  • Thanks for getting back to me. Below is whats in the last migration that ran successfully and the one that is producing the error.


    namespace Fuel\Migrations;

    class Add_slug_to_posts
    {
    public function up()
    {
    \DBUtil::add_fields('posts', array(
    'slug' => array('constraint' => 255, 'type' => 'varchar'),

    ));
    }

    public function down()
    {
    \DBUtil::drop_fields('posts', array(
    'slug'

    ));
    }
    }

    amespace Fuel\Migrations;

    class Add_summary_to_posts
    {
    public function up()
    {
    \DBUtil::add_fields('posts', array(
    'slug' => array('type' => 'text'),

    ));
    }

    public function down()
    {
    \DBUtil::drop_fields('posts', array(
    'slug'

    ));
    }
    }

  • These two migration files add the same column ('slug'), so it's logical you get this database error?

    Both don't match the oil command you gave earlier btw...

Howdy, Stranger!

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

In this Discussion