26 lines
768 B
Python
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),
|
|
]
|