X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-database.git/blobdiff_plain/d56b164dce1fecede76c87d09f49698a40eb7177..82ea287fbac5e9f6ab383a8fa8e3fc2bc538821e:/sipb_xen_database/models.py?ds=inline diff --git a/sipb_xen_database/models.py b/sipb_xen_database/models.py index 1090531..9fbf4dc 100644 --- a/sipb_xen_database/models.py +++ b/sipb_xen_database/models.py @@ -28,6 +28,7 @@ ctx = SessionContext(create_session) machine_table = Table('machines', meta, Column('machine_id', Integer, primary_key=True, nullable=False), Column('name', String, nullable=False), + Column('description', String, nullable=False), Column('memory', Integer, nullable=False), Column('owner', String, nullable=False), Column('contact', String, nullable=False), @@ -69,7 +70,7 @@ autoinstalls_table = Table('autoinstalls', meta, machine_access_table = Table('machine_access', meta, Column('machine_id', Integer, ForeignKey('machines.machine_id'), nullable=False, index=True), Column('user', String, nullable=False, index=True), - PrimaryKeyConstraint('machine_id', 'user')) + PrimaryKeyConstraint('machine_id', 'user', ondelete='CASCADE')) class Machine(object): def __repr__(self): @@ -103,7 +104,7 @@ assign_mapper(ctx, Machine, machine_table, properties={'nics': relation(NIC, backref="machine", lazy=False), 'disks': relation(Disk, backref="machine", lazy=False), 'type': relation(Type, lazy=False), - 'acl': relation(MachineAccess, backref="machine", lazy=False)}); + 'acl': relation(MachineAccess, backref="machine", lazy=False, passive_deletes=True, cascade="all, delete-orphan")}); assign_mapper(ctx, MachineAccess, machine_access_table) assign_mapper(ctx, NIC, nic_table) assign_mapper(ctx, Disk, disk_table)