decode existing metadata

This commit is contained in:
j 2016-01-08 16:14:40 +05:30
parent 5d02474ce8
commit d4a961f470

View file

@ -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():