Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Oil generate models with wrong migration name
  • You can see the problem in the code, look at the model names and migration file names. For some kind a reason second migration name is not the same as models name.


    D:\xampp\htdocs\ld>php oil g model api_users_actions user_id:int action:enum[getprojects,getvotes,getcomments,vote,comment,getmessages,getsettings] sc
    heduling:enum[each_Y,each_m,each_d,each_H,each_i,each_s,unlimited] enabled:int[1]
    Creating model: D:\xampp\htdocs\ld\fuel\app\classes\model\api\users\action.php
    Creating migration: D:\xampp\htdocs\ld\fuel\app\migrations/045_create_api_users_actions.php

    D:\xampp\htdocs\ld>php oil g model api_users ip:text name:varchar[255] prefix:varchar[20] api_key:varchar[50] api_secret:varchar[50] enabled:int[1] bl
    ocked:int[1]
    Creating model: D:\xampp\htdocs\ld\fuel\app\classes\model\api\user.php
    Creating migration: D:\xampp\htdocs\ld\fuel\app\migrations/046_create_api_users_actions_2.php


    Is this undocumented feature?
  • The first migration is a class called Create_Api_Users_Actions. The second one must be suffixed, otherwise you'll end up with duplicate class names, which will cause the migration run to crash.
  • I'm generating two diff. models - api_users_actions and api_users, I don't see duplication in here. I'm missing something?
  • Ah, missed that, just looked at the "creating migration" lines.

    I've looked in the code, but I have no clue where the "_action" in the second migration comes from. The model generation code calls the migration generation method using the models table name, prefixed with "create_".

    I can reproduce this behaviour here, so I'll have a look.
  • HarroHarro
    Accepted Answer
    Funny thing is that if I run your second generation again (using -f), it does create the correct migration...
  • Thanks for the info. This looks like weird bug.
  • Found the issue. Duplicate migration detection is borked. I won't have time for this today, could you create an issue for this at https://github.com/fuel/oil/issues ?
  • Yes, no problem.

Howdy, Stranger!

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

In this Discussion