Django not showing RAW SQL with sqlmigrate

I'm trying to get the RAW SQL from a migration and it only prints begin and commit.

I'm modify a model, adding the middle_name field

class User(AbstractBaseUser):
    email = models.EmailField(max_length=200, blank=False, unique=True)
    first_name = models.CharField(
        max_length=200, blank=False, verbose_name="nombre"
    )
    middle_name = models.CharField(
        max_length=200, blank=True, verbose_name="segundo nombre"
    )

It creates the migration 0007_user_middle_name.py

# Generated by Django 3.2.23 on 2024-06-10 16:15

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('biglifeapp', '0006_biglifesetting_new_field'),
    ]

    operations = [
        migrations.AddField(
            model_name='user',
            name='middle_name',
            field=models.CharField(blank=True, max_length=200, verbose_name='segundo nombre'),
        ),
    ]

but when I run python manage.py sqlmigrate my_app 0007 --database=default

it only prints

`BEGIN;
--
-- Add field middle_name to user
--
COMMIT;

this should print something like

`BEGIN;
--
-- Add field middle_name to user
--
alter table user add column middle_name (...)
COMMIT;

I saw 2 questions on stackoverflow, but none of those was the case

for this case, the db does indeed change, I'm adding a new column to it

For some migrations, why `sqlmigrate` shows empty, or the same SQL both directions?

in this case, the --database argument is being provided

Django sqlmigrate not showing raw sql

Back to Top