+ def migrate(self):
+ with Session(self.engine) as session:
+ session.exec(text(''' alter table goal add start_date DATETIME; '''))
+ session.commit()
+ return 'Success'
+
+
+ def _set_pref_goal_id(self, goal_id):
+ with Session(self.engine) as session:
+ prefs = session.exec(select(PreferGoal)).all()
+ for pref in prefs:
+ session.delete(pref)
+ session.commit()
+ pref = PreferGoal()
+ pref.goal_id = goal_id
+ session.add(pref)
+ session.commit()
+
+ def _get_pref_goal_id(self):
+ with Session(self.engine) as session:
+ pref = session.exec(select(PreferGoal)).one()
+ return pref.goal_id
+
+
+ def clear(self, goal_id, clear_all=False):
+ with Session(self.engine) as session:
+ goal = session.exec(_get_with_id(Goal, goal_id)).first()
+ for item in goal.tasks:
+ if clear_all or item.complete_date:
+ session.delete(item)
+ session.commit()