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