Conditionalize populating the types table in invirt-database-tables
[invirt/packages/invirt-database.git] / invirt-database-tables
index 695b04f..78c7ab4 100755 (executable)
@@ -14,10 +14,12 @@ def create():
     database.meta.create_all()
     session = database.session()
     session.begin()
-    session.save(database.Type(type_id='linux-hvm', description='HVM',
-                               hvm='t', apic='t', acpi='t', pae='t'))
-    session.save(database.Type(type_id='linux', description='ParaVM',
-                               hvm='f', apic='f', acpi='f', pae='f'))
+    if not database.Type.query.get('linux-hvm'):
+        session.save(database.Type(type_id='linux-hvm', description='HVM',
+                                   hvm='t', apic='t', acpi='t', pae='t'))
+    if not database.Type.query.get('linux'):
+        session.save(database.Type(type_id='linux', description='ParaVM',
+                                   hvm='f', apic='f', acpi='f', pae='f'))
     session.commit()
 
 database.connect()