inventory_model.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from cgi import test
  2. import this
  3. from sqlalchemy import Column,Integer,String,Boolean,ForeignKey,Sequence,ForeignKeyConstraint
  4. import persistence
  5. __db_Base = persistence.get_db_base()
  6. class inventory_site(__db_Base):
  7. __tablename__ = "tInventory_sites"
  8. id = Column(Integer,Sequence('inventory_site_id_seq'), primary_key=True, nullable=False)
  9. name = Column(String(150))
  10. address = Column(String)
  11. gps_coordinates = Column(String)
  12. note = Column(String)
  13. tags = Column(String)
  14. contact_id = Column(Integer, ForeignKey('tInventory_contacts.id'))
  15. class inventory_item(__db_Base):
  16. __tablename__ = "tInventory_items"
  17. id = Column(Integer,Sequence('inventory_item_id_seq'), primary_key=True, nullable=False)
  18. name = Column(String(100), nullable=False)
  19. note = Column(String)
  20. brand = Column(String(50))
  21. wear_score = Column(Integer)
  22. type = Column(String(50))
  23. owned = Column(Boolean, default= True)
  24. tags = Column(String)
  25. custom_fields_json = Column(String)
  26. assigned = Column(Boolean, default= False)
  27. assign_date_epoch = Column(Integer)
  28. serial_number = Column(String)
  29. group_id = Column(Integer, ForeignKey('tInventory_groups.id',onupdate="cascade",ondelete="cascade"), nullable=True)
  30. contact_id = Column(Integer, ForeignKey('tInventory_contacts.id',onupdate="cascade",ondelete="cascade"), nullable=True)
  31. site_id = Column(Integer, ForeignKey('tInventory_sites.id',onupdate="cascade",ondelete="cascade"), nullable=True)
  32. class inventory_group(__db_Base):
  33. __tablename__ = "tInventory_groups"
  34. id = Column(Integer,Sequence('inventory_group_id_seq'), primary_key=True, nullable=False)
  35. name = Column(String(100), nullable=False)
  36. note = Column(String)
  37. class inventory_contact(__db_Base):
  38. __tablename__ = "tInventory_contacts"
  39. id = Column(Integer,Sequence('inventory_contact_id_seq'), primary_key=True, nullable=False)
  40. contact_person = Column(String(150))
  41. contact_mail = Column(String(100))
  42. contact_number = Column(String(100))
  43. note = Column(String)
  44. tags = Column(String)