fix(add): fixed #199, foreign key constraint failed
This commit is contained in:
@@ -33,11 +33,7 @@ class BrickMinifigure(RebrickableMinifigure):
|
||||
)
|
||||
)
|
||||
|
||||
if not refresh:
|
||||
# Insert into database
|
||||
self.insert(commit=False)
|
||||
|
||||
# Load the inventory
|
||||
# Load the inventory (needed to count parts for rebrickable record)
|
||||
if not BrickPartList.download(
|
||||
socket,
|
||||
self.brickset,
|
||||
@@ -46,9 +42,14 @@ class BrickMinifigure(RebrickableMinifigure):
|
||||
):
|
||||
return False
|
||||
|
||||
# Insert the rebrickable set into database (after counting parts)
|
||||
# Insert the rebrickable minifigure into database first (parent record)
|
||||
# This must happen before inserting into bricktracker_minifigures due to FK constraint
|
||||
self.insert_rebrickable()
|
||||
|
||||
if not refresh:
|
||||
# Insert into bricktracker_minifigures database (child record)
|
||||
self.insert(commit=False)
|
||||
|
||||
except Exception as e:
|
||||
socket.fail(
|
||||
message='Error while importing minifigure {figure} from {set}: {error}'.format( # noqa: E501
|
||||
|
||||
@@ -62,13 +62,14 @@ class BrickPart(RebrickablePart):
|
||||
)
|
||||
)
|
||||
|
||||
if not refresh:
|
||||
# Insert into database
|
||||
self.insert(commit=False)
|
||||
|
||||
# Insert the rebrickable set into database
|
||||
# Insert the rebrickable part into database first (parent record)
|
||||
# This must happen before inserting into bricktracker_parts due to FK constraint
|
||||
self.insert_rebrickable()
|
||||
|
||||
if not refresh:
|
||||
# Insert into bricktracker_parts database (child record)
|
||||
self.insert(commit=False)
|
||||
|
||||
except Exception as e:
|
||||
socket.fail(
|
||||
message='Error while importing part {part} from {kind} {identifier}: {error}'.format( # noqa: E501
|
||||
|
||||
Reference in New Issue
Block a user