If you adhere to migration naming conventions, you can simply pass the output of rake db:migrate:status via grep :
rake db:migrate:status | grep 'compan'
This is not ideal, though - migration names should have nothing to do with what they actually do - migration can add a column name to the company table and be called EvacuateWeaselTubes and it still works just fine.
If you want to create a task that could overcome this problem, she would have to analyze each of the migration files to see what changed. Since there are many ways to indicate a change in migration ( add_column , create_table or call execute('CREATE whatever') , for example), you probably want to find references to Model.table_name , and then check the schema_migrations check box to see if it was executed .
source share