Add sql table column before or after specific other column – by migrations in Laravel 4.1

Yes. Create a new migration using php artisan migrate:make update_users_table. Then use the table command as follows (if you’re using MySQL!): Schema::table(‘users’, function($table) { $table->string(‘phone_nr’)->after(‘id’); }); Once you’ve finished your migration, save it and run it using php artisan migrate and your table will be updated. Documentation: https://laravel.com/docs/4.2/migrations#column-modifiers

Laravel Migration Change to Make a Column Nullable

Laravel 5 now supports changing a column; here’s an example from the offical documentation: Schema::table(‘users’, function($table) { $table->string(‘name’, 50)->nullable()->change(); }); Source: http://laravel.com/docs/5.0/schema#changing-columns Laravel 4 does not support modifying columns, so you’ll need use another technique such as writing a raw SQL command. For example: // getting Laravel App Instance $app = app(); // getting laravel … Read more

Laravel Add a new column to existing table in a migration

To create a migration, you may use the migrate:make command on the Artisan CLI. Use a specific name to avoid clashing with existing models for Laravel 5+: php artisan make:migration add_paid_to_users_table –table=users for Laravel 3: php artisan migrate:make add_paid_to_users You then need to use the Schema::table() method (as you’re accessing an existing table, not creating … Read more