Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
oil generate migration rename_field not working
  • $ oil g migration rename_field_bio_to_biography_in_tests $ oil r migrate
    1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`biography` text NOT NULL' at line 2 [ ALTER TABLE `sw_tests`
    MODIFY `bio` `biography` text NOT NULL ] in COREPATH/classes/database/mysql/connection.php on line 210 In MySQL, we must use CHANGE instead of MODIFY when renaming column name. Workaround: --- a/fuel/core/classes/dbutil.php
    +++ b/fuel/core/classes/dbutil.php
    @@ -120,7 +120,19 @@ class DBUtil
    */
    public static function modify_fields($table, $fields)
    {
    - return static::alter_fields('MODIFY', $table, $fields);
    + $type = 'MODIFY';
    + foreach ($fields as $field => $definitions)
    + {
    + foreach ($definitions as $key => $val)
    + {
    + if ($key === 'name')
    + {
    + $type = 'CHANGE';
    + }
    + }
    + }
    +
    + return static::alter_fields($type, $table, $fields);
    } /**
    I looked for tests for dbutil, but I couldn't find tests.
    How can I write tests for it?

Howdy, Stranger!

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