@@ -31,6 +31,7 @@ def upgrade() -> None:
3131 sa .Column ("updated_at" , sa .DateTime (), server_default = sa .text ("(CURRENT_TIMESTAMP)" ), nullable = False ),
3232 sa .PrimaryKeyConstraint ("id" ),
3333 )
34+ op .create_index ("idx_projects_name" , "projects" , ["name" ], unique = False )
3435 op .create_table (
3536 "sinks" ,
3637 sa .Column ("id" , sa .Text (), nullable = False ),
@@ -65,6 +66,7 @@ def upgrade() -> None:
6566 sa .ForeignKeyConstraint (["project_id" ], ["projects.id" ], ondelete = "CASCADE" ),
6667 sa .PrimaryKeyConstraint ("id" ),
6768 )
69+ op .create_index ("idx_dataset_revisions_project" , "dataset_revisions" , ["project_id" ], unique = False )
6870 op .create_table (
6971 "labels" ,
7072 sa .Column ("project_id" , sa .Text (), nullable = False ),
@@ -94,17 +96,15 @@ def upgrade() -> None:
9496 sa .Column ("id" , sa .Text (), nullable = False ),
9597 sa .Column ("created_at" , sa .DateTime (), server_default = sa .text ("(CURRENT_TIMESTAMP)" ), nullable = False ),
9698 sa .Column ("updated_at" , sa .DateTime (), server_default = sa .text ("(CURRENT_TIMESTAMP)" ), nullable = False ),
97- sa .ForeignKeyConstraint (
98- ["parent_revision" ],
99- ["model_revisions.id" ],
100- ),
99+ sa .ForeignKeyConstraint (["parent_revision" ], ["model_revisions.id" ]),
101100 sa .ForeignKeyConstraint (["project_id" ], ["projects.id" ], ondelete = "CASCADE" ),
102- sa .ForeignKeyConstraint (
103- ["training_dataset_id" ],
104- ["dataset_revisions.id" ],
105- ),
101+ sa .ForeignKeyConstraint (["training_dataset_id" ], ["dataset_revisions.id" ]),
106102 sa .PrimaryKeyConstraint ("id" ),
107103 )
104+ op .create_index (
105+ "idx_model_revisions_project_status" , "model_revisions" , ["project_id" , "training_status" ], unique = False
106+ )
107+ op .create_index ("idx_model_revisions_architecture" , "model_revisions" , ["project_id" , "architecture" ], unique = False )
108108 op .create_table (
109109 "dataset_items" ,
110110 sa .Column ("project_id" , sa .Text (), nullable = False ),
@@ -127,6 +127,7 @@ def upgrade() -> None:
127127 sa .ForeignKeyConstraint (["source_id" ], ["sources.id" ], ondelete = "SET NULL" ),
128128 sa .PrimaryKeyConstraint ("id" ),
129129 )
130+ op .create_index ("idx_dataset_items_user_reviewed" , "dataset_items" , ["project_id" , "user_reviewed" ], unique = False )
130131 op .create_index ("idx_dataset_items_project_created_at" , "dataset_items" , ["project_id" , "created_at" ], unique = False )
131132 op .create_table (
132133 "pipelines" ,
@@ -144,6 +145,7 @@ def upgrade() -> None:
144145 sa .ForeignKeyConstraint (["source_id" ], ["sources.id" ], ondelete = "RESTRICT" ),
145146 sa .PrimaryKeyConstraint ("project_id" ),
146147 )
148+ op .create_index ("idx_pipelines_is_running" , "pipelines" , ["is_running" ], unique = False )
147149 op .create_table (
148150 "dataset_items_labels" ,
149151 sa .Column ("dataset_item_id" , sa .Text (), nullable = False ),
@@ -161,13 +163,19 @@ def downgrade() -> None:
161163 """Downgrade schema."""
162164 # ### commands auto generated by Alembic - please adjust! ###
163165 op .drop_table ("dataset_items_labels" )
166+ op .drop_index ("idx_pipelines_is_running" , table_name = "pipelines" )
164167 op .drop_table ("pipelines" )
165168 op .drop_index ("idx_dataset_items_project_created_at" , table_name = "dataset_items" )
169+ op .drop_index ("idx_dataset_items_user_reviewed" , table_name = "dataset_items" )
166170 op .drop_table ("dataset_items" )
171+ op .drop_index ("idx_model_revisions_architecture" , table_name = "model_revisions" )
172+ op .drop_index ("idx_model_revisions_project_status" , table_name = "model_revisions" )
167173 op .drop_table ("model_revisions" )
168174 op .drop_table ("labels" )
175+ op .drop_index ("idx_dataset_revisions_project" , table_name = "dataset_revisions" )
169176 op .drop_table ("dataset_revisions" )
170177 op .drop_table ("sources" )
171178 op .drop_table ("sinks" )
179+ op .drop_index ("idx_projects_name" , table_name = "projects" )
172180 op .drop_table ("projects" )
173181 # ### end Alembic commands ###
0 commit comments