dongwei8440 2016-06-12 16:38 采纳率: 100%
浏览 64
已采纳

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

I'm using Propel2 ORM w/ PostgreSQL, this is my configuration:

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

This is my sample schema:

<?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 has been fresh installed on Ubuntu 16.04. When I run propel diff and propel migrate the first time everything is OK and the tables are generated.

Here is the first generated migration: http://pastebin.com/hK9qwfeA

If, without changing the schema, I re-run diff propel detects changes (which are non-existent):

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

With the following generated migration file: http://pastebin.com/Yx143CKp

Of course, if I execute the migration file SQL complains:

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

I can't really figure out what's happening. All of the above, with a much more complex schema (and with this one, too) works correctly w/ MySQL.

Any ideas?

EDIT: this is the SQL from pgSql for the table generated in the first migration:

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条回答 默认 最新

  • dr637349 2016-06-14 18:04
    关注

    Downgrading PostgreSQL 9.5.x to 9.4.8 solved this problem for me.

    It may be a bug in 9.5.x.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改