mirror of
https://git.osuv.de/m/gitea-mariadb-migration.git
synced 2024-05-12 03:55:05 +00:00
finish migration script
This commit is contained in:
12
migrate.py
12
migrate.py
@ -2,7 +2,12 @@
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
import MariaSQL
|
import MariaSQL
|
||||||
|
import hashlib
|
||||||
|
import binascii
|
||||||
|
import random
|
||||||
|
|
||||||
|
def GetRandomString(N):
|
||||||
|
return ''.join(random.choice("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") for _ in range(10))
|
||||||
|
|
||||||
def dict_factory(cursor, row):
|
def dict_factory(cursor, row):
|
||||||
d = {}
|
d = {}
|
||||||
@ -74,4 +79,11 @@ for table in tables:
|
|||||||
# https://github.com/go-gitea/gitea/blob/adf3f004b65135e9375ae60dfd0d9ecba340342e/models/migrations/v71.go#L43
|
# https://github.com/go-gitea/gitea/blob/adf3f004b65135e9375ae60dfd0d9ecba340342e/models/migrations/v71.go#L43
|
||||||
# https://github.com/go-gitea/gitea/pull/4331
|
# https://github.com/go-gitea/gitea/pull/4331
|
||||||
# TODO
|
# TODO
|
||||||
|
if this_table == 'two_factor' and 'scratch_token' in row:
|
||||||
|
ScratchSalt = GetRandomString(10)
|
||||||
|
raw_ScratchHash = hashlib.pbkdf2_hmac('sha256', row['scratch_token'].encode(), ScratchSalt.encode(), 100000)
|
||||||
|
ScratchHash = binascii.hexlify(raw_ScratchHash).decode('utf-8')
|
||||||
|
row.pop('scratch_token')
|
||||||
|
row['scratch_salt'] = ScratchSalt
|
||||||
|
row['scratch_hash'] = ScratchHash
|
||||||
output = MARIADB.insert(this_table, row)
|
output = MARIADB.insert(this_table, row)
|
||||||
|
Reference in New Issue
Block a user