2015-09-08 05:59:59 +02:00
|
|
|
import logging
|
|
|
|
|
|
|
|
|
2015-09-04 22:22:02 +02:00
|
|
|
def migrate_db(db_dir, start, end):
|
|
|
|
current = start
|
2016-10-14 08:13:37 +02:00
|
|
|
while current < end:
|
|
|
|
if current == 1:
|
2018-02-12 19:33:48 +01:00
|
|
|
from lbrynet.database.migrator.migrate1to2 import do_migration
|
2017-05-10 17:30:36 +02:00
|
|
|
elif current == 2:
|
2018-02-12 19:33:48 +01:00
|
|
|
from lbrynet.database.migrator.migrate2to3 import do_migration
|
2017-07-26 19:48:58 +02:00
|
|
|
elif current == 3:
|
2018-02-12 19:33:48 +01:00
|
|
|
from lbrynet.database.migrator.migrate3to4 import do_migration
|
2017-12-07 00:27:42 +01:00
|
|
|
elif current == 4:
|
2018-02-12 19:33:48 +01:00
|
|
|
from lbrynet.database.migrator.migrate4to5 import do_migration
|
|
|
|
elif current == 5:
|
|
|
|
from lbrynet.database.migrator.migrate5to6 import do_migration
|
2018-03-27 20:58:29 +02:00
|
|
|
elif current == 6:
|
|
|
|
from lbrynet.database.migrator.migrate6to7 import do_migration
|
2018-05-08 19:51:02 +02:00
|
|
|
elif current == 7:
|
|
|
|
from lbrynet.database.migrator.migrate7to8 import do_migration
|
2018-05-16 02:44:30 +02:00
|
|
|
elif current == 8:
|
|
|
|
from lbrynet.database.migrator.migrate8to9 import do_migration
|
2016-10-14 08:13:37 +02:00
|
|
|
else:
|
2018-02-12 19:33:48 +01:00
|
|
|
raise Exception("DB migration of version {} to {} is not available".format(current,
|
|
|
|
current+1))
|
2018-03-27 20:58:29 +02:00
|
|
|
do_migration(db_dir)
|
2016-10-14 08:13:37 +02:00
|
|
|
current += 1
|
|
|
|
return None
|
2015-09-04 22:22:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
def run_migration_script():
|
|
|
|
import sys
|
2015-09-08 05:59:59 +02:00
|
|
|
log_format = "(%(asctime)s)[%(filename)s:%(lineno)s] %(funcName)s(): %(message)s"
|
|
|
|
logging.basicConfig(level=logging.DEBUG, format=log_format, filename="migrator.log")
|
|
|
|
sys.stdout = open("migrator.out.log", 'w')
|
|
|
|
sys.stderr = open("migrator.err.log", 'w')
|
|
|
|
migrate_db(sys.argv[1], int(sys.argv[2]), int(sys.argv[3]))
|
2016-11-28 20:23:10 +01:00
|
|
|
|
|
|
|
|
2015-09-08 05:59:59 +02:00
|
|
|
if __name__ == "__main__":
|
2016-10-14 08:13:37 +02:00
|
|
|
run_migration_script()
|