how can I create a migration to add a value to an enum in eloquent

后端 未结 5 1569
后悔当初
后悔当初 2020-12-28 14:46

I have a table that contains an enum field

CREATE TABLE `user_status` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `values` enum(\'on\', \'off\'),
           


        
5条回答
  •  佛祖请我去吃肉
    2020-12-28 15:13

    The second answer works, but in my case CHANGE was throwing an error. So i tried using MODIFY instead and that worked. Thanks guys..

    Here is my code:

    class ChangeJobTypeEnum extends Migration {
    
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::statement("ALTER TABLE _TABLENAME_ MODIFY _COLUMNNAME_ ENUM('on', 'off', 'auto')");
    
    }
    
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        DB::statement("ALTER TABLE _TABLENAME_ MODIFY_COLUMNNAME_ ENUM('on', 'off')");
    
    }
    }
    

提交回复
热议问题