我正在使用 Laravel 5.3。我可以成功连接到我的 Redshift 数据库。
但是我发现 Laravel 迁移功能不适用于 Redshift,因为 Laravel 在具有“串行”类型列的架构中创建了一个“迁移”表。 Redshift 不支持“串行”类型。
[Illuminate\Database\QueryException]
SQLSTATE[0A000]: Feature not supported: 7 ERROR: Column "migrations.id" has unsupported type "serial". (SQL: create table "migrations" ("id" serial primary key not null, "migration" varchar(255) not null, "batch" integer not null))[PDOException]
SQLSTATE[0A000]: Feature not supported: 7 ERROR: Column "migrations.id" has unsupported type "serial".
有没有办法解决这个问题,以便我可以在 Redshift 中使用迁移?
最佳答案
对于 Laravel 8. *migrations
表可以存储在不同的数据库(例如 MySQL)中,必须将其配置为 config/database.php
中的默认连接(或 DB_CONNECTION
环境变量)。
创建 migrations
table :
php artisan migrate:install --database=mysql
...哪里mysql
是连接的名称。然后在 Redshift 迁移中,您需要明确指定一个连接:
class CreateRedshiftTable extends Migration
{
protected $connection = 'redshift';
}
然后运行 php artisan migrate
并且每次迁移都将使用指定的连接。这种方法有局限性,因为 Laravel pgsql
驱动程序不支持 Redshift 特定功能。
关于php - 将 Laravel 迁移与 AWS Redshift 数据库结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40972572/