migration script fix
This commit is contained in:
parent
502f7cd9a7
commit
0b654d8b02
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -138,3 +138,5 @@ Pipfile.lock
|
||||||
migration/data
|
migration/data
|
||||||
migration/content/**/*.md
|
migration/content/**/*.md
|
||||||
.obsidian
|
.obsidian
|
||||||
|
|
||||||
|
*.zip
|
|
@ -34,3 +34,4 @@ Also see `Dockerfile`
|
||||||
# How to do an authorized request
|
# How to do an authorized request
|
||||||
|
|
||||||
Put the header 'Auth' with token from signInQuery or registerQuery.
|
Put the header 'Auth' with token from signInQuery or registerQuery.
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,16 @@ def migrate(entry):
|
||||||
'slug': entry['slug'],
|
'slug': entry['slug'],
|
||||||
# 'createdBy': entry['createdBy'],
|
# 'createdBy': entry['createdBy'],
|
||||||
# 'createdAt': date_parse(entry['createdAt']),
|
# 'createdAt': date_parse(entry['createdAt']),
|
||||||
'title': entry['title'], #.lower(),
|
'title': entry['title'].replace(' ', ' '), #.lower(),
|
||||||
'children': [],
|
'children': [],
|
||||||
'community' : Community.default_community.slug,
|
'community' : Community.default_community.slug,
|
||||||
'body' : entry.get('description')
|
'body' : entry.get('description')
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
topic = session.query(Topic).filter(Topic.slug == entry['slug']).first()
|
topic = session.query(Topic).filter(Topic.slug == topic_dict['slug']).first()
|
||||||
|
if not topic:
|
||||||
|
topic = session.query(Topic).filter(Topic.title == topic_dict['title']).first()
|
||||||
if not topic:
|
if not topic:
|
||||||
topic = Topic.create(**topic_dict)
|
topic = Topic.create(**topic_dict)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -23,15 +23,18 @@ def migrate(entry):
|
||||||
'slug': entry['slug'],
|
'slug': entry['slug'],
|
||||||
# 'createdBy': entry['createdBy'],
|
# 'createdBy': entry['createdBy'],
|
||||||
# 'createdAt': ts,
|
# 'createdAt': ts,
|
||||||
'title': entry['title'], # .lower(),
|
'title': entry['title'].replace(' ', ' '), # .lower(),
|
||||||
'children': [],
|
'children': [],
|
||||||
'community' : Community.default_community.slug,
|
'community' : Community.default_community.slug,
|
||||||
'body' : entry.get('description')
|
'body' : entry.get('description')
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
topic = session.query(Topic).filter(Topic.slug == entry['slug']).first()
|
topic = session.query(Topic).filter(Topic.slug == topic_dict['slug']).first()
|
||||||
if not topic: topic = Topic.create(**topic_dict)
|
if not topic:
|
||||||
|
topic = session.query(Topic).filter(Topic.title == topic_dict['title']).first()
|
||||||
|
if not topic:
|
||||||
|
topic = Topic.create(**topic_dict)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
raise e
|
raise e
|
||||||
|
|
Loading…
Reference in New Issue
Block a user