Search code examples
laravelpostgresqlmigration

How can I create laravel migration with enum type column?


I am trying to create enum column in laravel migration. Upon executing the query it does create column in the table but checking in postgresql for created enum types, it shows theres none. Does anyone ever experience this?

I am using laravel 5.4, php 7 and vagrant

Migration code

public function up()
    {
        Schema::create('restaurant_tables', function(Blueprint $table){
            $table->increments('_id');
            $table->string('tableNo', 100);
            $table->json('spatialLocation');
            $table->enum('tableStatus' , array('Occupied', 'Reserved', 'Vacant', 'For Cleaning'))->default('Vacant');
            $table->integer('numberOfCustomers');
            $table->integer('seatLimit');
            $table->string('tableDimension', 100);
            $table->enum('tableType', ['4x4','16x4','8x4']);
            $table->bigInteger('chairID');
        });

        Schema::table('restaurant_tables', function(Blueprint $table){
            $table->foreign('chairID')->references('_id')->on('restaurant_chairs');
        });
    }

Image in checking if enum data type created, and check if all tables are created


Solution

  • $table->enum('tableStatus',['Vacant', 'Reserved', 'Occupied', 'For Cleaning']);
    

    First one will be default