Skip to content

Commit fe5d324

Browse files
committed
foreign keys named wrong
1 parent 82a7fe5 commit fe5d324

1 file changed

Lines changed: 54 additions & 34 deletions

File tree

src/murfey/util/db.py

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ class CLEMImageSeries(SQLModel, table=True): # type: ignore
256256
data_collection_group: Optional["DataCollectionGroup"] = Relationship(
257257
back_populates="clem_image_series"
258258
)
259-
dcg_id: Optional[int] = Field(foreign_key="datacollectiongroup.id", default=None)
259+
dcg_id: Optional[int] = Field(
260+
foreign_key="datacollectiongroup.dataCollectionGroupId", default=None
261+
)
260262
dcg_name: Optional[str] = Field(default=None)
261263

262264
# Link to grid squares
@@ -458,7 +460,7 @@ class DataCollectionGroup(SQLModel, table=True): # type: ignore
458460

459461
class NotificationParameter(SQLModel, table=True): # type: ignore
460462
id: Optional[int] = Field(default=None, primary_key=True)
461-
dcg_id: int = Field(foreign_key="datacollectiongroup.id")
463+
dcg_id: int = Field(foreign_key="datacollectiongroup.dataCollectionGroupId")
462464
name: str
463465
min_value: float
464466
max_value: float
@@ -492,7 +494,7 @@ class DataCollection(SQLModel, table=True): # type: ignore
492494
)
493495
tag: str = Field(primary_key=True)
494496
dcg_id: int = Field(
495-
foreign_key="datacollectiongroup.id",
497+
foreign_key="datacollectiongroup.dataCollectionGroupId",
496498
alias="dataCollectionGroupId",
497499
sa_column_kwargs={"name": "dataCollectionGroupId"},
498500
)
@@ -522,7 +524,7 @@ class ProcessingJob(SQLModel, table=True): # type: ignore
522524
)
523525
recipe: str = Field(primary_key=True)
524526
dc_id: int = Field(
525-
foreign_key="datacollection.id",
527+
foreign_key="datacollection.dataCollectionId",
526528
alias="dataCollectionId",
527529
sa_column_kwargs={"name": "dataCollectionId"},
528530
)
@@ -590,14 +592,16 @@ class PreprocessStash(SQLModel, table=True): # type: ignore
590592
class SelectionStash(SQLModel, table=True): # type: ignore
591593
id: Optional[int] = Field(default=None, primary_key=True)
592594
class_selection_score: float
593-
pj_id: int = Field(foreign_key="processingjob.id")
595+
pj_id: int = Field(foreign_key="processingjob.processingJobId")
594596
processing_job: Optional[ProcessingJob] = Relationship(
595597
back_populates="selection_stash"
596598
)
597599

598600

599601
class TomographyProcessingParameters(SQLModel, table=True): # type: ignore
600-
dcg_id: int = Field(primary_key=True, foreign_key="datacollectiongroup.id")
602+
dcg_id: int = Field(
603+
primary_key=True, foreign_key="datacollectiongroup.dataCollectionGroupId"
604+
)
601605
pixel_size: float
602606
dose_per_frame: float
603607
frame_count: int
@@ -620,7 +624,7 @@ class AutoProcProgram(SQLModel, table=True): # type: ignore
620624
sa_column_kwargs={"name": "autoProcProgramId"},
621625
)
622626
pj_id: int = Field(
623-
foreign_key="processingjob.id",
627+
foreign_key="processingjob.processingJobId",
624628
alias="processingJobId",
625629
sa_column_kwargs={"name": "processingJobId"},
626630
)
@@ -650,7 +654,7 @@ class AutoProcProgram(SQLModel, table=True): # type: ignore
650654

651655
class MurfeyLedger(SQLModel, table=True): # type: ignore
652656
id: Optional[int] = Field(primary_key=True, default=None)
653-
app_id: int = Field(foreign_key="autoprocprogram.id")
657+
app_id: int = Field(foreign_key="autoprocprogram.autoProcProgramId")
654658
auto_proc_program: Optional[AutoProcProgram] = Relationship(
655659
back_populates="murfey_ids"
656660
)
@@ -704,7 +708,9 @@ class GridSquare(SQLModel, table=True): # type: ignore
704708
foil_holes: List["FoilHole"] = Relationship(
705709
back_populates="grid_square", sa_relationship_kwargs={"cascade": "delete"}
706710
)
707-
atlas_id: Optional[int] = Field(foreign_key="datacollectiongroup.id")
711+
atlas_id: Optional[int] = Field(
712+
foreign_key="datacollectiongroup.dataCollectionGroupId"
713+
)
708714
scaled_pixel_size: Optional[float] = None
709715
pixel_location_x: Optional[int] = None
710716
pixel_location_y: Optional[int] = None
@@ -777,7 +783,9 @@ class SearchMap(SQLModel, table=True): # type: ignore
777783
tilt_series: List["TiltSeries"] = Relationship(
778784
back_populates="search_map", sa_relationship_kwargs={"cascade": "delete"}
779785
)
780-
atlas_id: Optional[int] = Field(foreign_key="datacollectiongroup.id")
786+
atlas_id: Optional[int] = Field(
787+
foreign_key="datacollectiongroup.dataCollectionGroupId"
788+
)
781789
scaled_pixel_size: Optional[float] = None
782790
pixel_location_x: Optional[int] = None
783791
pixel_location_y: Optional[int] = None
@@ -799,7 +807,7 @@ class Movie(SQLModel, table=True): # type: ignore
799807
sa_column_kwargs={"name": "movieId"},
800808
)
801809
data_collection_id: Optional[int] = Field(
802-
foreign_key="datacollection.id",
810+
foreign_key="datacollection.dataCollectionId",
803811
alias="dataCollectionId",
804812
sa_column_kwargs={"name": "dataCollectionId"},
805813
)
@@ -821,7 +829,7 @@ class Movie(SQLModel, table=True): # type: ignore
821829

822830
class CtfParameters(SQLModel, table=True): # type: ignore
823831
id: Optional[int] = Field(default=None, primary_key=True)
824-
pj_id: int = Field(foreign_key="processingjob.id")
832+
pj_id: int = Field(foreign_key="processingjob.processingJobId")
825833
micrographs_file: str
826834
coord_list_file: str
827835
extract_file: str
@@ -838,7 +846,7 @@ class CtfParameters(SQLModel, table=True): # type: ignore
838846

839847
class TomogramPicks(SQLModel, table=True): # type: ignore
840848
tomogram: str = Field(primary_key=True)
841-
pj_id: int = Field(foreign_key="processingjob.id")
849+
pj_id: int = Field(foreign_key="processingjob.processingJobId")
842850
cbox_3d: str
843851
particle_count: int
844852
tomogram_pixel_size: float
@@ -849,15 +857,15 @@ class TomogramPicks(SQLModel, table=True): # type: ignore
849857

850858
class ParticleSizes(SQLModel, table=True): # type: ignore
851859
id: Optional[int] = Field(default=None, primary_key=True)
852-
pj_id: int = Field(foreign_key="processingjob.id")
860+
pj_id: int = Field(foreign_key="processingjob.processingJobId")
853861
particle_size: float
854862
processing_job: Optional[ProcessingJob] = Relationship(
855863
back_populates="particle_sizes"
856864
)
857865

858866

859867
class SPARelionParameters(SQLModel, table=True): # type: ignore
860-
pj_id: int = Field(primary_key=True, foreign_key="processingjob.id")
868+
pj_id: int = Field(primary_key=True, foreign_key="processingjob.processingJobId")
861869
angpix: float
862870
dose_per_frame: float
863871
gain_ref: Optional[str]
@@ -877,7 +885,7 @@ class SPARelionParameters(SQLModel, table=True): # type: ignore
877885

878886

879887
class ClassificationFeedbackParameters(SQLModel, table=True): # type: ignore
880-
pj_id: int = Field(primary_key=True, foreign_key="processingjob.id")
888+
pj_id: int = Field(primary_key=True, foreign_key="processingjob.processingJobId")
881889
estimate_particle_diameter: bool = True
882890
hold_class2d: bool = False
883891
rerun_class2d: bool = False
@@ -899,7 +907,7 @@ class ClassificationFeedbackParameters(SQLModel, table=True): # type: ignore
899907

900908
class Class2DParameters(SQLModel, table=True): # type: ignore
901909
particles_file: str = Field(primary_key=True)
902-
pj_id: int = Field(primary_key=True, foreign_key="processingjob.id")
910+
pj_id: int = Field(primary_key=True, foreign_key="processingjob.processingJobId")
903911
murfey_id: int = Field(foreign_key="murfeyledger.id")
904912
class2d_dir: str
905913
batch_size: int
@@ -917,15 +925,15 @@ class Class2D(SQLModel, table=True): # type: ignore
917925
particles_file: str = Field(
918926
primary_key=True,
919927
)
920-
pj_id: int = Field(primary_key=True, foreign_key="processingjob.id")
928+
pj_id: int = Field(primary_key=True, foreign_key="processingjob.processingJobId")
921929
murfey_id: int = Field(foreign_key="murfeyledger.id")
922930
processing_job: Optional[ProcessingJob] = Relationship(back_populates="class2ds")
923931
murfey_ledger: Optional[MurfeyLedger] = Relationship(back_populates="class2ds")
924932

925933

926934
class Class3DParameters(SQLModel, table=True): # type: ignore
927935
particles_file: str = Field(primary_key=True)
928-
pj_id: int = Field(primary_key=True, foreign_key="processingjob.id")
936+
pj_id: int = Field(primary_key=True, foreign_key="processingjob.processingJobId")
929937
murfey_id: int = Field(foreign_key="murfeyledger.id")
930938
class3d_dir: str
931939
batch_size: int
@@ -945,7 +953,7 @@ class Class3DParameters(SQLModel, table=True): # type: ignore
945953
class Class3D(SQLModel, table=True): # type: ignore
946954
class_number: int = Field(primary_key=True)
947955
particles_file: str = Field(primary_key=True)
948-
pj_id: int = Field(primary_key=True, foreign_key="processingjob.id")
956+
pj_id: int = Field(primary_key=True, foreign_key="processingjob.processingJobId")
949957
murfey_id: int = Field(foreign_key="murfeyledger.id")
950958
# class3d_parameters: Optional[Class3DParameters] = Relationship(
951959
# back_populates="class3ds"
@@ -957,7 +965,7 @@ class Class3D(SQLModel, table=True): # type: ignore
957965
class RefineParameters(SQLModel, table=True): # type: ignore
958966
tag: str = Field(primary_key=True)
959967
refine_dir: str = Field(primary_key=True)
960-
pj_id: int = Field(primary_key=True, foreign_key="processingjob.id")
968+
pj_id: int = Field(primary_key=True, foreign_key="processingjob.processingJobId")
961969
murfey_id: int = Field(foreign_key="murfeyledger.id")
962970
class3d_dir: str
963971
class_number: int
@@ -973,15 +981,15 @@ class RefineParameters(SQLModel, table=True): # type: ignore
973981
class Refine3D(SQLModel, table=True): # type: ignore
974982
tag: str = Field(primary_key=True)
975983
refine_dir: str = Field(primary_key=True)
976-
pj_id: int = Field(primary_key=True, foreign_key="processingjob.id")
984+
pj_id: int = Field(primary_key=True, foreign_key="processingjob.processingJobId")
977985
murfey_id: int = Field(foreign_key="murfeyledger.id")
978986
processing_job: Optional[ProcessingJob] = Relationship(back_populates="refine3ds")
979987
murfey_ledger: Optional[MurfeyLedger] = Relationship(back_populates="refine3ds")
980988

981989

982990
class BFactorParameters(SQLModel, table=True): # type: ignore
983991
project_dir: str = Field(primary_key=True)
984-
pj_id: int = Field(primary_key=True, foreign_key="processingjob.id")
992+
pj_id: int = Field(primary_key=True, foreign_key="processingjob.processingJobId")
985993
batch_size: int
986994
refined_grp_uuid: int
987995
refined_class_uuid: int
@@ -993,15 +1001,19 @@ class BFactorParameters(SQLModel, table=True): # type: ignore
9931001

9941002
class BFactors(SQLModel, table=True): # type: ignore
9951003
bfactor_directory: str = Field(primary_key=True)
996-
pj_id: int = Field(primary_key=True, foreign_key="processingjob.id")
1004+
pj_id: int = Field(primary_key=True, foreign_key="processingjob.processingJobId")
9971005
number_of_particles: int
9981006
resolution: float
9991007

10001008

10011009
class MotionCorrection(SQLModel, table=True): # type: ignore
10021010
motionCorrectionId: int = Field(primary_key=True, unique=True)
1003-
dataCollectionId: Optional[int] = Field(foreign_key="datacollection.id")
1004-
autoProcProgramId: Optional[int] = Field(foreign_key="autoprocprogram.id")
1011+
dataCollectionId: Optional[int] = Field(
1012+
foreign_key="datacollection.dataCollectionId"
1013+
)
1014+
autoProcProgramId: Optional[int] = Field(
1015+
foreign_key="autoprocprogram.autoProcProgramId"
1016+
)
10051017
imageNumber: Optional[int] = None
10061018
firstFrame: Optional[int] = None
10071019
lastFrame: Optional[int] = None
@@ -1017,7 +1029,7 @@ class MotionCorrection(SQLModel, table=True): # type: ignore
10171029
fftFullPath: Optional[str] = None
10181030
fftCorrectedFullPath: Optional[str] = None
10191031
comments: Optional[str] = None
1020-
movieId: Optional[int] = Field(foreign_key="movie.murfey_id")
1032+
movieId: Optional[int] = Field(foreign_key="movie.movieId")
10211033
auto_proc_program: Optional["AutoProcProgram"] = Relationship(
10221034
back_populates="motion_correction"
10231035
)
@@ -1039,7 +1051,9 @@ class CTF(SQLModel, table=True): # type: ignore
10391051
motionCorrectionId: Optional[int] = Field(
10401052
foreign_key="motioncorrection.motionCorrectionId"
10411053
)
1042-
autoProcProgramId: Optional[int] = Field(foreign_key="autoprocprogram.id")
1054+
autoProcProgramId: Optional[int] = Field(
1055+
foreign_key="autoprocprogram.autoProcProgramId"
1056+
)
10431057
boxSizeX: Optional[float] = None
10441058
boxSizeY: Optional[float] = None
10451059
minResolution: Optional[float] = None
@@ -1062,7 +1076,7 @@ class CTF(SQLModel, table=True): # type: ignore
10621076

10631077
class ParticlePicker(SQLModel, table=True): # type: ignore
10641078
particlePickerId: int = Field(primary_key=True, unique=True)
1065-
programId: Optional[int] = Field(foreign_key="autoprocprogram.id")
1079+
programId: Optional[int] = Field(foreign_key="autoprocprogram.autoProcProgramId")
10661080
firstMotionCorrectionId: Optional[int] = Field(
10671081
foreign_key="motioncorrection.motionCorrectionId"
10681082
)
@@ -1083,8 +1097,12 @@ class ParticlePicker(SQLModel, table=True): # type: ignore
10831097

10841098
class Tomogram(SQLModel, table=True): # type: ignore
10851099
tomogramId: int = Field(primary_key=True, unique=True)
1086-
dataCollectionId: Optional[int] = Field(foreign_key="datacollection.id")
1087-
autoProcProgramId: Optional[int] = Field(foreign_key="autoprocprogram.id")
1100+
dataCollectionId: Optional[int] = Field(
1101+
foreign_key="datacollection.dataCollectionId"
1102+
)
1103+
autoProcProgramId: Optional[int] = Field(
1104+
foreign_key="autoprocprogram.autoProcProgramId"
1105+
)
10881106
volumeFile: Optional[str] = None
10891107
stackFile: Optional[str] = None
10901108
sizeX: Optional[int] = None
@@ -1135,7 +1153,9 @@ class RelativeIceThickness(SQLModel, table=True): # type: ignore
11351153
motionCorrectionId: Optional[int] = Field(
11361154
foreign_key="motioncorrection.motionCorrectionId"
11371155
)
1138-
autoProcProgramId: Optional[int] = Field(foreign_key="autoprocprogram.id")
1156+
autoProcProgramId: Optional[int] = Field(
1157+
foreign_key="autoprocprogram.autoProcProgramId"
1158+
)
11391159
minimum: Optional[float] = None
11401160
q1: Optional[float] = None
11411161
median: Optional[float] = None
@@ -1150,7 +1170,7 @@ class RelativeIceThickness(SQLModel, table=True): # type: ignore
11501170

11511171

11521172
class TiltImageAlignment(SQLModel, table=True): # type: ignore
1153-
movieId: int = Field(foreign_key="movie.murfey_id", primary_key=True)
1173+
movieId: int = Field(foreign_key="movie.movieId", primary_key=True)
11541174
tomogramId: int = Field(foreign_key="tomogram.tomogramId", primary_key=True)
11551175
defocusU: Optional[float] = None
11561176
defocusV: Optional[float] = None
@@ -1170,7 +1190,7 @@ class ParticleClassificationGroup(SQLModel, table=True): # type: ignore
11701190
particlePickerId: Optional[int] = Field(
11711191
foreign_key="particlepicker.particlePickerId"
11721192
)
1173-
programId: Optional[int] = Field(foreign_key="autoprocprogram.id")
1193+
programId: Optional[int] = Field(foreign_key="autoprocprogram.autoProcProgramId")
11741194
type: Optional[str] = Enum("2D", "3D")
11751195
batchNumber: Optional[int] = None
11761196
numberOfParticlesPerBatch: Optional[int] = None

0 commit comments

Comments
 (0)