Fixed foreign key generation bug for pgsql.