Skip to content

Commit

Permalink
#15: Getting all migration versions available up to a version.
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermechapiewski committed Mar 11, 2009
1 parent c10ef3a commit 1fdda48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/simple_db_migrate/core.py
Expand Up @@ -42,6 +42,10 @@ def get_all_migration_versions(self):
for each_file in migration_files:
versions.append(self.get_migration_version(each_file))
return versions

def get_all_migration_versions_up_to(self, limit_version):
all_versions = self.get_all_migration_versions()
return [version for version in all_versions if version < limit_version]

def get_migration_version(self, sql_file):
return sql_file[0:sql_file.find("_")]
Expand Down
8 changes: 7 additions & 1 deletion tests/core_test.py
Expand Up @@ -87,7 +87,13 @@ def test_it_should_get_all_migration_versions_available(self):
all_versions = db_migrate.get_all_migration_versions()
for each_version_got in all_versions:
self.assertTrue(each_version_got in expected_versions)


def test_it_should_get_all_migration_versions_up_to_a_version(self):
db_migrate = SimpleDBMigrate(".")
migration_files = db_migrate.get_all_migration_versions_up_to("20090214115200")
self.assertEquals(len(migration_files), 1)
self.assertEquals(migration_files[0], "20090214115100")

def test_it_should_get_migration_up_command_in_file(self):
db_migrate = SimpleDBMigrate(".")
migration_file = "20090214120600_example_migration_file_with_commands.migration"
Expand Down

0 comments on commit 1fdda48

Please sign in to comment.