Opened 23 months ago

Closed 23 months ago

Last modified 23 months ago

#34253 closed Bug (invalid)

migrations don't apply

Reported by: Oleg Korsak Owned by: nobody
Component: Uncategorized Version: 4.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Oleg Korsak)

# Generated by Django 4.1.5 on 2023-01-12 01:57

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('myApp', '0001_initial'),
    ]

    operations = [
        migrations.AlterField(
            model_name='report49',
            name='d29',
            field=models.IntegerField(default=1),
        ),
    ]

there is no such migration applied yet, but sqlmigrate shows:

BEGIN;
--
-- Alter field d29 on report49
--
-- (no-op)
COMMIT;

Initial migration didn't set any defaults as well

Change History (4)

comment:1 by Tim Graham, 23 months ago

Component: UncategorizedMigrations
Resolution: invalid
Status: newclosed

You haven't stated what the unexpected behavior is. If the migration doesn't execute any SQL (which is impossible to know given the information you provided) then the output looks correct. For example, if you added default=1 to the field, then no SQL queries are expected.

comment:2 by Oleg Korsak, 23 months ago

Component: MigrationsUncategorized
Description: modified (diff)

in reply to:  1 ; comment:3 by Oleg Korsak, 23 months ago

Replying to Tim Graham:

You haven't stated what the unexpected behavior is. If the migration doesn't execute any SQL (which is impossible to know given the information you provided) then the output looks correct. For example, if you added default=1 to the field, then no SQL queries are expected.

I added initial default=0 - table created, no default for column. then I changed to default=1 and alter didn't change anything as well. any idea why? SQLAlchemy + alembic does such things.

in reply to:  3 comment:4 by Mariusz Felisiak, 23 months ago

I added initial default=0 - table created, no default for column. then I changed to default=1 and alter didn't change anything as well. any idea why? SQLAlchemy + alembic does such things.

Django's ORM don't use defaults defined at the database level and always specify the value when performing inserts instead. #470 is a ticket to allow using database defaults.

Note: See TracTickets for help on using tickets.
Back to Top