【问题标题】:Propel2 diff detects non-existent changes with PostgreSQLPropel2 diff 使用 PostgreSQL 检测不存在的更改
【发布时间】:2016-06-12 16:38:23
【问题描述】:

我正在使用带有 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';

【问题讨论】:

  • 为了记录,我切换到 Doctrine 2。

标签: php postgresql orm propel propel2


【解决方案1】:

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

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

【讨论】:

  • 请不要理会这个答案。如果正确,它将提供关键信息。如果有的话,请编辑以改进它。
  • 我想这是正确的答案,因为它解决了问题,虽然间接
【解决方案2】:

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

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

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

【讨论】:

    猜你喜欢
    • 2019-03-03
    • 1970-01-01
    • 2013-03-08
    • 1970-01-01
    • 2015-01-01
    • 2019-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多