Supabase と Prisma で P1013 database string is invalid
投稿日:Mon Jan 08 2024 01:52:58 GMT+0000 (Coordinated Universal Time)
背景
Supabase で新しいプロジェクトを作り Prisma で migrate deploy しようとしたところ以下のエラー
P1013: The provided database string is invalid. invalid port number in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.
解決法
今回の原因としては Supabase の接続パスワードに使用できない文字が含まれているためだったので、パスワードを%エンコードして解決した。
例えばパスワードが 「@password+」だったら「%40password%2B」というようにパスワードを%エンコードした値を接続文字列に設定する。
javascript で簡単にエンコードできる。
encodeURIComponent(“@password%”) // %40password%2B