maxxd Posted August 31, 2019 Share Posted August 31, 2019 Hi y'all. So I'm not new to frameworks in general but am new to Laravel specifically. I'm working through a thing and am running into an issue where a migration will create the specified table, but won't create the proper columns. Using the example in the documentation I get this behavior. For instance, <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateFlightsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('flights', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); $table->string('airline'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('flights'); } } This leaves me with a table named 'flights' that has the columns 'id', 'created_at', and 'updated_at'. Please note this code is copied and pasted from the Laravel migration documentation. Anybody have any words of wisdom on this? It's driving me nuts and I'm sure it's something simple I just don't know about. Quote Link to comment https://forums.phpfreaks.com/topic/309165-laravel-migration-question/ Share on other sites More sharing options...
maxxd Posted September 1, 2019 Author Share Posted September 1, 2019 (edited) On the off chance someone finds this in the future, apparently the answer is that you don't specify the auto-increment column and the call to $table->timestamps() must come last in the method. I finally dropped the $table->bigIncrement('id'); line and put the $table->timestamps(); call last in the stack, and now it works. So, you know... cool. Edited September 1, 2019 by maxxd hit enter too soon Quote Link to comment https://forums.phpfreaks.com/topic/309165-laravel-migration-question/#findComment-1569332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.