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

0 votes

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'),
  PRIMARY KEY (`id`),
) ENGINE=InnoDB;

How can I create a migration to add a value to the enum field?

Nov 12, 2020 in Laravel by kartik
• 37,490 points
636 views

1 answer to this question.

0 votes

Hello @kartik,

Try using this code:

public function up()
    {
        Schema::create('dt_warehouses', function (Blueprint $table) {
            **$table->enum('isactive', ['Y', 'N'])->default('Y');**
            $table->timestamps();
        });
    }

Hope it works!!

Thank You!!

answered Nov 12, 2020 by Niroj
• 82,680 points

Related Questions In Laravel

0 votes
1 answer

How Can I Set the Default Value of a Timestamp Column to the Current Timestamp with Laravel Migrations?

Hello, To create both of the created_at and updated_at columns: $t->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); $t->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP on update ...READ MORE

answered Apr 2, 2020 in Laravel by Niroj
• 82,680 points
6,143 views
0 votes
1 answer

How to manually create a new empty Eloquent Collection in Laravel?

Hello @kartik, It's not really Eloquent, to add ...READ MORE

answered Aug 11, 2020 in Laravel by Niroj
• 82,680 points
2,042 views
0 votes
1 answer

How can I create a unique random string in laravel?

Hello @kartik, You can use : sha1(time()) Explanation: sha1 is ...READ MORE

answered Sep 25, 2020 in Laravel by Niroj
• 82,680 points
739 views
0 votes
1 answer

How can I modify a migration in Laravel?

Hello @kartik, You should create a new migration ...READ MORE

answered Sep 27, 2020 in Laravel by Niroj
• 82,680 points
672 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,680 points
6,774 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,680 points
789 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,680 points
589 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,680 points
7,176 views
0 votes
1 answer

How can we create a record in Laravel using eloquent?

We need to create a new model ...READ MORE

answered Mar 20, 2020 in Laravel by Niroj
• 82,680 points
231 views
+2 votes
2 answers

How to add a new column to existing table of laravel in a migration?

You need do little modification in your ...READ MORE

answered Dec 10, 2020 in Laravel by anonymous
• 82,680 points
29,000 views