summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2013-01-29 09:38:45 -0600
committerTim Laszlo <tim.laszlo@gmail.com>2013-01-29 09:39:24 -0600
commitd7d90ca8626cae96d5aad3aac81967fa31cf7c4f (patch)
tree561d39ac30beb819826007e5b4f6be45346a6b12
parente74a45e719cbb5445720a32c8a3ec41b306e2667 (diff)
downloadbcfg2-d7d90ca8626cae96d5aad3aac81967fa31cf7c4f.tar.gz
bcfg2-d7d90ca8626cae96d5aad3aac81967fa31cf7c4f.tar.bz2
bcfg2-d7d90ca8626cae96d5aad3aac81967fa31cf7c4f.zip
add old schema to migration
-rw-r--r--src/lib/Bcfg2/Server/Reports/updatefix.py5
-rw-r--r--src/lib/Bcfg2/settings.py2
-rwxr-xr-xtools/upgrade/1.3/migrate_dbstats.py9
3 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/Bcfg2/Server/Reports/updatefix.py b/src/lib/Bcfg2/Server/Reports/updatefix.py
index b377806ab..cb131c29d 100644
--- a/src/lib/Bcfg2/Server/Reports/updatefix.py
+++ b/src/lib/Bcfg2/Server/Reports/updatefix.py
@@ -80,6 +80,9 @@ def _populate_interaction_entry_counts():
cursor.close()
+def update_noop():
+ return True
+
# be sure to test your upgrade query before reflecting the change in the models
# the list of function and sql command to do should go here
_fixes = [_merge_database_table_entries,
@@ -103,6 +106,8 @@ _fixes = [_merge_database_table_entries,
_interactions_constraint_or_idx,
'alter table reports_reason add is_binary bool NOT NULL default False;',
'alter table reports_reason add is_sensitive bool NOT NULL default False;',
+ update_noop, #_remove_table_column('reports_interaction', 'client_version'),
+ "alter table reports_reason add unpruned varchar(1280) not null default 'N/A';",
]
# this will calculate the last possible version of the database
diff --git a/src/lib/Bcfg2/settings.py b/src/lib/Bcfg2/settings.py
index 190bdff58..9e6a815c7 100644
--- a/src/lib/Bcfg2/settings.py
+++ b/src/lib/Bcfg2/settings.py
@@ -136,6 +136,8 @@ if HAS_SOUTH:
'south',
'Bcfg2.Reporting',
)
+if 'BCFG2_LEGACY_MODELS' in os.environ:
+ INSTALLED_APPS += ('Bcfg2.Server.Reports.reports',)
# Imported from Bcfg2.Server.Reports
MEDIA_ROOT = ''
diff --git a/tools/upgrade/1.3/migrate_dbstats.py b/tools/upgrade/1.3/migrate_dbstats.py
index 15bd328f9..69d9514df 100755
--- a/tools/upgrade/1.3/migrate_dbstats.py
+++ b/tools/upgrade/1.3/migrate_dbstats.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import os
+os.environ['BCFG2_LEGACY_MODELS'] = '1'
os.environ['DJANGO_SETTINGS_MODULE'] = 'Bcfg2.settings'
import sys
@@ -217,6 +218,14 @@ def migrate_stage1():
def _restructure():
"""major restructure of reporting data"""
+ # run any migrations from the previous schema
+ try:
+ from Bcfg2.Server.Reports.updatefix import update_database
+ update_database()
+ except:
+ logger.error("Failed to run legacy schema updates", exc_info=1)
+ return False
+
# try to avoid dangling transactions
if not migrate_stage1():
return