Jump to content
Sign in to follow this  
maxxd

Laravel migration question

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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 by maxxd
hit enter too soon

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.