old_contents: # -*- coding: utf-8 -*-
  from __future__ import unicode_literals
  
  from django.db import migrations
  
  from osmaxx.countries.utils import get_polyfile_name_to_file_mapping
  from osmaxx.utils.polyfile_helpers import polyfile_to_geos_geometry
  
  
  class Migration(migrations.Migration):
      def import_countries(apps, schema_editor):  # noqa
          tolerance = 0.01  # in degrees
          Country = apps.get_model("countries", "Country")  # noqa
          for name, polyfile_path in get_polyfile_name_to_file_mapping().items():
              geometry = polyfile_to_geos_geometry(polyfile_path)
              simplified_geometry = polyfile_to_geos_geometry(polyfile_path, simplify_tolerance=tolerance)
              Country.objects.create(
                  name=name,
                  polyfile=polyfile_path,
                  polygon=geometry,
                  simplified_polygon=simplified_geometry,
              )
  
      def remove_countries(apps, schema_editor):  # noqa
          Country = apps.get_model("countries", "Country")  # noqa
          Country.objects.all().delete()
  
      dependencies = [
          ('countries', '0001_initial'),
      ]
  
      operations = [
          migrations.RunPython(import_countries, remove_countries),
      ]
  
new_contents: # -*- coding: utf-8 -*-
  from __future__ import unicode_literals
  
  from django.db import migrations
  
  
  class Migration(migrations.Migration):
      def import_countries(apps, schema_editor):  # noqa
          # not doing anything to let the migrations pass on new installations
          pass
  
      def remove_countries(apps, schema_editor):  # noqa
          Country = apps.get_model("countries", "Country")  # noqa
          Country.objects.all().delete()
  
      dependencies = [
          ('countries', '0001_initial'),
      ]
  
      operations = [
          migrations.RunPython(import_countries, remove_countries),
      ]
  
subject: make migrations run again on new installation where countries are not available