renumber-migrations: Skip migration 0261.

Because of a security release that required a migration, there
are two migrations numbered 0261. To avoid breaking existing
installs renumbering the migrations, we skipped migration 0261
when running tools/renumber-migrations.
This commit is contained in:
Clara Dantas 2020-06-18 18:00:43 -03:00 committed by Tim Abbott
parent 1094e533bf
commit e87df351f7
1 changed files with 10 additions and 5 deletions

View File

@ -51,6 +51,7 @@ def resolve_conflicts(conflicts: List[str], files_list: List[str]) -> None:
if __name__ == '__main__': if __name__ == '__main__':
MIGRATIONS_TO_SKIP = {'0209', '0261'}
while True: while True:
conflicts: List[str] = [] conflicts: List[str] = []
stack: List[str] = [] stack: List[str] = []
@ -61,11 +62,15 @@ if __name__ == '__main__':
migration_number = file[0:4] migration_number = file[0:4]
counter = file_index.count(migration_number) counter = file_index.count(migration_number)
# There are 2 migrations 0209 because of a security if counter > 1 and file[0:4] not in stack:
# release requiring a migration. # When we need to backport migrations to a previous
if counter > 1 and file[0:4] not in stack and migration_number != "0209": # release, we sometimes end up with multiple having
conflicts += [file_name for file_name in files_list if file_name.startswith(migration_number)] # the same ID number (which isn't a problem; the
stack.append(migration_number) # migrations graph structure, not the IDs, is what
# matters).
if migration_number not in MIGRATIONS_TO_SKIP:
conflicts += [file_name for file_name in files_list if file_name.startswith(migration_number)]
stack.append(migration_number)
if len(conflicts) > 0: if len(conflicts) > 0:
resolve_conflicts(conflicts, files_list) resolve_conflicts(conflicts, files_list)