| Total Complexity | 4 | 
| Total Lines | 16 | 
| Duplicated Lines | 0 % | 
| 1 | import transaction | ||
| 4 | class MigrationBase(object): | ||
| 5 | def __init__(self, root): | ||
| 6 | self.root = root | ||
| 7 | |||
| 8 | @classmethod | ||
| 9 | def is_applicable(cls, root): | ||
| 10 | return getattr(root, '_db_version', 0) < cls.DB_VERSION | ||
| 11 | |||
| 12 | def set_version(self): | ||
| 13 | self.root._db_version = self.DB_VERSION | ||
| 14 | |||
| 15 | def apply(self): | ||
| 16 | transaction.begin() | ||
| 17 | self.forward() | ||
| 18 | self.set_version() | ||
| 19 | transaction.commit() | ||
| 20 |