management.migrations.0001_initial

 1# Generated by Django 5.2.1 on 2025-06-04 11:49
 2
 3import django.db.models.deletion
 4from django.conf import settings
 5from django.db import migrations, models
 6
 7
 8class Migration(migrations.Migration):
 9
10    initial = True
11
12    dependencies = [
13        ('accounts', '0001_initial'),
14        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15    ]
16
17    operations = [
18        migrations.CreateModel(
19            name='Blocks',
20            fields=[
21                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
22                ('name', models.CharField(max_length=100)),
23                ('no_of_floors', models.IntegerField()),
24                ('created_at', models.DateTimeField(auto_now_add=True)),
25                ('updated_at', models.DateTimeField(auto_now=True)),
26                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
27                ('hospital', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounts.hospital')),
28            ],
29            options={
30                'db_table': 'blocks',
31                'unique_together': {('name', 'hospital')},
32            },
33        ),
34        migrations.CreateModel(
35            name='Shift',
36            fields=[
37                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
38                ('name', models.CharField(max_length=100)),
39                ('start_time', models.TimeField()),
40                ('end_time', models.TimeField()),
41                ('created_at', models.DateTimeField(auto_now_add=True)),
42                ('updated_at', models.DateTimeField(auto_now=True)),
43                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
44                ('hospital', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounts.hospital')),
45            ],
46            options={
47                'db_table': 'shifts',
48                'unique_together': {('name', 'hospital')},
49            },
50        ),
51    ]
class Migration(django.db.migrations.migration.Migration):
 9class Migration(migrations.Migration):
10
11    initial = True
12
13    dependencies = [
14        ('accounts', '0001_initial'),
15        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
16    ]
17
18    operations = [
19        migrations.CreateModel(
20            name='Blocks',
21            fields=[
22                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
23                ('name', models.CharField(max_length=100)),
24                ('no_of_floors', models.IntegerField()),
25                ('created_at', models.DateTimeField(auto_now_add=True)),
26                ('updated_at', models.DateTimeField(auto_now=True)),
27                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
28                ('hospital', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounts.hospital')),
29            ],
30            options={
31                'db_table': 'blocks',
32                'unique_together': {('name', 'hospital')},
33            },
34        ),
35        migrations.CreateModel(
36            name='Shift',
37            fields=[
38                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
39                ('name', models.CharField(max_length=100)),
40                ('start_time', models.TimeField()),
41                ('end_time', models.TimeField()),
42                ('created_at', models.DateTimeField(auto_now_add=True)),
43                ('updated_at', models.DateTimeField(auto_now=True)),
44                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
45                ('hospital', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounts.hospital')),
46            ],
47            options={
48                'db_table': 'shifts',
49                'unique_together': {('name', 'hospital')},
50            },
51        ),
52    ]

The base class for all migrations.

Migration files will import this from django.db.migrations.Migration and subclass it as a class called Migration. It will have one or more of the following attributes:

  • operations: A list of Operation instances, probably from django.db.migrations.operations
  • dependencies: A list of tuples of (app_path, migration_name)
  • run_before: A list of tuples of (app_path, migration_name)
  • replaces: A list of migration_names

Note that all migrations come out of migrations and into the Loader or Graph as instances, having been initialized with their app label and name.

initial = True
dependencies = [('accounts', '0001_initial'), ('accounts', '__first__')]
operations = [<CreateModel name='Blocks', fields=[('id', <django.db.models.fields.BigAutoField>), ('name', <django.db.models.fields.CharField>), ('no_of_floors', <django.db.models.fields.IntegerField>), ('created_at', <django.db.models.fields.DateTimeField>), ('updated_at', <django.db.models.fields.DateTimeField>), ('created_by', <django.db.models.fields.related.ForeignKey>), ('hospital', <django.db.models.fields.related.ForeignKey>)], options={'db_table': 'blocks', 'unique_together': {('name', 'hospital')}}>, <CreateModel name='Shift', fields=[('id', <django.db.models.fields.BigAutoField>), ('name', <django.db.models.fields.CharField>), ('start_time', <django.db.models.fields.TimeField>), ('end_time', <django.db.models.fields.TimeField>), ('created_at', <django.db.models.fields.DateTimeField>), ('updated_at', <django.db.models.fields.DateTimeField>), ('created_by', <django.db.models.fields.related.ForeignKey>), ('hospital', <django.db.models.fields.related.ForeignKey>)], options={'db_table': 'shifts', 'unique_together': {('name', 'hospital')}}>]