migration-fixes
This commit is contained in:
parent
51c7f68ceb
commit
0cd6761dd3
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -145,3 +145,4 @@ migration/content/**/*.md
|
||||||
.DS_Store
|
.DS_Store
|
||||||
dump
|
dump
|
||||||
.vscode
|
.vscode
|
||||||
|
*.sql
|
|
@ -5,7 +5,7 @@ import json
|
||||||
from migration.utils import DateTimeEncoder
|
from migration.utils import DateTimeEncoder
|
||||||
|
|
||||||
def json_tables():
|
def json_tables():
|
||||||
print('[migration] unpack bson to migration/data/*.json')
|
print('[migration] unpack dump/discours/*.bson to migration/data/*.json')
|
||||||
data = {
|
data = {
|
||||||
"content_items": [],
|
"content_items": [],
|
||||||
"content_item_categories": [],
|
"content_item_categories": [],
|
||||||
|
@ -16,7 +16,7 @@ def json_tables():
|
||||||
}
|
}
|
||||||
for table in data.keys():
|
for table in data.keys():
|
||||||
lc = []
|
lc = []
|
||||||
with open('migration/data/'+table+'.bson', 'rb') as f:
|
with open('dump/discours/'+table+'.bson', 'rb') as f:
|
||||||
bs = f.read()
|
bs = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
base = 0
|
base = 0
|
||||||
|
@ -24,5 +24,5 @@ def json_tables():
|
||||||
base, d = bson.decode_document(bs, base)
|
base, d = bson.decode_document(bs, base)
|
||||||
lc.append(d)
|
lc.append(d)
|
||||||
data[table] = lc
|
data[table] = lc
|
||||||
open(os.getcwd() + '/dump/discours/'+table+'.json', 'w').write(json.dumps(lc,cls=DateTimeEncoder))
|
open(os.getcwd() + '/migration/data/'+table+'.json', 'w').write(json.dumps(lc,cls=DateTimeEncoder))
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,9 @@ import sqlalchemy
|
||||||
from orm import User, UserRating
|
from orm import User, UserRating
|
||||||
from orm.user import EmailSubscription
|
from orm.user import EmailSubscription
|
||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
from migration.html2text import html2text
|
|
||||||
from orm.base import local_session
|
from orm.base import local_session
|
||||||
|
|
||||||
def migrate(entry):
|
def migrate(entry):
|
||||||
|
|
||||||
if 'subscribedTo' in entry: del entry['subscribedTo']
|
if 'subscribedTo' in entry: del entry['subscribedTo']
|
||||||
email = entry['emails'][0]['address']
|
email = entry['emails'][0]['address']
|
||||||
user_dict = {
|
user_dict = {
|
||||||
|
|
|
@ -10,7 +10,7 @@ RESET_PWD_URL = environ.get("RESET_PWD_URL") or "https://localhost:8080/reset_pw
|
||||||
CONFIRM_EMAIL_URL = environ.get("CONFIRM_EMAIL_URL") or "https://new.discours.io"
|
CONFIRM_EMAIL_URL = environ.get("CONFIRM_EMAIL_URL") or "https://new.discours.io"
|
||||||
ERROR_URL_ON_FRONTEND = environ.get("ERROR_URL_ON_FRONTEND") or "https://new.discours.io"
|
ERROR_URL_ON_FRONTEND = environ.get("ERROR_URL_ON_FRONTEND") or "https://new.discours.io"
|
||||||
|
|
||||||
DB_URL = environ.get("DATABASE_URL") or environ.get("DB_URL") or "sqlite:///db.sqlite3"
|
DB_URL = environ.get("DATABASE_URL") or environ.get("DB_URL") or "postgres://localhost:5432" or "sqlite:///db.sqlite3"
|
||||||
JWT_ALGORITHM = "HS256"
|
JWT_ALGORITHM = "HS256"
|
||||||
JWT_SECRET_KEY = "8f1bd7696ffb482d8486dfbc6e7d16dd-secret-key"
|
JWT_SECRET_KEY = "8f1bd7696ffb482d8486dfbc6e7d16dd-secret-key"
|
||||||
JWT_LIFE_SPAN = 24 * 60 * 60 # seconds
|
JWT_LIFE_SPAN = 24 * 60 * 60 # seconds
|
||||||
|
|
Loading…
Reference in New Issue
Block a user