Commit 6df8af54 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Delete obsolete script mv_dbschema_0815.

parent c1d69d4c
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" NAME
mv_dbschema_0815
SYNOPSIS
Modify the database schema for all existing database.
DESCRIPTION
In the release 0.8.15, the database schema evolved.
* Add the field synonyms in collaboration, countries
and publishers
* Remove the obsolete table application.
* Remove the obsolete field harvesters.ratio
The script scan on all the database defined in models
and modify the database.
OPTIONS
-h, --help
Display the help and exit.
EXAMPLE
> cd ...track_publications/scripts
> ./mb_dbschema_0815.py ../models/_dev_pro.py
AUTHOR
R. Le Gac -- Oct 2015
"""
if __name__ == '__main__':
import argparse
import os
import re
import subprocess
import sys
REG_MYSQL = re.compile(r"mysql://(\w+):(\w+)@([\w\.]+)/(\w+)")
parser = argparse.ArgumentParser()
parser.add_argument("path",
help="path to the configuration file containing the DBURIS.")
ARGS = parser.parse_args()
#
# Get the DBURIS
#
execfile(ARGS.path)
#
# iterate on the databases
#
for name, value in DBURIS.iteritems():
rep = raw_input('\nModify the database "%s" [y/N]: ' % name)
if rep != "y":
continue
match = REG_MYSQL.match(value)
if not match:
print "Can't decode the URIs !!!"
continue
cmd = ["/usr/bin/mysql",
"-u", match.group(1),
"-p%s" % match.group(2),
"-h", match.group(3),
match.group(4),
"< dbschema-0815.sql"]
ret = subprocess.call(" ".join(cmd), shell=True)
if ret == 0:
print "database schema modified."
# exit gently
sys.exit(0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment