Created
August 19, 2019 16:24
-
-
Save ryan2clw/0c5133e00792d871475af0ddbe34f2ca to your computer and use it in GitHub Desktop.
data migration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by Django 2.2.4 on 2019-08-19 15:30 | |
from django.db import migrations | |
def seed_database(apps, _): | |
""" Seed the ball numbers into the database """ | |
balls = apps.get_model('play', 'Ball') | |
balls.objects.all().delete() | |
for i in range(1, 76): | |
data = { | |
"num_value" : i, | |
"is_played" : False | |
} | |
ball = balls.objects.create(**data) | |
ball.save() | |
class Migration(migrations.Migration): | |
""" Seeds ball data """ | |
dependencies = [ | |
('play', '0006_auto_20190819_1447'), | |
] | |
operations = [ | |
migrations.RunPython(seed_database) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment