881. thing_id FK column to NMA_Chemistry_SampleInfo (NOT NULL, no orphans)
992. NMA_MinorTraceChemistry table (child of NMA_Chemistry_SampleInfo)
1010"""
11+
1112from typing import Sequence , Union
1213
1314from alembic import op
1415import sqlalchemy as sa
1516
1617
17- revision : str = ' 95d8b982cd5d'
18- down_revision : Union [str , Sequence [str ], None ] = ' 2f6e9d3a1c45'
18+ revision : str = " 95d8b982cd5d"
19+ down_revision : Union [str , Sequence [str ], None ] = " 2f6e9d3a1c45"
1920branch_labels : Union [str , Sequence [str ], None ] = None
2021depends_on : Union [str , Sequence [str ], None ] = None
2122
@@ -24,49 +25,46 @@ def upgrade() -> None:
2425 """Upgrade schema."""
2526 # Add thing_id FK to NMA_Chemistry_SampleInfo (NOT NULL - no orphans)
2627 op .add_column (
27- 'NMA_Chemistry_SampleInfo' ,
28- sa .Column ('thing_id' , sa .Integer (), nullable = False )
28+ "NMA_Chemistry_SampleInfo" , sa .Column ("thing_id" , sa .Integer (), nullable = False )
2929 )
3030 op .create_foreign_key (
31- ' fk_chemistry_sample_info_thing' ,
32- ' NMA_Chemistry_SampleInfo' ,
33- ' thing' ,
34- [' thing_id' ],
35- ['id' ],
36- ondelete = ' CASCADE'
31+ " fk_chemistry_sample_info_thing" ,
32+ " NMA_Chemistry_SampleInfo" ,
33+ " thing" ,
34+ [" thing_id" ],
35+ ["id" ],
36+ ondelete = " CASCADE" ,
3737 )
3838
3939 # Create NMA_MinorTraceChemistry table
4040 op .create_table (
41- ' NMA_MinorTraceChemistry' ,
42- sa .Column ('id' , sa .Integer (), autoincrement = True , nullable = False ),
43- sa .Column (' chemistry_sample_info_id' , sa .Integer (), nullable = False ),
44- sa .Column (' analyte' , sa .String (50 ), nullable = True ),
45- sa .Column (' sample_value' , sa .Float (), nullable = True ),
46- sa .Column (' units' , sa .String (20 ), nullable = True ),
47- sa .Column (' symbol' , sa .String (10 ), nullable = True ),
48- sa .Column (' analysis_method' , sa .String (100 ), nullable = True ),
49- sa .Column (' analysis_date' , sa .Date (), nullable = True ),
50- sa .Column (' notes' , sa .Text (), nullable = True ),
51- sa .Column (' analyses_agency' , sa .String (100 ), nullable = True ),
52- sa .Column (' uncertainty' , sa .Float (), nullable = True ),
53- sa .Column (' volume' , sa .Float (), nullable = True ),
54- sa .Column (' volume_unit' , sa .String (20 ), nullable = True ),
55- sa .PrimaryKeyConstraint ('id' ),
41+ " NMA_MinorTraceChemistry" ,
42+ sa .Column ("id" , sa .Integer (), autoincrement = True , nullable = False ),
43+ sa .Column (" chemistry_sample_info_id" , sa .Integer (), nullable = False ),
44+ sa .Column (" analyte" , sa .String (50 ), nullable = True ),
45+ sa .Column (" sample_value" , sa .Float (), nullable = True ),
46+ sa .Column (" units" , sa .String (20 ), nullable = True ),
47+ sa .Column (" symbol" , sa .String (10 ), nullable = True ),
48+ sa .Column (" analysis_method" , sa .String (100 ), nullable = True ),
49+ sa .Column (" analysis_date" , sa .Date (), nullable = True ),
50+ sa .Column (" notes" , sa .Text (), nullable = True ),
51+ sa .Column (" analyses_agency" , sa .String (100 ), nullable = True ),
52+ sa .Column (" uncertainty" , sa .Float (), nullable = True ),
53+ sa .Column (" volume" , sa .Float (), nullable = True ),
54+ sa .Column (" volume_unit" , sa .String (20 ), nullable = True ),
55+ sa .PrimaryKeyConstraint ("id" ),
5656 sa .ForeignKeyConstraint (
57- [' chemistry_sample_info_id' ],
58- [' NMA_Chemistry_SampleInfo.OBJECTID' ],
59- ondelete = ' CASCADE' ,
57+ [" chemistry_sample_info_id" ],
58+ [" NMA_Chemistry_SampleInfo.OBJECTID" ],
59+ ondelete = " CASCADE" ,
6060 ),
6161 )
6262
6363
6464def downgrade () -> None :
6565 """Downgrade schema."""
66- op .drop_table (' NMA_MinorTraceChemistry' )
66+ op .drop_table (" NMA_MinorTraceChemistry" )
6767 op .drop_constraint (
68- 'fk_chemistry_sample_info_thing' ,
69- 'NMA_Chemistry_SampleInfo' ,
70- type_ = 'foreignkey'
68+ "fk_chemistry_sample_info_thing" , "NMA_Chemistry_SampleInfo" , type_ = "foreignkey"
7169 )
72- op .drop_column (' NMA_Chemistry_SampleInfo' , ' thing_id' )
70+ op .drop_column (" NMA_Chemistry_SampleInfo" , " thing_id" )
0 commit comments