前提・実現したいこと
Laravelで作ったアプリをHerokuにデプロイしてMySQLでMigrateをしたい。
発生している問題・エラーメッセージ
heroku run php artisan migrate
コマンドを打つと次のようなエラーが表示される。
In Connection.php line 669:
SQLSTATE[22023]: Invalid parameter value: 7 ERROR: invalid value for parameter "client_encoding": "utf8mb4" (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_t ype = 'BASE TABLE')
In PostgresConnector.php line 66:
SQLSTATE[22023]: Invalid parameter value: 7 ERROR: invalid value for parameter "client_encoding": "utf8mb4"
該当のソースコード
config/database.php
php
1<?php 2 3use Illuminate\Support\Str; 4 5return [ 6 7 /* 8 |-------------------------------------------------------------------------- 9 | Default Database Connection Name 10 |-------------------------------------------------------------------------- 11 | 12 | Here you may specify which of the database connections below you wish 13 | to use as your default connection for all database work. Of course 14 | you may use many connections at once using the Database library. 15 | 16 */ 17 18 'default' => env('DB_CONNECTION', 'mysql'), 19 20 /* 21 |-------------------------------------------------------------------------- 22 | Database Connections 23 |-------------------------------------------------------------------------- 24 | 25 | Here are each of the database connections setup for your application. 26 | Of course, examples of configuring each database platform that is 27 | supported by Laravel is shown below to make development simple. 28 | 29 | 30 | All database work in Laravel is done through the PHP PDO facilities 31 | so make sure you have the driver for your particular database of 32 | choice installed on your machine before you begin development. 33 | 34 */ 35 36 'connections' => [ 37 38 'sqlite' => [ 39 'driver' => 'sqlite', 40 'url' => env('DATABASE_URL'), 41 'database' => env('DB_DATABASE', database_path('database.sqlite')), 42 'prefix' => '', 43 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 44 ], 45 46 'mysql' => [ 47 'driver' => 'mysql', 48 'url' => env('DATABASE_URL'), 49 'host' => env('DB_HOST', '127.0.0.1'), 50 'port' => env('DB_PORT', '3306'), 51 'database' => env('DB_DATABASE', 'homestead'), 52 'username' => env('DB_USERNAME', 'homestead'), 53 'password' => env('DB_PASSWORD', 'secret'), 54 'charset' => 'utf8', 55 'collation' => 'utf8_unicode_ci', 56 'prefix' => '', 57 'prefix_indexes' => true, 58 'strict' => true, 59 'engine' => null, 60 'options' => extension_loaded('pdo_mysql') ? array_filter([ 61 PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 62 ]) : [], 63 ], 64 65 'pgsql' => [ 66 'driver' => 'pgsql', 67 'url' => env('DATABASE_URL'), 68 'host' => env('DB_HOST', '127.0.0.1'), 69 'port' => env('DB_PORT', '5432'), 70 'database' => env('DB_DATABASE', 'forge'), 71 'username' => env('DB_USERNAME', 'forge'), 72 'password' => env('DB_PASSWORD', ''), 73 'charset' => 'utf8', 74 'prefix' => '', 75 'prefix_indexes' => true, 76 'schema' => 'public', 77 'sslmode' => 'prefer', 78 ], 79 80 'sqlsrv' => [ 81 'driver' => 'sqlsrv', 82 'url' => env('DATABASE_URL'), 83 'host' => env('DB_HOST', 'localhost'), 84 'port' => env('DB_PORT', '1433'), 85 'database' => env('DB_DATABASE', 'forge'), 86 'username' => env('DB_USERNAME', 'forge'), 87 'password' => env('DB_PASSWORD', ''), 88 'charset' => 'utf8', 89 'prefix' => '', 90 'prefix_indexes' => true, 91 ], 92 93 ], 94 95 /* 96 |-------------------------------------------------------------------------- 97 | Migration Repository Table 98 |-------------------------------------------------------------------------- 99 | 100 | This table keeps track of all the migrations that have already run for 101 | your application. Using this information, we can determine which of 102 | the migrations on disk haven't actually been run in the database. 103 | 104 */ 105 106 'migrations' => 'migrations', 107 108 /* 109 |-------------------------------------------------------------------------- 110 | Redis Databases 111 |-------------------------------------------------------------------------- 112 | 113 | Redis is an open source, fast, and advanced key-value store that also 114 | provides a richer body of commands than a typical key-value system 115 | such as APC or Memcached. Laravel makes it easy to dig right in. 116 | 117 */ 118 119 'redis' => [ 120 121 'client' => env('REDIS_CLIENT', 'phpredis'), 122 123 'options' => [ 124 'cluster' => env('REDIS_CLUSTER', 'redis'), 125 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 126 ], 127 128 'default' => [ 129 'url' => env('REDIS_URL'), 130 'host' => env('REDIS_HOST', '127.0.0.1'), 131 'password' => env('REDIS_PASSWORD', null), 132 'port' => env('REDIS_PORT', 6379), 133 'database' => env('REDIS_DB', 0), 134 ], 135 136 'cache' => [ 137 'url' => env('REDIS_URL'), 138 'host' => env('REDIS_HOST', '127.0.0.1'), 139 'password' => env('REDIS_PASSWORD', null), 140 'port' => env('REDIS_PORT', 6379), 141 'database' => env('REDIS_CACHE_DB', 1), 142 ], 143 144 ], 145 146]; 147
試したこと
・config/database.php
のutf8mb4
の箇所を全てutf8
に変更。
・heroku run php artisan config:cache
を実行しその後再度heroku run php artisan migrate
を実行。
・config/database.php
ファイルの'mysql'
の箇所と'pgsql'
の箇所に'client_encoding' => 'utf8',
をそれぞれ追加。
これら全て試しても変わらず同じエラーメッセージが表示されます。
どなたかご教授していただけると幸いです。
補足情報(FW/ツールのバージョンなど)
MacOS Catalina 10.15.4
Docker for Mac version 2.2.0.5
PHP 7.3.11
Composer 1.9.1
heroku/7.39.2 darwin-x64 node-v12.13.0
回答2件
あなたの回答
tips
プレビュー