Skip to content

Commit

Permalink
Fix issue with postgres dump printing duplicate content
Browse files Browse the repository at this point in the history
  • Loading branch information
emilpriver committed Jul 3, 2024
1 parent 30d86e0 commit efffaf0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/database_drivers/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl DatabaseDriver for PostgresDriver {

let constraints: Vec<String> = sqlx::query(
r#"
SELECT
SELECT DISTINCT
CASE
WHEN tc.constraint_type = 'PRIMARY KEY' THEN
'ALTER TABLE ' || tc.table_name ||
Expand All @@ -305,7 +305,9 @@ impl DatabaseDriver for PostgresDriver {
'ALTER TABLE ' || tc.table_name ||
' ADD CONSTRAINT ' || tc.constraint_name ||
' CHECK (' || cc.check_clause || ');'
END AS sql
END AS sql,
tc.table_name,
tc.constraint_name
FROM
information_schema.table_constraints tc
JOIN
Expand All @@ -318,7 +320,7 @@ impl DatabaseDriver for PostgresDriver {
tc.table_schema = 'public'
ORDER BY
tc.table_name,
tc.constraint_name;
tc.constraint_name
"#,
)
.map(|row: PgRow| row.get("sql"))
Expand Down

0 comments on commit efffaf0

Please sign in to comment.