From e1ffcb609bbfc9b7be0f989f8e32ea77a672beb4 Mon Sep 17 00:00:00 2001 From: long2ice Date: Tue, 28 Jul 2020 18:31:45 +0800 Subject: [PATCH] fix version sort --- CHANGELOG.rst | 1 + aerich/migrate.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5a38bb9..1c054cf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,7 @@ ChangeLog 0.2.2 ----- - Fix postgres drop fk. +- Fix version sort. 0.2.1 ----- diff --git a/aerich/migrate.py b/aerich/migrate.py index c11921d..f8c5992 100644 --- a/aerich/migrate.py +++ b/aerich/migrate.py @@ -44,7 +44,10 @@ class Migrate: @classmethod def get_all_version_files(cls) -> List[str]: - return sorted(filter(lambda x: x.endswith("json"), os.listdir(cls.migrate_location))) + return sorted( + filter(lambda x: x.endswith("json"), os.listdir(cls.migrate_location)), + key=lambda x: x.split("_")[0], + ) @classmethod async def get_last_version(cls) -> Aerich: