55Create Date: 2025-08-07 15:45:43.241567
66
77"""
8+
89from alembic import op
910import sqlalchemy as sa
1011
1112
1213# revision identifiers, used by Alembic.
13- revision = ' 0b29eefbe1dd'
14- down_revision = ' 2b7a977e7e98'
14+ revision = " 0b29eefbe1dd"
15+ down_revision = " 2b7a977e7e98"
1516branch_labels = None
1617depends_on = None
1718
1819
1920def upgrade ():
2021 # ### commands auto generated by Alembic - please adjust! ###
2122 # Rename existing columns
22- op .alter_column ('controlled_keywords' , 'value' , new_column_name = 'label' , existing_type = sa .String (), existing_nullable = False )
23- op .alter_column ('controlled_keywords' , 'vocabulary' , new_column_name = 'system' , existing_type = sa .String (), existing_nullable = True )
23+ op .alter_column (
24+ "controlled_keywords" , "value" , new_column_name = "label" , existing_type = sa .String (), existing_nullable = False
25+ )
26+ op .alter_column (
27+ "controlled_keywords" , "vocabulary" , new_column_name = "system" , existing_type = sa .String (), existing_nullable = True
28+ )
2429 # Add new columns
25- op .add_column (' controlled_keywords' , sa .Column (' code' , sa .String (), nullable = True ))
26- op .add_column (' controlled_keywords' , sa .Column (' version' , sa .String (), nullable = True ))
30+ op .add_column (" controlled_keywords" , sa .Column (" code" , sa .String (), nullable = True ))
31+ op .add_column (" controlled_keywords" , sa .Column (" version" , sa .String (), nullable = True ))
2732 # Drop and recreate the correct unique constraint
28- op .drop_constraint (' ix_controlled_keywords_key_value' , ' controlled_keywords' , type_ = ' unique' )
29- op .create_unique_constraint (' ix_controlled_keywords_key_label' , ' controlled_keywords' , [' key' , ' label' ])
33+ op .drop_constraint (" ix_controlled_keywords_key_value" , " controlled_keywords" , type_ = " unique" )
34+ op .create_unique_constraint (" ix_controlled_keywords_key_label" , " controlled_keywords" , [" key" , " label" ])
3035 # ### end Alembic commands ###
3136
3237 # TODO: Will modify this part when we get the final GO terms.
@@ -37,10 +42,14 @@ def upgrade():
3742
3843def downgrade ():
3944 # ### commands auto generated by Alembic - please adjust! ###
40- op .alter_column ('controlled_keywords' , 'label' , new_column_name = 'value' , existing_type = sa .String (), existing_nullable = False )
41- op .alter_column ('controlled_keywords' , 'system' , new_column_name = 'vocabulary' , existing_type = sa .String (), existing_nullable = True )
42- op .drop_constraint ('ix_controlled_keywords_key_label' , 'controlled_keywords' , type_ = 'unique' )
43- op .create_unique_constraint ('ix_controlled_keywords_key_value' , 'controlled_keywords' , ['key' , 'value' ])
44- op .drop_column ('controlled_keywords' , 'version' )
45- op .drop_column ('controlled_keywords' , 'code' )
45+ op .alter_column (
46+ "controlled_keywords" , "label" , new_column_name = "value" , existing_type = sa .String (), existing_nullable = False
47+ )
48+ op .alter_column (
49+ "controlled_keywords" , "system" , new_column_name = "vocabulary" , existing_type = sa .String (), existing_nullable = True
50+ )
51+ op .drop_constraint ("ix_controlled_keywords_key_label" , "controlled_keywords" , type_ = "unique" )
52+ op .create_unique_constraint ("ix_controlled_keywords_key_value" , "controlled_keywords" , ["key" , "value" ])
53+ op .drop_column ("controlled_keywords" , "version" )
54+ op .drop_column ("controlled_keywords" , "code" )
4655 # ### end Alembic commands ###
0 commit comments