我的项目有三个数据库。当我尝试使用PostgreSQL进行Laravel迁移时。我收到一些错误。但是Laravel与其他mysql数据库的迁移是可以的。我正在使用 XAMPP 。你能检查一下并纠正我吗?
错误
[PDOException]
could not find driver
数据库
<?php
return [
'fetch' => PDO::FETCH_CLASS,
'default' => env('DB_CONNECTION', 'mysql_shop'),
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => database_path('database.sqlite'),
'prefix' => '',
],
'mysql_cms' => [
'driver' => 'mysql',
'host' => env('DB_CONTAO_HOST', 'localhost'),
'database' => env('DB_CONTAO_DATABASE', 'forge'),
'username' => env('DB_CONTAO_USERNAME', 'forge'),
'password' => env('DB_CONTAO_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'mysql_shop' => [
'driver' => 'mysql',
'host' => env('DB_SHOP_HOST', 'localhost'),
'database' => env('DB_SHOP_DATABASE', 'forge'),
'username' => env('DB_SHOP_USERNAME', 'forge'),
'password' => env('DB_SHOP_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_PGSQL_HOST', 'localhost'),
'database' => env('DB_PGSQL_DATABASE', 'maindb'),
'username' => env('DB_PGSQL_USERNAME', 'postgres'),
'password' => env('DB_PGSQL_PASSWORD', 'postgres'),
'charset' => 'utf8',
'prefix' => '',
'schema' => env('DB_PGSQL_SCHEMA', 'fes'),
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
],
迁移代码
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::connection('pgsql')->create('fes.password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token')->index();
$table->timestamp('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::connection('pgsql')->drop('fes.password_resets');
}
}