[1.7.x] Factored create_fk_sql, create_unique_sql, and delete_constraint_sql.

Backport of 0bea6c8749 from master