What you are doing is pretty straightforward so I'm surprised you are running in to trouble.
I did notice this line is not quite right: jodb.joke_category.requires = IS_IN_DB(jodb,jodb.joke.id) Should be: jodb.joke_category.joke_id.requires = IS_IN_DB(jodb, joke.id<http://jodb.joke.id/> ) For me, "jodb" was hard to look at since I'm so used to just "db". I do the same thing as Villas. I develop against SQLite and then deploy on Postgres. I have migrations turned off in my production environment and then I do migrations more carefully than I do in dev.