decode existing metadata
This commit is contained in:
parent
5d02474ce8
commit
d4a961f470
1 changed files with 22 additions and 0 deletions
22
oml/setup.py
22
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():
|
||||
|
|
Loading…
Reference in a new issue