formatted

This commit is contained in:
2021-08-21 02:17:15 +03:00
parent 90c552a8f3
commit 06c8d9c66b
4 changed files with 296 additions and 300 deletions

View File

@@ -10,10 +10,10 @@ pipenv install -r requirements.txt
## Using
Put the unpacked mongodump to the `data` folder and operate with `pipenv shell && python`
Put the unpacked mongodump to the `data` folder and operate with
`pipenv shell && python`
1. get old data jsons
1. get old data jsons
```py
import bson2json
@@ -23,19 +23,16 @@ bson2json.json_tables() # creates all the needed data json from bson mongodump
2. migrate users
```py
import json
from migrations.users import migrate
```sh
pipenv run python migrate.py users
```
Note: this will create db entries and it is not tolerant to existed unique email.
data = json.loads(open('data/users.json').read())
newdata = {}
3. then topics and shouts
for u in data:
try:
newdata[u['_id']] = migrate(u)
except:
print('FAIL!')
print(u)
```sh
pipenv run python migrate.py topics
pipenv run python migrate.py shouts
```
```
Now you got the *.dict.json files which contain all the data with old and new(!) ids.