Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Using ORM in migration
  • I'm fairly new to FuelPHP and therefore wonder about a "best practice". I'm using ORM for two projects I'm working on and wonder if we can/should use it in a migration script.

    There are cases where I'd like to add some default values to tables created in a migration script. A user "guest", a group called "anonymous" or a bunch of "categories" I'd like to add.

    ORM models don't seem to be available in a migration script. 

    What's the best way to add default data?
  • ORM Models should be available without problems, like any other classes. Providing the Orm package is loaded, and the model class is loadable (if in a module you might have to load that module too).

    We do everything related to upgrades in migrations, database changes are actually a minority of the actions. So that also include loading new base data, re-ordering of data after structural DB changes, etc.

    We usually use plain DB queries though, in case no ORM specific logic is needed, they're faster then ORM calls
  • Thanks Harro! I think I'll use \DB::insert()->execute() for now!

Howdy, Stranger!

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

In this Discussion