Fix embarrassing bug: generated foreign key constraints now correctly reference target table.