首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Propel2 diff使用PostgreSQL检测不存在的更改。

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

Stack Overflow用户
提问于 2016-06-12 16:38:23
回答 2查看 206关注 0票数 2

我使用的是Propel2 ORM / PostgreSQL,这是我的配置:

代码语言:javascript
复制
propel:
database:
    connections:
        default:
            adapter: pgsql
            dsn: pgsql:host=localhost;port=5432;dbname=sps_db
            user: postgres
            password: postgres
            settings:
                charset: utf8

这是我的示例模式:

代码语言:javascript
复制
<?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已在Ubuntu16.04上新安装。当我第一次运行propel diffpropel migrate时,一切正常,生成表。

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

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

代码语言:javascript
复制
Comparing models...
Structure of database was modified in datasource "default": 1 modified tables

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

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

代码语言:javascript
复制
  [PDOException]                                                                                         
  SQLSTATE[42701]: Duplicate column: 7 ERROR:  column "id_product" of relation "product" already exists  

我真搞不清到底发生了什么。所有这些,使用一个更复杂的模式(而且这个模式也是如此)可以正确地工作w/ MySQL。

有什么想法吗?

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

代码语言:javascript
复制
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';
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-06-14 18:04:28

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

它可能是9.5.x中的一个bug。

票数 11
EN

Stack Overflow用户

发布于 2016-08-22 06:09:33

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

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

它归结为在PostgreSQL9.5中拆分架构时的一个简单的trim命令

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37776670

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档