Propel2 diff使用PostgreSQL检测不存在的更改

时间:2016-06-12 16:38:24

标签: php postgresql orm propel propel2

我正在使用带PostgreSQL的Propel2 ORM,这是我的配置:

propel:
database:
    connections:
        default:
            adapter: pgsql
            dsn: pgsql:host=localhost;port=5432;dbname=sps_db
            user: postgres
            password: postgres
            settings:
                charset: utf8

这是我的示例架构:

<?xml version="1.0" encoding="utf-8"?>
<database name="default" defaultIdMethod="native" defaultPhpNamingMethod="underscore" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="http://xsd.propelorm.org/1.6/database.xsd" >
<table name="product" description="Available products table">
    <column name="id_product" autoIncrement="true" primaryKey="true" type="BIGINT" required="true"/>
    <column name="id_product_barcode" type="BIGINT" />
    <column name="name" type="VARCHAR" size="200" required="true" />
    <column name="id_product_manufacturer" type="INTEGER" required="true" />
    <column name="id_product_category" type="INTEGER" required="true"/>
    <column name="id_product_photo" type="BIGINT" />
</table>
</database>

PostgreSQL 9.5已经在Ubuntu 16.04上全新安装。 当我第一次运行propel diffpropel migrate时,一切正常并生成表格。

以下是第一次生成的迁移:http://pastebin.com/hK9qwfeA

如果在不更改架构的情况下,我重新运行diff propel检测到更改(不存在):

Comparing models...
Structure of database was modified in datasource "default": 1 modified tables

使用以下生成的迁移文件:http://pastebin.com/Yx143CKp

当然,如果我执行迁移文件SQL抱怨:

  [PDOException]                                                                                         
  SQLSTATE[42701]: Duplicate column: 7 ERROR:  column "id_product" of relation "product" already exists  

我无法弄清楚发生了什么。以上所有,使用更复杂的模式(并且使用这个模式)也能正确地使用MySQL。

有什么想法吗?

编辑:这是pgSql中第一次迁移中生成的表的SQL:

CREATE TABLE public.product
(
  id_product bigint NOT NULL DEFAULT nextval('product_id_product_seq'::regclass),
  id_product_barcode bigint,
  name character varying(200) NOT NULL,
  id_product_manufacturer integer NOT NULL,
  id_product_category integer NOT NULL,
  id_product_photo bigint,
  CONSTRAINT product_pkey PRIMARY KEY (id_product)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE public.product
  OWNER TO postgres;
COMMENT ON TABLE public.product
  IS 'Available products table';

2 个答案:

答案 0 :(得分:11)

将PostgreSQL 9.5.x降级到9.4.8为我解决了这个问题。

这可能是9.5.x中的错误。

答案 1 :(得分:0)

经过一些调试和调查(我们认为这是9.5元数据更改),我们发现了以下内容:

https://github.com/propelorm/Propel2/pull/1245

在postgresql 9.5中分割模式时,它归结为一个简单的trim命令