|
1 | | -# Generated by Django 4.2.3 on 2023-12-01 10:39 |
2 | | - |
3 | 1 | from django.db import migrations |
4 | 2 |
|
5 | 3 |
|
| 4 | +def add_state_medication_data(apps, schema_editor): |
| 5 | + StateMedication = apps.get_model('api', 'StateMedication') |
| 6 | + |
| 7 | + # Define your data |
| 8 | + state_medication_data = [ |
| 9 | + {'state': 'mania', 'first': 'mania-first', |
| 10 | + 'second': 'mania-second', 'third': 'mania-third'}, |
| 11 | + {'state': 'hypomanic', 'first': 'hypomanic-first', |
| 12 | + 'second': 'hypomanic-second', 'third': 'hypomanic-third'}, |
| 13 | + {'state': 'depressed', 'first': 'depressed-first', |
| 14 | + 'second': 'depressed-second', 'third': 'depressed-third'}, |
| 15 | + {'state': 'euthymic', 'first': 'euthymic-first', |
| 16 | + 'second': 'euthymic-second', 'third': 'euthymic-third'}, |
| 17 | + ] |
| 18 | + |
| 19 | + # Insert the data into the StateMedication table |
| 20 | + for med in state_medication_data: |
| 21 | + StateMedication.objects.create(**med) |
| 22 | + |
| 23 | + |
6 | 24 | class Migration(migrations.Migration): |
7 | 25 |
|
8 | 26 | dependencies = [ |
9 | 27 | ('api', '0001_initial'), |
10 | 28 | ] |
11 | 29 |
|
12 | 30 | operations = [ |
| 31 | + migrations.RunPython(add_state_medication_data), |
13 | 32 | ] |
0 commit comments