Dynamic enum fix

Rejigging various tables to add foreign key relationships for dynamic enums.

Also modified ASModel to automatically sniff out and apply dynamic enums from the JSONModel schemas.  Previously I'd assumed we would call create_enum automatically, but obviously that doesn't work because I forgot to do it in every single case I added a dynamic enum...