Skip to content

Instantly share code, notes, and snippets.

@ceoro9
Created February 18, 2018 20:53
Show Gist options
  • Save ceoro9/961ccaaecd1355bf6319f5cb32065143 to your computer and use it in GitHub Desktop.
Save ceoro9/961ccaaecd1355bf6319f5cb32065143 to your computer and use it in GitHub Desktop.
Example of pre-defined data before migrarion.
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-01-22 17:31
"""Load data using py and sqlq
...
"""
from __future__ import unicode_literals
from django.db import migrations
def load_users(apps, schema_editor):
#user = User(..)
#user.save()
pass
def delete_users(apps, schema_editor):
#Users = app.get_model(...HELP!!)
#Users.object.all().delete()
pass
def load_users_from_sql():
#return sql_statments
pass
def delete_users_from_sql():
#return sql_statments
pass
class Migration(migrations.Migration):
dependencies = [
('userauth', '0001_squashed_0002_auto_20180120_1828'),
]
operations = [
# 1st arg - function to run
# 2nd arg - funtcion to run if rollback happens
#migrations.RunPython(load_users, delete_users),
#migrations.RunSQL(load_user_from_sql(), delete_users_from_sql())
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment