gpt4 book ai didi

php - 将 Laravel 迁移与 AWS Redshift 数据库结合使用

转载 作者:行者123 更新时间:2023-12-04 13:48:06 25 4
gpt4 key购买 nike

我正在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com