Skip to content

Commit 52fa75e

Browse files
committed
Added IF EXISTS clauses to drop statements
1 parent 5b354c6 commit 52fa75e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

foreignkey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (c ForeignKeySchema) Add() {
4343

4444
// Return SQL to drop the table
4545
func (c ForeignKeySchema) Drop() {
46-
fmt.Printf("ALTER TABLE %s DROP CONSTRAINT %s;\n", c.row["table_name"], c.row["constraint_name"])
46+
fmt.Printf("ALTER TABLE %s DROP CONSTRAINT IF EXISTS %s;\n", c.row["table_name"], c.row["constraint_name"])
4747
}
4848

4949
// Handle the case where the table and column match, but the details do not

table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (c TableSchema) Add() {
3838

3939
// Return SQL to drop the table
4040
func (c TableSchema) Drop() {
41-
fmt.Printf("DROP TABLE %s;\n", c.row["table_name"])
41+
fmt.Printf("DROP TABLE IF EXISTS %s;\n", c.row["table_name"])
4242
}
4343

4444
// Handle the case where the table and column match, but the details do not

0 commit comments

Comments
 (0)