Brightside
Brightside

Reputation: 131

laravel 4 - change column type with migration generator?

I am trying to create all files related to the table/db migration throughout the CMD with laravel generators and other tools.

And i am looking for to change column type with cmd line similar to this one:

$ php artisan generate:migration add_username_to_users_table --fields="username:string"

i use this one to add username field - i believe its from the generator build for laravel 4. so i wonder if there is similar command in order to change column type to integer.

Upvotes: 0

Views: 2717

Answers (2)

jmadsen
jmadsen

Reputation: 3675

Have a look at Jeffrey Way's Migrations Generator

https://github.com/JeffreyWay/Laravel-4-Generators#migrations

extends migrations with many handy tools, including what you are looking for

Upvotes: 0

Hassan
Hassan

Reputation: 626

As you know, the Artisan CLI will create a migration file and if you notice, the file's name will be something like 2014_05_12_200322_create_users_table.php, which is the date and time of creation. If you run the command again with a changed column type, it will just create a new migration file for you.

This is a good thing and is something desired because otherwise it could get quite confusing keeping track of something that has been run or changed, especially when working in working in a team. So, use the rollback command and change your migration file as per your requirements and run the migration again.

migrate:rollback

Edit: Here's an article you should check out.

Upvotes: 1

Related Questions