mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-13 20:08:55 +00:00
Sqlite doesn't allow BigInteger to be used as an primary key with autoincrement
This commit is contained in:
parent
d8bceaad5d
commit
b683659d21
@ -124,7 +124,7 @@ async def delete_image(
|
||||
if not image:
|
||||
raise ControllerNotFoundError(f"Image '{image_path}' not found")
|
||||
|
||||
if await images_repo.get_image_templates(image.id):
|
||||
if await images_repo.get_image_templates(image.image_id):
|
||||
raise ControllerError(f"Image '{image_path}' is used by one or more templates")
|
||||
|
||||
try:
|
||||
|
@ -15,7 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from sqlalchemy import Table, Column, String, ForeignKey, BigInteger
|
||||
from sqlalchemy import Table, Column, String, ForeignKey, BigInteger, Integer
|
||||
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", BigInteger, ForeignKey("images.image_id", ondelete="CASCADE")),
|
||||
Column("image_id", Integer, ForeignKey("images.image_id", ondelete="CASCADE")),
|
||||
Column("template_id", GUID, ForeignKey("templates.template_id", ondelete="CASCADE"))
|
||||
)
|
||||
|
||||
@ -33,7 +33,7 @@ class Image(BaseTable):
|
||||
|
||||
__tablename__ = "images"
|
||||
|
||||
image_id = Column(BigInteger, primary_key=True, autoincrement=True)
|
||||
image_id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
filename = Column(String, index=True)
|
||||
path = Column(String, unique=True)
|
||||
image_type = Column(String)
|
||||
|
@ -75,7 +75,7 @@ class ImagesRepository(BaseRepository):
|
||||
|
||||
query = select(models.Template).\
|
||||
join(models.Template.images).\
|
||||
filter(models.Image.id == image_id)
|
||||
filter(models.Image.image_id == image_id)
|
||||
|
||||
result = await self._db_session.execute(query)
|
||||
return result.scalars().all()
|
||||
@ -86,7 +86,7 @@ class ImagesRepository(BaseRepository):
|
||||
"""
|
||||
|
||||
db_image = models.Image(
|
||||
id=None,
|
||||
image_id=None,
|
||||
filename=image_name,
|
||||
image_type=image_type,
|
||||
image_size=image_size,
|
||||
|
Loading…
Reference in New Issue
Block a user