[Django] #34253: migrations don't apply

12 views
Skip to first unread message

Django

unread,
Jan 11, 2023, 7:10:00 PM1/11/23
to django-...@googlegroups.com
#34253: migrations don't apply
-----------------------------------------+------------------------
Reporter: kamikaze | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
{{{
# 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;

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34253>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 11, 2023, 7:23:00 PM1/11/23
to django-...@googlegroups.com
#34253: migrations don't apply
----------------------------+--------------------------------------
Reporter: kamikaze | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 4.1
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => invalid
* component: Uncategorized => Migrations


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34253#comment:1>

Django

unread,
Jan 11, 2023, 7:24:02 PM1/11/23
to django-...@googlegroups.com
#34253: migrations don't apply
-------------------------------+--------------------------------------

Reporter: kamikaze | Owner: nobody
Type: Bug | Status: closed
Component: Uncategorized | Version: 4.1

Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by kamikaze):

* component: Migrations => Uncategorized


Old description:

> {{{
> # 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;
>
> }}}

New description:

{{{
# 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

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34253#comment:2>

Django

unread,
Jan 11, 2023, 7:31:40 PM1/11/23
to django-...@googlegroups.com
#34253: migrations don't apply
-------------------------------+--------------------------------------
Reporter: kamikaze | Owner: nobody
Type: Bug | Status: closed
Component: Uncategorized | Version: 4.1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by kamikaze):

Replying to [comment:1 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34253#comment:3>

Django

unread,
Jan 12, 2023, 12:03:24 AM1/12/23
to django-...@googlegroups.com
#34253: migrations don't apply
-------------------------------+--------------------------------------
Reporter: Oleg Korsak | Owner: nobody

Type: Bug | Status: closed
Component: Uncategorized | Version: 4.1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Mariusz Felisiak):

> 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34253#comment:4>

Reply all
Reply to author
Forward
0 new messages