diff --git a/gns3server/db/models/computes.py b/gns3server/db/models/computes.py index 5fd1cf56..71043d88 100644 --- a/gns3server/db/models/computes.py +++ b/gns3server/db/models/computes.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from sqlalchemy import Column, String +from sqlalchemy import Column, String, Integer from .base import BaseTable, GUID @@ -28,6 +28,6 @@ class Compute(BaseTable): name = Column(String, index=True) protocol = Column(String) host = Column(String) - port = Column(String) + port = Column(Integer) user = Column(String) password = Column(String) diff --git a/gns3server/db/models/images.py b/gns3server/db/models/images.py index 8e933f5f..9db3a682 100644 --- a/gns3server/db/models/images.py +++ b/gns3server/db/models/images.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from sqlalchemy import Table, Column, String, Integer, ForeignKey, BigInteger +from sqlalchemy import Table, Column, String, ForeignKey, BigInteger from sqlalchemy.orm import relationship from .base import Base, BaseTable, GUID @@ -24,7 +24,7 @@ from .base import Base, BaseTable, GUID image_template_link = Table( "images_templates_link", Base.metadata, - Column("image_id", Integer, ForeignKey("images.id", ondelete="CASCADE")), + Column("image_id", BigInteger, ForeignKey("images.image_id", ondelete="CASCADE")), Column("template_id", GUID, ForeignKey("templates.template_id", ondelete="CASCADE")) ) @@ -33,11 +33,11 @@ class Image(BaseTable): __tablename__ = "images" - id = Column(Integer, primary_key=True, autoincrement=True) - filename = Column(String) + image_id = Column(BigInteger, primary_key=True, autoincrement=True) + filename = Column(String, index=True) + path = Column(String, unique=True) image_type = Column(String) image_size = Column(BigInteger) - path = Column(String, unique=True, index=True) - checksum = Column(String) + checksum = Column(String, index=True) checksum_algorithm = Column(String) templates = relationship("Template", secondary=image_template_link, back_populates="images") diff --git a/gns3server/db/models/templates.py b/gns3server/db/models/templates.py index 71515271..7b344735 100644 --- a/gns3server/db/models/templates.py +++ b/gns3server/db/models/templates.py @@ -33,9 +33,9 @@ class Template(BaseTable): default_name_format = Column(String) symbol = Column(String) builtin = Column(Boolean, default=False) - compute_id = Column(String) usage = Column(String) template_type = Column(String) + compute_id = Column(String) images = relationship("Image", secondary=image_template_link, back_populates="templates") __mapper_args__ = {