S
S
Sergey Zavialov2019-02-22 12:26:24
Laravel
Sergey Zavialov, 2019-02-22 12:26:24

How to create deleted_at field for soft delete in existing db table?

Created a migration in which I prescribe the following.
The code is like this

public function up()
    {
        Schema::table('articles', function (Blueprint $table) {
            //
            $table->softDeletes();
        });
    }

public function down()
    {
        Schema::table('articles', function (Blueprint $table) {
            //
            $table->dropColumn('deleted_at');
        });
    }

Console
php artisan migrate
Can't create deleted_at field
in console following
"c:\OSPanel\domains\blog>php artisan migrate
"select * from information_schema.tables where table_schema = ? and table_name = ?"
"select `migration` from `migrations` order by `batch` asc, `migration` asc"
"select max(`batch`) as aggregate from `migrations`"
Migrating: 2019_02_22_083248_change_artical_table_soft
"insert into `migrations` (`migration`, `batch`) values ​​(?, ?)"
Migrated: 2019_02_22_083248_change_artical_table_soft"
What's with the red quotes.
When re-typing in the console
The message in the console is the following
c:\OSPanel\domains\blog>
"select * from information_schema.tables where table_schema = ? and table_name = ?"
"select `migration` from `migrations` order by `batch` asc, `migration` asc"
Nothing to migrate.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question