FuelPHP: Create Table When Using 'oil generate model' Confusion

I am totally new to FuelPHP, ORM and migrations in general so sorry if I come across like a newbie, but I've been struggling with this for a few hours now so I thought I'd ask for help. I think I'm either doing something wrong or missing something fundamental.

I am trying to create a users model, for simplicity let's say it just has a string representing name.

I was under the impression that using the following two Oil commands would create a users model, and an associated migration which after running would build an associated table:

php oil generate model user name:string
oil refine migrate

This does successfully create the model and migration, but running the second command doesn't build the table in the database.

If I run these commands on the other hand:

php oil generate migration create_user name:text
oil refine migrate

The migration is created and the table is built in my database. I noticed that perpending 'create_' to the migration name made it possible to create the table, whereas leaving it off (i.e php oil generate migration user name:text) doesn't insert the table to the DB. I noticed the generated migrations with and without the 'create_' are significantly different.

So my question ultimately is, how do I create the model, associated migration which creates the table? Or, am I totally misunderstanding something?



If you get 'Already on the latest migration', your migration tracking data is out of sync. Migrations are tracked both in the database (a table called migration) and a config file in your environment folder called migrations.php.

If there is already an entry in one of them, oil will not run it again.

So you can't just delete the table through the backdoor and then run the migration again. You'll have to run a 'migrate:down' to revert the last migration, or if you delete all, also delete the migration table and config file.

Again, credit to Harro Verton on the FuelPHP forums.

Need Your Help

Query one entity according to another joined entity field values

php mysql symfony2 doctrine2 query-builder

I have this OneToMany relationship between two entities: Sculpture(1) and Image(n). My goal is to query all Sculptures that have all their Image.featured set to 0. If a Sculpture have at least one ...

Need to change color of text on input form on mobile site

css joomla mobile-website

I have recently made my website responsive, it is a joomla site, and on the mobile version anywhere that I have a form, when you type in the text you can barely see it because of the color. I have ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.