1
0

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.

Phinxのcreate(), update(), save()

Posted at

Phinxには、テーブルを作ったり編集したりするコードを書いたあとで、create()やupdate()というメソッドを呼ぶ必要があります。
でも、save()なんてメソッドもあります。
うーん、違いはなんだろう・・・。

違い

ソースから引用。

create()

Creates a table from the object instance.

テーブルを作ります。

update()

Updates a table from the object instance.

テーブルを更新します。

save()

Commits the table changes.
If the table doesn't exist it is created otherwise it is updated.

テーブルがなければ作るし、あれば更新します。

おまけ

へー、なるほど。
ただ、removeIndex()するときは、save()する必要がなく、すぐに適用されるようです(公式Docより)。

There is no need to call the save() method when using removeIndex(). The index will be removed immediately.

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?