-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQL: Add migration to clear up old triggers
- Loading branch information
Showing
3 changed files
with
51 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import mariadb | ||
|
||
|
||
def migration_name(): | ||
return "Dropping old ensure_ingredients_are_ordered triggers (new ones were added)" | ||
|
||
|
||
def check_preconditions(cur): | ||
return | ||
|
||
|
||
def needs_to_run(cur): | ||
cur.execute("SHOW TRIGGERS WHERE `Trigger` LIKE 'ensure_ingredients_are_ordered'") | ||
if cur.fetchone(): | ||
return True | ||
return False | ||
|
||
|
||
def migrate(cur, db): | ||
try: | ||
cur.execute("DROP TRIGGER IF EXISTS ensure_ingredients_are_ordered;") | ||
db.commit() | ||
except mariadb.Error as err: | ||
print("Something went wrong: {}".format(err)) |