Last active
January 20, 2021 11:12
-
-
Save upinetree/9f643d02bdb8d245b66c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 特定のテーブルのカラムにだけCOLLATIONを設定する方法 | |
| ``` | |
| $ be bin/rails db | |
| =# ALTER TABLE users ALTER COLUMN kana TYPE varchar COLLATE "ja_JP.utf8"; | |
| > 特定のカラムにだけ付与 | |
| =# \d staffs | |
| > 付与したことを確認 | |
| ``` | |
| ## お目当てのCOLLATIONが存在しないときに作る方法 | |
| macにbrewで入れたpostgresqlに`ja_JP.UTF-8`がなかったので作りました。 | |
| ``` | |
| $ locale -a | grep ja | |
| ja_JP | |
| ja_JP.eucJP | |
| ja_JP.SJIS | |
| ja_JP.UTF-8 | |
| > 目的のlocaleを確認 | |
| $ be bin/rails db | |
| =# \l | |
| > templateのCollateにja_JP.UTF-8が設定されているのに… | |
| =# SELECT * from pg_collation; | |
| > ja_JP.UTF-8に対応するcollationがない… | |
| =# CREATE COLLATION "ja_JP.utf8" (LOCALE = 'ja_JP.UTF-8'); | |
| > つくられた | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment