Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import unicode_literals
- from django.db import migrations
- def load_sql(apps, schema_editor):
- from os.path import normpath, dirname, isfile, join
- from os import listdir
- sql_folder_path = '/backoffice/sql/'
- def load_raw_sql(folder_inside):
- folder_path = join(sql_folder_path, folder_inside)
- sql_files = [join(folder_path, f) for f in listdir(folder_path) if isfile(join(folder_path, f))]
- for sql_file in sql_files:
- with open(sql_file, 'r') as g:
- migrations.RunSQL(g.read())
- folders = ['functions', 'index', 'triggers']
- for folder in folders:
- load_raw_sql(folder)
- class Migration(migrations.Migration):
- dependencies = [
- ('app1', '0001_squashed_0018_auto_20150616_0708'),
- ]
- operations = [
- migrations.RunPython(load_sql),
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement