Skip to content

Commit 2288c40

Browse files
Merge pull request #859 from eaguad1337/fix/migrate-status
add batch number to status command
2 parents 0b0ca18 + eb140ef commit 2288c40

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/masoniteorm/commands/MigrateStatusCommand.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,20 @@ def handle(self):
2222
)
2323
migration.create_table_if_not_exists()
2424
table = self.table()
25-
table.set_header_row(["Ran?", "Migration"])
25+
table.set_header_row(["Ran?", "Migration", "Batch"])
2626
migrations = []
2727

28-
for migration_file in migration.get_ran_migrations():
28+
for migration_data in migration.get_ran_migrations():
29+
migration_file = migration_data["migration_file"]
30+
batch = migration_data["batch"]
31+
2932
migrations.append(
30-
["<info>Y</info>", f"<comment>{migration_file}</comment>"]
33+
["<info>Y</info>", f"<comment>{migration_file}</comment>", f"<info>{batch}</info>"]
3134
)
3235

3336
for migration_file in migration.get_unran_migrations():
3437
migrations.append(
35-
["<error>N</error>", f"<comment>{migration_file}</comment>"]
38+
["<error>N</error>", f"<comment>{migration_file}</comment>", "<info>-</info>"]
3639
)
3740

3841
table.set_rows(migrations)

src/masoniteorm/migrations/Migration.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,16 @@ def get_ran_migrations(self):
118118

119119
database_migrations = self.migration_model.all()
120120
for migration in all_migrations:
121-
if migration in database_migrations.pluck("migration"):
122-
ran.append(migration)
121+
matched_migration = database_migrations.where(
122+
"migration", migration
123+
).first()
124+
if matched_migration:
125+
ran.append(
126+
{
127+
"migration_file": matched_migration.migration,
128+
"batch": matched_migration.batch,
129+
}
130+
)
123131
return ran
124132

125133
def migrate(self, migration="all", output=False):

0 commit comments

Comments
 (0)