diff --git a/oml/item/models.py b/oml/item/models.py index 06a2586..7d46f07 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -218,6 +218,8 @@ class Item(db.Model): # self.meta.update does not trigger db update! m = Metadata.load(*self.meta['primaryid']) for key in m: + if key == 'id': + continue self.meta[key] = m[key] self.modified = datetime.utcnow() self.update_sort() @@ -701,6 +703,8 @@ class Metadata(db.Model): def edit(self, data): changed = {} for key in data: + if key == 'id': + continue if data[key] != self.data.get(key): self.data[key] = data[key] changed[key] = data[key] @@ -719,5 +723,7 @@ class Metadata(db.Model): def load(self, key, value): m = self.get(key, value) if m: + if 'id' in m.data: + del m.data['id'] return m.data return {} diff --git a/oml/setup.py b/oml/setup.py index dc24eba..3d5b261 100644 --- a/oml/setup.py +++ b/oml/setup.py @@ -232,6 +232,13 @@ def upgrade_db(old, new=None): for i in item.models.Item.query: for f in i.files.all(): f.move() + if old <= '20160103-423-05ca6c9': + with db.session(): + import item.models + for i in item.models.Item.query: + if 'id' in i.meta: + del i.meta['id'] + i.save() def create_default_lists(user_id=None): with db.session():