diff --git a/schmeckels/restart.py b/schmeckels/restart.py new file mode 100644 index 0000000..5009515 --- /dev/null +++ b/schmeckels/restart.py @@ -0,0 +1,25 @@ +#! /usr/bin/env python3 +import re +import sys + +import click +import colorful as cf + +from schmeckels.helper import create_tag, get_rules, get_session +from schmeckels.models import Tag, Transaction + + +@click.command(name="restart") +def command(): + input("This will DELETE all tags and remove all sorting! You sure?") + + session = get_session() + allTransactions = session.query(Transaction).all() + + for transaction in allTransactions: + transaction.tags = [] + + session.bulk_save_objects(allTransactions) + + session.query(Tag).delete() + session.commit()