Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Oil Migrations questions
  • I've used the following to create the database table users and all the nice fluff that comes with the scaffolding:
    php oil g scaffold user first_name:string last_name:string password:string email:string
    

    But, I want to add another field to the users table. According to the docs on migrations via oil there are some functions to modify migrations;
    php oil g migration add_add1_to_users add1:string
    

    Should update the table when I run php oil r migrate but it doesn't. It creates a blank migration class with a blank up and down. Have I mis-understood the functions or is there a bug?
  • I'm not at home so I don't have access to my more complete code, but here's the approach I went for. https://gist.github.com/9b579608422e7442e3d9 I had to do it in three parts... Oil - classes/generate/migrations/actions.php... Add in the new info. I also extracted the field formatting from the create method to be used elsewhere. Core - classes/DBUtil.php Had to add classes to work with the columns, I still have to make sure every supported database works, this is for MySQL only ATM. Oil - classes/generate.php Added the add_field_to_table & rename_field_to_newfield_on_table -- Again, I've done more work to this... I just whipped this up at work when I had my ideas. But, I don't want to go through all the trouble of testing and getting it to 100% without knowing if it's the approach you would have approved of, or if there are consequences that I can't foresee.
  • Magic Migrations are currently only supported for create and drop. The reason for this was a limitation in the DBUtil class which did not allow us to add/drop/rename tables, etc. These methods have been added to DBUtil in the develop branch so theoretically they can be added now/soon, but with us meant to be in a feature freeze I'd not recommend it. If somebody is willing to do it in a branch and send a pull request then WAHOO, head to Oil\Generate_Migration_Actions and implement away, all the methods are there, implemented and ready to go, they just need the logic to be put in.
  • That's cool. Thanks for clearing it up guys. :) I'll have a fiddle. Can't wait to see what comes of the framework!
  • I'll try my hand tonight.
  • You're heading along the correct lines yes. Make sure you are working out of develop as changes have been made to magic methods recently. Working out of master = potential duplicated effort.
  • I'm not 100% sure the magic migrations are working at the moment. I haven't gone through the source yet because it hasn't been that important to me... but it has yet to work for me...

Howdy, Stranger!

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

In this Discussion