Explorar el Código

Add a new method __purge_db() to the migration handler

Yann Weber hace 9 años
padre
commit
39401184d0
Se han modificado 2 ficheros con 30 adiciones y 2 borrados
  1. 26
    2
      EditorialModel/migrationhandler/mysql.py
  2. 4
    0
      README.md

+ 26
- 2
EditorialModel/migrationhandler/mysql.py Ver fichero

@@ -52,6 +52,28 @@ class MysqlMigrationHandler(EditorialModel.migrationhandler.dummy.DummyMigration
52 52
         self._create_default_tables(self.drop_if_exists)
53 53
         pass
54 54
     
55
+    ## @brief Delete all table created by the MH
56
+    # @param model Model : the Editorial model
57
+    def __purge_db(self, model):
58
+        for uid in [c.uid for c in model.components('EmClass')]:
59
+            try:
60
+                self.delete_emclass_table(model, uid)
61
+            except pymysql.err.InternalError as e:
62
+                print(e)
63
+        
64
+        for tname in [ MySQL.get_r2t2table_name(f.em_class.name, model.component(f.rel_to_type_id).name) for f in model.components('EmField') if f.fieldtype == 'rel2type' ]:
65
+            try:
66
+                self._query("DROP TABLE %s;"%tname)
67
+            except pymysql.err.InternalError as e:
68
+                print(e)
69
+
70
+        for tname in [ MySQL.relations_table_name, MySQL.objects_table_name ]:
71
+            try:
72
+                self._query("DROP TABLE %s;"%tname)
73
+            except pymysql.err.InternalError as e:
74
+                print(e)
75
+        
76
+
55 77
     ## @brief Modify the db given an EM change
56 78
     # 
57 79
     # @param em model : The EditorialModel.model object to provide the global context
@@ -185,13 +207,15 @@ class MysqlMigrationHandler(EditorialModel.migrationhandler.dummy.DummyMigration
185 207
     # @param em Model : A Model instance
186 208
     # @param uid int : An EmField uid
187 209
     def delete_emclass_table(self, em, uid):
188
-        emclass = emcomponent(uid)
210
+        emclass = em.component(uid)
189 211
         if not isinstance(emclass, EditorialModel.classes.EmClass):
190 212
             raise ValueError("The give uid is not an EmClass uid")
191
-        tname = self.datasource.escape_idname(self._emclass2table_name(emclass))
213
+        tname = self._emclass2table_name(emclass)
192 214
         # Delete the table triggers to prevent errors
193 215
         self._generate_triggers(tname, dict())
194 216
 
217
+        tname = self.datasource.escape_idname(tname)
218
+
195 219
         self._query("""DROP TABLE {table_name};""".format(table_name = tname))
196 220
 
197 221
     ## @brief Given an EmField delete the corresponding column

+ 4
- 0
README.md Ver fichero

@@ -5,6 +5,10 @@ First test installation :
5 5
 ** install dependencies
6 6
   pip install -r requirements.txt
7 7
 
8
+** Doxygen generation
9
+  Dependencies : doxygen graphviz doxypy
10
+  Generation : run doxygen in the root folder (where the Doxyfile is)
11
+
8 12
 ** create local config in settings.py
9 13
 Copy settings.py.example to settings.py, change the conf to your local settings
10 14
 

Loading…
Cancelar
Guardar