Forum OpenACS Q&A: content_type__create_type for both item and revision table?
For example, I have two tables named ec2_product and ec2_product_revision, and until now I have only created a content_revision type named ec2_product_revision so attributes from ec2_product have not been included in ec2_productx. I tried creating a content_item type named ec2_product, but it's giving an error saying that tree_sortkey is duplicated in the generated view.
"Note that your extended attribute table must reference the cr_revisions table, not cr_items. As mentioned above, this allows you to maintain multiple revisions of the attribute data in tandem with revisions of the content object itself."
Hopefully somebody knows a way around this, as I can't think of one ...
The most straightforward way to extend a content type is to subtype cr_revision. The additional complexity of extending the cr_item is not worth the storage savings or having some non-versioned extedned attributes in most cases.
So the simple solution is to store all of your type specific attributes in the subtype of content revision.
select acs_object_type__create_type ( 'bt_bug', 'Bug', 'Bugs', 'acs_object', 'bt_bugs', 'bug_id', null, 'f', null, 'bt_bug__name' );I guess Lars could comment on whether that is simply a bug or is some sort of shortcoming with subclassing cr_item.
You could enforce uniqueness in a revision table with a partial index.
You can do something similiar with a functional index on oracle (there is an example in chapter 7 in Tom Kyte's Effective Oracle by Design titled selective uniqueness).
However I believe Jade has a trick up his sleeve which actually lets content_type__create_attribute work its magic to full extent. See his guide, if I'm not misstaken.
If you need foreign key references on versioned items, you can add that in as a part of the definition. I also describe this on my tutorial page.
Jeff's partial index trick is a very nice tool to have in your toolbox.
Have we answered your question?