【问题标题】:Phinx - database migrations for php app - postgreSQL schema does not workPhinx - php 应用程序的数据库迁移 - postgreSQL 模式不起作用
【发布时间】:2016-12-12 00:00:44
【问题描述】:

我正在使用 Phinx 进行数据库迁移。

在我的例子中它不适用于 PostgreSQL 模式(例如 test.table)。

// create the table
$table = $this->table('test.table');
$table->addColumn('test', 'integer')
      ->create();

当我点击phinx migrate 时,它会导致错误。有什么解决办法吗?

我的错误是:

--> IMAGE ERROR

错误是:语法错误或在“.”内

Phinx 是否支持 table 方法中的点表示法?

【问题讨论】:

标签: php postgresql database-migration phinx


【解决方案1】:

您确定可以在表名中使用点符号吗?

// create the table
$table = $this->table('test_table');
$table->addColumn('test', 'integer')
    ->create();

test.table 将遵循databasename.tablename 的模式

【讨论】:

  • 在 postgreSQL 点符号中如下:schema.tablename
【解决方案2】:

我找到了替代解决方案。在更改表之前,我手动选择了 PostgreSQL 模式。

// changing schema
$this->getAdapter()->setOptions(array_replace($this->getAdapter()->getOptions(), ['schema' => 'your_schema']));

// create the table
$table = $this->table('test_table');
$table->addColumn('test', 'integer')
            ->create();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-08
    • 2012-04-27
    • 2016-09-20
    • 2013-09-20
    • 2010-10-23
    • 2011-10-05
    • 1970-01-01
    相关资源
    最近更新 更多