[jifty-devel] Referential integrity

myshare mraptor at gmail.com
Thu Mar 8 13:17:57 EST 2007

Isn't :

column fkid => refers_to YourApp::Model::Table;

works in this situations ?

On 3/8/07, Edmund von der Burg <evdb at ecclestoad.co.uk> wrote:
> Hello,
> I want to create a setup where it is not possible to delete an object
> in one class if it is being referenced from another class. Eg say I
> have boks and authors, I want to prevent deletion of an author if
> there are books by that author in the database.
> What is the best way to do this?
> I could add foreign key links in the database but that might not be
> portable (I am on postgres).
> I could add code to each model class to check before deleteing but
> that would be cumbersome. Rather I'd like Jifty to enforce this sort
> of relationship if a 'references' column is marked as 'mandatory'. ie
> in Book.pm the 'author' would be marked as 'is mandatory'. Hence
> deleteing the books author would leave the book in an invalid state so
> the deletion of the author should be prevented.
> Am I missing something?
> Cheers,
>   Edmund.

More information about the jifty-devel mailing list