2929
3030class Acquisition (SQLModel , table = True , table_name = "acquisition" ):
3131 __table_args__ = {"extend_existing" : True }
32- id : str = Field (primary_key = True )
32+ uuid : str = Field (primary_key = True )
3333 epu_id : str | None = Field (default = None )
3434 name : str
3535 status : AcquisitionStatus = Field (default = AcquisitionStatus .PLANNED , sa_column = Column (AcquisitionStatusType ()))
@@ -45,9 +45,9 @@ class Acquisition(SQLModel, table=True, table_name="acquisition"):
4545
4646class Atlas (SQLModel , table = True , table_name = "atlas" ):
4747 __table_args__ = {"extend_existing" : True }
48- id : str = Field (primary_key = True )
48+ uuid : str = Field (primary_key = True )
4949 atlas_id : str = Field (default = "" )
50- grid_id : str | None = Field (default = None , foreign_key = "grid.id " )
50+ grid_id : str | None = Field (default = None , foreign_key = "grid.uuid " )
5151 acquisition_date : datetime | None = Field (default = None )
5252 storage_folder : str | None = Field (default = None )
5353 description : str | None = Field (default = None )
@@ -60,8 +60,8 @@ class Atlas(SQLModel, table=True, table_name="atlas"):
6060
6161class Grid (SQLModel , table = True , table_name = "grid" ):
6262 __table_args__ = {"extend_existing" : True }
63- id : str = Field (primary_key = True )
64- acquisition_id : str | None = Field (default = None , foreign_key = "acquisition.id " )
63+ uuid : str = Field (primary_key = True )
64+ acquisition_id : str | None = Field (default = None , foreign_key = "acquisition.uuid " )
6565 status : GridStatus = Field (default = GridStatus .NONE , sa_column = Column (GridStatusType ()))
6666 name : str
6767 data_dir : str | None = Field (default = None )
@@ -83,8 +83,8 @@ class Grid(SQLModel, table=True, table_name="grid"):
8383
8484class AtlasTile (SQLModel , table = True , table_name = "atlastile" ):
8585 __table_args__ = {"extend_existing" : True }
86- id : str = Field (primary_key = True )
87- atlas_id : str | None = Field (default = None , foreign_key = "atlas.id " )
86+ uuid : str = Field (primary_key = True )
87+ atlas_id : str | None = Field (default = None , foreign_key = "atlas.uuid " )
8888 tile_id : str = Field (default = "" )
8989 position_x : int | None = Field (default = None )
9090 position_y : int | None = Field (default = None )
@@ -97,8 +97,8 @@ class AtlasTile(SQLModel, table=True, table_name="atlastile"):
9797
9898class GridSquare (SQLModel , table = True , table_name = "gridsquare" ):
9999 __table_args__ = {"extend_existing" : True }
100- id : str = Field (primary_key = True )
101- grid_id : str | None = Field (default = None , foreign_key = "grid.id " )
100+ uuid : str = Field (primary_key = True )
101+ grid_id : str | None = Field (default = None , foreign_key = "grid.uuid " )
102102 status : GridSquareStatus = Field (default = GridSquareStatus .NONE , sa_column = Column (GridSquareStatusType ()))
103103 gridsquare_id : str = Field (default = "" )
104104 data_dir : str | None = Field (default = None )
@@ -132,8 +132,8 @@ class GridSquare(SQLModel, table=True, table_name="gridsquare"):
132132
133133class FoilHole (SQLModel , table = True , table_name = "foilhole" ):
134134 __table_args__ = {"extend_existing" : True }
135- id : str = Field (primary_key = True )
136- gridsquare_id : str | None = Field (default = None , foreign_key = "gridsquare.id " )
135+ uuid : str = Field (primary_key = True )
136+ gridsquare_id : str | None = Field (default = None , foreign_key = "gridsquare.uuid " )
137137 status : FoilHoleStatus = Field (default = FoilHoleStatus .NONE , sa_column = Column (FoilHoleStatusType ()))
138138 foilhole_id : str = Field (default = "" )
139139 center_x : float | None = Field (default = None )
@@ -157,8 +157,8 @@ class FoilHole(SQLModel, table=True, table_name="foilhole"):
157157
158158class Micrograph (SQLModel , table = True , table_name = "micrograph" ):
159159 __table_args__ = {"extend_existing" : True }
160- id : str = Field (primary_key = True )
161- foilhole_id : str | None = Field (default = None , foreign_key = "foilhole.id " )
160+ uuid : str = Field (primary_key = True )
161+ foilhole_id : str | None = Field (default = None , foreign_key = "foilhole.uuid " )
162162 status : MicrographStatus = Field (default = MicrographStatus .NONE , sa_column = Column (MicrographStatusType ()))
163163 micrograph_id : str = Field (default = "" )
164164 location_id : str | None = Field (default = None )
@@ -199,7 +199,7 @@ class QualityPredictionModel(SQLModel, table=True):
199199class QualityPredictionModelParameter (SQLModel , table = True ):
200200 __table_args__ = {"extend_existing" : True }
201201 id : int | None = Field (default = None , primary_key = True )
202- grid_id : str = Field (foreign_key = "grid.id " )
202+ grid_id : str = Field (foreign_key = "grid.uuid " )
203203 timestamp : datetime = Field (default_factory = datetime .now )
204204 prediction_model_name : str = Field (foreign_key = "qualitypredictionmodel.name" )
205205 key : str
@@ -211,8 +211,8 @@ class QualityPredictionModelParameter(SQLModel, table=True):
211211class QualityPredictionModelWeight (SQLModel , table = True ):
212212 __table_args__ = {"extend_existing" : True }
213213 id : int | None = Field (default = None , primary_key = True )
214- grid_id : str = Field (foreign_key = "grid.id " )
215- micrograph_id : str | None = Field (default = None , foreign_key = "micrograph.id " )
214+ grid_id : str = Field (foreign_key = "grid.uuid " )
215+ micrograph_id : str | None = Field (default = None , foreign_key = "micrograph.uuid " )
216216 micrograph_quality : bool | None = Field (default = None )
217217 timestamp : datetime = Field (default_factory = datetime .now )
218218 origin : str | None = Field (default = None )
@@ -229,8 +229,8 @@ class QualityPrediction(SQLModel, table=True):
229229 timestamp : datetime = Field (default_factory = datetime .now )
230230 value : float
231231 prediction_model_name : str = Field (foreign_key = "qualitypredictionmodel.name" )
232- foilhole_id : str | None = Field (default = None , foreign_key = "foilhole.id " )
233- gridsquare_id : str | None = Field (default = None , foreign_key = "gridsquare.id " )
232+ foilhole_id : str | None = Field (default = None , foreign_key = "foilhole.uuid " )
233+ gridsquare_id : str | None = Field (default = None , foreign_key = "gridsquare.uuid " )
234234 foilhole : FoilHole | None = Relationship (back_populates = "prediction" )
235235 gridsquare : GridSquare | None = Relationship (back_populates = "prediction" )
236236 model : QualityPredictionModel | None = Relationship (back_populates = "predictions" )
@@ -270,39 +270,39 @@ def _create_db_and_tables(engine):
270270 try :
271271 # acquisition indexes
272272 sess .execute (
273- text ("CREATE INDEX IF NOT EXISTS idx_acquisition_id_pattern ON acquisition (id text_pattern_ops);" )
273+ text ("CREATE INDEX IF NOT EXISTS idx_acquisition_id_pattern ON acquisition (uuid text_pattern_ops);" )
274274 )
275- sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_acquisition_id_hash ON acquisition USING hash (id );" ))
275+ sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_acquisition_id_hash ON acquisition USING hash (uuid );" ))
276276 sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_acquisition_name ON acquisition (name);" ))
277277
278278 # atlas indexes
279- sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_atlas_id_pattern ON atlas (id text_pattern_ops);" ))
279+ sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_atlas_id_pattern ON atlas (uuid text_pattern_ops);" ))
280280 sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_atlas_grid_id ON atlas (grid_id);" ))
281281
282282 # grid indexes
283- sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_grid_id_pattern ON grid (id text_pattern_ops);" ))
284- sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_grid_id_hash ON grid USING hash (id );" ))
283+ sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_grid_id_pattern ON grid (uuid text_pattern_ops);" ))
284+ sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_grid_id_hash ON grid USING hash (uuid );" ))
285285 sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_grid_acquisition_id ON grid (acquisition_id);" ))
286286 sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_grid_name ON grid (name);" ))
287287
288288 # gridsquare indexes
289289 sess .execute (
290- text ("CREATE INDEX IF NOT EXISTS idx_gridsquare_id_pattern ON gridsquare (id text_pattern_ops);" )
290+ text ("CREATE INDEX IF NOT EXISTS idx_gridsquare_id_pattern ON gridsquare (uuid text_pattern_ops);" )
291291 )
292- sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_gridsquare_id_hash ON gridsquare USING hash (id );" ))
292+ sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_gridsquare_id_hash ON gridsquare USING hash (uuid );" ))
293293 sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_gridsquare_grid_id ON gridsquare (grid_id);" ))
294294
295295 # foilhole indexes
296- sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_foilhole_id_pattern ON foilhole (id text_pattern_ops);" ))
297- sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_foilhole_id_hash ON foilhole USING hash (id );" ))
296+ sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_foilhole_id_pattern ON foilhole (uuid text_pattern_ops);" ))
297+ sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_foilhole_id_hash ON foilhole USING hash (uuid );" ))
298298 sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_foilhole_gridsquare_id ON foilhole (gridsquare_id);" ))
299299 sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_foilhole_quality ON foilhole (quality);" ))
300300
301301 # micrograph indexes
302302 sess .execute (
303- text ("CREATE INDEX IF NOT EXISTS idx_micrograph_id_pattern ON micrograph (id text_pattern_ops);" )
303+ text ("CREATE INDEX IF NOT EXISTS idx_micrograph_id_pattern ON micrograph (uuid text_pattern_ops);" )
304304 )
305- sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_micrograph_id_hash ON micrograph USING hash (id );" ))
305+ sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_micrograph_id_hash ON micrograph USING hash (uuid );" ))
306306 sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_micrograph_foilhole_id ON micrograph (foilhole_id);" ))
307307
308308 sess .commit ()
@@ -312,7 +312,7 @@ def _create_db_and_tables(engine):
312312
313313 try :
314314 sess .execute (
315- text ("CREATE INDEX IF NOT EXISTS idx_atlastile_id_pattern ON atlastile (id text_pattern_ops);" )
315+ text ("CREATE INDEX IF NOT EXISTS idx_atlastile_id_pattern ON atlastile (uuid text_pattern_ops);" )
316316 )
317317 sess .execute (text ("CREATE INDEX IF NOT EXISTS idx_atlastile_atlas_id ON atlastile (atlas_id);" ))
318318 sess .commit ()
0 commit comments