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

标签 php amazon-web-services laravel-5 database-migration amazon-redshift

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

相关文章:

php - MySQL 中的并发处理

amazon-web-services - 无法在 EMR 4.0.0 上安装 Ganglia

python - Nginx,ec2 上的 django,弹性 ip 没有响应

php - 在 Laradock 应用程序中找不到类 'MongoId'

php - Laravel:根据每个项目的半径选择选择一定距离内的模型

php - 如何设置本地与生产环境中不同的 Laravel 5 存储和缓存路径?

php - 如何创建一个 SQL 查询,其中我可以使用 WHERE & AND 子句选择一列的最大数量

PHP 使用键和值对检查 foreach 循环内的数值?

php - 如何在mysql中将二进制数据解释为整数

amazon-web-services - AWS 内部负载均衡器的 SSL 证书