gault-millau/apps/location/migrations/0012_data_migrate.py
Виктор Гладких e9ad418976 Revert migrate location
2019-10-11 16:57:59 +03:00

27 lines
828 B
Python

from django.db import migrations, connection
import os
class Migration(migrations.Migration):
def load_data_from_sql(apps, schema_editor):
file_path = os.path.join(os.path.dirname(__file__), 'migrate_lang.sql')
sql_statement = open(file_path).read()
with connection.cursor() as c:
c.execute(sql_statement)
def revert_data(apps, schema_editor):
file_path = os.path.join(os.path.dirname(__file__), 'remigrate_lang.sql')
sql_statement = open(file_path).read()
with connection.cursor() as c:
c.execute(sql_statement)
dependencies = [
('location', '0011_country_languages'),
]
operations = [
migrations.RunPython(load_data_from_sql, revert_data),
# migrations.RunPython(load_data_from_sql, revert_data),
]