Add foreign key from target to target_type

Migration and schema updates.