gault-millau/apps/translation/migrations/006_data_migrate.py
Виктор Гладких ee93cf9ff6 Fix migrate
2019-10-21 15:15:19 +03:00

26 lines
768 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 = [
('translation', '0005_auto_20191021_1201'),
]
operations = [
migrations.RunPython(load_data_from_sql, revert_data),
]