From d4a961f47068d283271e1f1c3abeaac4dfdbe70a Mon Sep 17 00:00:00 2001 From: j Date: Fri, 8 Jan 2016 16:14:40 +0530 Subject: [PATCH] decode existing metadata --- oml/setup.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/oml/setup.py b/oml/setup.py index 8114d1c..c171bae 100644 --- a/oml/setup.py +++ b/oml/setup.py @@ -296,6 +296,28 @@ def upgrade_db(old, new=None): sql = 'CREATE UNIQUE INDEX IF NOT EXISTS useritem_index on useritem(user_id,item_id)' session.execute(sql) session.commit() + if old <= '20160108-551-7c23bfb': + with db.session() as session: + import item.models + from meta.utils import decode_html_data + for m in item.models.Metadata.query: + data = decode_html_data(m.data.copy()) + if data != m.data: + #print(m, m.data, data) + m.data = data + m.save() + for i in item.models.Item.query: + changed = False + meta = decode_html_data(i.meta.copy()) + if meta != i.meta: + #print(i, i.meta, meta) + i.meta = meta + info = decode_html_data(i.info.copy()) + if info != i.info: + #print(i, i.info, info) + i.info = info + if changed: + i.save() def create_default_lists(user_id=None): with db.session():