0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【CakePHP3.7】マイグレーションでテーブルをDropする時はsave()を忘れずに!

0
Posted at

テーブルをdropするために、マイグレーションを作る。

public function change()
{
    $table = $this->table('tableNames');
        ->drop();
}

一見それっぽいけど、マイグレーションを実行してもテーブルはdropされない。

じゃあこれなら?

public function change()
{
    $this->dropTable('tableNames’);
}

これだとテーブルはdropされるけどdeprecatedが発生しちゃう。

Deprecated Error: dropTable() is deprecated since 0.10.0. Use $this->table($tableName)->drop()->save() instead. in [/var/www/html/pos/vendor/robmorgan/phinx/src/Phinx/Migration/AbstractMigration.php, line 322]

指示された様に書き換えたら、うまく行きました◎

public function change()
{
    $table = $this->table('tableNames');
        ->drop()->save();
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?