[migractions] add sanity check in rename_relation_type stable
authorJulien Cristau <julien.cristau@logilab.fr>
Thu, 06 Mar 2014 18:41:23 +0100
branchstable
changeset 9698 737983d87497
parent 9697 d96b5e72717c
child 9699 990676d3f39f
[migractions] add sanity check in rename_relation_type If the relation is still present in the fs schema, we probably shouldn't be renaming it (because it's still in use somewhere, possibly in a different cube). Closes #3608172
server/migractions.py
--- a/server/migractions.py	Mon Apr 07 08:46:41 2014 +0000
+++ b/server/migractions.py	Thu Mar 06 18:41:23 2014 +0100
@@ -1099,12 +1099,19 @@
         if commit:
             self.commit()
 
-    def cmd_rename_relation_type(self, oldname, newname, commit=True):
+    def cmd_rename_relation_type(self, oldname, newname, commit=True, force=False):
         """rename an existing relation
 
         `oldname` is a string giving the name of the existing relation
         `newname` is a string giving the name of the renamed relation
+
+        If `force` is True, proceed even if `oldname` still appears in the fs schema
         """
+        if oldname in self.fs_schema and not force:
+            if not self.confirm('Relation %s is still present in the filesystem schema,'
+                                ' do you really want to drop it?' % oldname,
+                                default='n'):
+                raise SystemExit(1)
         self.cmd_add_relation_type(newname, commit=True)
         self.rqlexec('SET X %s Y WHERE X %s Y' % (newname, oldname),
                      ask_confirm=self.verbosity>=2)