Yii, Postgres and tables inheritance

Hello all!

A have some problems with Yii and Postgres. I have the table, that has been inherited from another one. Parent table have the primary key, but child doesnt have one. When I try generate CRUD for child table Yii reports that there are no primary key. Relations method doesnt work for this model too.

any ideas ??

p.s. sorry for my English!

I think that problem in this query:



SELECT conname, consrc, contype, indkey FROM (


	SELECT


		conname,


		CASE WHEN contype='f' THEN


			pg_catalog.pg_get_constraintdef(oid)


		ELSE


			'CHECK (' || consrc || ')'


		END AS consrc,


		contype,


		conrelid AS relid,


		NULL AS indkey


	FROM


		pg_catalog.pg_constraint


	WHERE


		contype IN ('f', 'c')


	UNION ALL


	SELECT


		pc.relname,


		NULL,


		CASE WHEN indisprimary THEN


				'p'


		ELSE


				'u'


		END,


		pi.indrelid,


		indkey


	FROM


		pg_catalog.pg_class pc,


		pg_catalog.pg_index pi


	WHERE


		pc.oid=pi.indexrelid


		AND EXISTS (


			SELECT 1 FROM pg_catalog.pg_depend d JOIN pg_catalog.pg_constraint c


			ON (d.refclassid = c.tableoid AND d.refobjid = c.oid)


			WHERE d.classid = pc.tableoid AND d.objid = pc.oid AND d.deptype = 'i' AND c.contype IN ('u', 'p')


	)


) AS sub


WHERE relid = (SELECT oid FROM pg_catalog.pg_class WHERE relname= :table


	AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace


	WHERE nspname=:scheme))


…in CpgSqlSchema.php

Not sure how to fix this for the moment…Could you create a ticket about this issue? If you find any solution, please let us know. Thanks.

Could you post both the tables ?

You need to create PK for your children table. It's described in PostgreSQL manual about inheritance. See caveats section.