Hello there,
I guess your example is not the best since this check could be defined on Author.Meta.constraints
directly but if you wanted to define such a check on Book anyway you'll have to define a function
and refer to it in the check constraint using Func.
Using RunSQL in your migrations
RunSQL("""
create or replace function author_age_gt(int, int) returns boolean as $$
select exists (
select 1
from "author"
where id = $1 and age > $2
);
$$ language sql;
""")
And then you could define your CheckConstraint as
CheckConstraint(Func(F('author'), 18, function='author_age_gt'), name='age_check')
Cheers,
Simon