1
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 1 year has passed since last update.

【Laravel】【PostgreSQL】typeをnumericでマイグレーションしたい

Posted at

$table->decimalを採用する。
https://readouble.com/laravel/5.7/ja/migrations.html

$table->decimal('amount', 8, 2);

有効(全体桁数)/小数点以下桁数指定のDECIMALカラム

本当にこれでいいのかと思い一応postgresの公式を調べる。

decimalとnumeric型は等価です。 2つのデータ型はともに標準SQLに従っています。

postgresqlではdecimalとnumeric型は等価らしいので、マイグレーションする際の記述はこれで問題ないかと。

参考:
https://www.postgresql.jp/docs/9.2/datatype-numeric.html
https://qiita.com/windows222/items/5c5a7ef3beb6f1d8f8aa

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