2

我正在使用带有 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 diff并且propel 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';
4

2 回答 2

11

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

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

于 2016-06-14T18:04:28.710 回答
0

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

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

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

于 2016-08-22T06:09:33.120 回答