aboutsummaryrefslogtreecommitdiff
path: root/rpkid
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2014-04-03 13:54:11 +0000
committerRob Austein <sra@hactrn.net>2014-04-03 13:54:11 +0000
commit40eb72d672b926b8e950e2924762deea79c13eb5 (patch)
tree6fec18b839beed47163f822bee862c41f9a9af9f /rpkid
parent40a78d8c81256921645db88bd92c4cb70a3d3297 (diff)
Remove deferred-upgrade stuff, we don't need it at the moment, it's
fragile, and this may not really be the right approach anyway. svn path=/branches/tk671/; revision=5744
Diffstat (limited to 'rpkid')
-rwxr-xr-xrpkid/rpki-sql-setup58
1 files changed, 4 insertions, 54 deletions
diff --git a/rpkid/rpki-sql-setup b/rpkid/rpki-sql-setup
index 1863622a..40a78532 100755
--- a/rpkid/rpki-sql-setup
+++ b/rpkid/rpki-sql-setup
@@ -73,11 +73,10 @@ class UserDB(object):
"""
Class to wrap MySQL access parameters for a particular database.
- NB: The SQL definitions for the upgrade_version and deferred_upgrade
- tables are embedded in this class rather than being declared in any
- of the .sql files. This is deliberate: nothing but the upgrade
- system should ever touch these tables, and it's simpler to keep
- everything in one place.
+ NB: The SQL definitions for the upgrade_version table is embedded in
+ this class rather than being declared in any of the .sql files.
+ This is deliberate: nothing but the upgrade system should ever touch
+ this table, and it's simpler to keep everything in one place.
We have to be careful about SQL commits here, because CREATE TABLE
implies an automatic commit. So presence of the magic table per se
@@ -91,15 +90,6 @@ class UserDB(object):
) ENGINE=InnoDB
"""
- deferred_upgrade_table_schema = """
- CREATE TABLE deferred_upgrade (
- id SERIAL NOT NULL,
- script TEXT NOT NULL,
- added DATETIME NOT NULL,
- version TEXT
- ) ENGINE=InnoDB
- """
-
def __init__(self, name):
self.name = name
self.database = cfg.get("sql-database", section = name)
@@ -161,35 +151,6 @@ class UserDB(object):
lines.append(line)
return [statement.strip() for statement in " ".join(lines).rstrip(";").split(";") if statement.strip()]
- def add_deferred_upgrade(self, script, version = None):
- insert = "INSERT deferred_upgrade (script, added, version) VALUES (%s, %s, %s)"
- values = (script, datetime.datetime.now(), version)
- try:
- self.cur.execute(insert, values)
- except _mysql_exceptions.ProgrammingError, e:
- if e.args[0] != ER_NO_SUCH_TABLE:
- raise
- log("Creating deferred_upgrade table in %s" % self.name)
- self.cur.execute(self.deferred_upgrade_table_schema)
- self.cur.execute(insert, values)
- self.db.commit()
-
- @property
- def deferred_upgrades(self):
- try:
- while True:
- self.cur.execute("SELECT id, script FROM deferred_upgrade ORDER BY id LIMIT 1")
- row = self.cur.fetchone()
- if row is None:
- break
- rowid, script = row
- yield script
- self.cur.execute("DELETE FROM deferred_upgrade WHERE id = %s", (rowid,))
- self.db.commit()
- except _mysql_exceptions.ProgrammingError, e:
- if e.args[0] != ER_NO_SUCH_TABLE:
- raise
-
class Version(object):
"""
@@ -295,14 +256,6 @@ def do_apply_upgrades(name):
db.version = current_version
db.close()
-def do_apply_deferred_upgrades(name):
- db = UserDB(name)
- db.open()
- for i, script in enumerate(db.deferred_upgrades):
- log("Running deferred upgrade #%i for %s" % (i, name))
- exec script
- db.close()
-
def log(text):
if args.verbose:
print "#", text
@@ -342,9 +295,6 @@ group.add_argument("--create-if-missing",
group.add_argument("--apply-upgrades",
action = "store_const", dest = "dispatch", const = do_apply_upgrades,
help = "apply upgrade scripts to existing databases")
-group.add_argument("--apply-deferred-upgrades",
- action = "store_const", dest = "dispatch", const = do_apply_deferred_upgrades,
- help = "apply upgrade scripts that were deferred until daemon startup")
parser.set_defaults(dispatch = do_create_if_missing)
args = parser.parse_args()