SkyLearn-Test/payments/migrations/0002_testclass_array.py
2024-02-02 19:48:44 +05:00

26 lines
868 B
Python

# Generated by Django 3.1.3 on 2021-04-16 09:14
from django.db import migrations, models
# Function to create initial data for array field in PostgreSQL
def create_array_field_for_postgres(apps, schema_editor):
TestClass = apps.get_model('payments', 'TestClass')
TestClass.objects.create(array=[])
class Migration(migrations.Migration):
dependencies = [
('payments', '0001_initial'),
]
operations = [
# Adding a JSONField for array, which is supported by both PostgreSQL and MySQL
migrations.AddField(
model_name='testclass',
name='array',
field=models.JSONField(blank=True, default=list, null=True),
),
# Running the create_array_field_for_postgres function to populate initial data in PostgreSQL
migrations.RunPython(create_array_field_for_postgres),
]