Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Migrations - re-structuring table
  • Hiya! I've added a model with some fields. However I forgot some fields and want to add them using a migration. Thus, I've generated a migration (php oil g migration). However I'm unable to find a function (in DBUtil) which can add a field to my table. Anything I'm missing? I don't want to drop and create the table (and lose all of my data) just for re-structuring. Thanks!
  • I get blank methods in the generated file when following the instructions for running oil from the command line - but they should look something like this: <?php namespace Fuel\Migrations; class Add_status_to_project { public function up()
    {
    \DB::query('ALTER TABLE `projects` ADD `status` VARCHAR( 25 );')->execute();
    } public function down()
    {
    \DB::query('ALTER TABLE `projects` DROP `status`')->execute();
    }
    }
  • Right you are. I was actually unpleasantly surprised yesterday to discover that DBUtil does not actually have any functionality to add fields to a table. I'm pretty sure this is not me missing it, but its nowhere I could find. When the add_fields methods are added I will make sure that the magic migration - mentioned (brilliant username, but I'll have to validate against that) works.
  • That would be great. Thanks.
  • $ php oil generate migration add_sth_to_table sth:text
    
    hope it helps :P
  • Thanks for your reply. However this just generated an empty migration file for me?
  • What am I supposed to put in the migration file? I can't find anything in DBUtil.

Howdy, Stranger!

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

In this Discussion