[Django] #31257: django migration has not been correctly applied for decimal_places - mysql

5 views
Skip to first unread message

Django

unread,
Feb 11, 2020, 3:03:11 AM2/11/20
to django-...@googlegroups.com
#31257: django migration has not been correctly applied for decimal_places - mysql
---------------------------------------+------------------------
Reporter: zbynekdrlik | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 2.2
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 |
---------------------------------------+------------------------
I use mysql in django and have these migration file
```
class Migration(migrations.Migration):

dependencies = [
('ft', '0010_auto_20191027_2255'),
]

operations = [
migrations.AlterField(
model_name='polozkydokl',
name='jedn_cena',
field=djmoney.models.fields.MoneyField(decimal_places=4,
default=Decimal('0'), default_currency='EUR', max_digits=12,
verbose_name='Jednotková cena'),
),
]

```
Migration has been already applied but in db there is still old
decimal_places=3 schema
`| jedn_cena | decimal(12,3) | NO | | NULL |
|
`

```
python3 manage.py sqlmigrate ft 0011_auto_20200103_1523
BEGIN;
--
-- Alter field jedn_cena on polozkydokl
--
COMMIT;

```

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

Django

unread,
Feb 11, 2020, 4:35:00 AM2/11/20
to django-...@googlegroups.com
#31257: Migrations don't apply changes for decimal_places on MySQL.
-----------------------------+--------------------------------------
Reporter: zbynekdrlik | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 2.2
Severity: Normal | Resolution: worksforme

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 felixxm):

* status: new => closed
* resolution: => worksforme


Old description:

> I use mysql in django and have these migration file
> ```
> class Migration(migrations.Migration):
>
> dependencies = [
> ('ft', '0010_auto_20191027_2255'),
> ]
>
> operations = [
> migrations.AlterField(
> model_name='polozkydokl',
> name='jedn_cena',
> field=djmoney.models.fields.MoneyField(decimal_places=4,
> default=Decimal('0'), default_currency='EUR', max_digits=12,
> verbose_name='Jednotková cena'),
> ),
> ]
>
> ```
> Migration has been already applied but in db there is still old
> decimal_places=3 schema
> `| jedn_cena | decimal(12,3) | NO | | NULL |
> |
> `
>
> ```
> python3 manage.py sqlmigrate ft 0011_auto_20200103_1523
> BEGIN;
> --
> -- Alter field jedn_cena on polozkydokl
> --
> COMMIT;
>
> ```

New description:

I use mysql in django and have these migration file
{{{
class Migration(migrations.Migration):

dependencies = [
('ft', '0010_auto_20191027_2255'),
]

operations = [
migrations.AlterField(
model_name='polozkydokl',
name='jedn_cena',
field=djmoney.models.fields.MoneyField(decimal_places=4,
default=Decimal('0'), default_currency='EUR', max_digits=12,
verbose_name='Jednotková cena'),
),
]

}}}

Migration has been already applied but in db there is still old
`decimal_places=3` schema
{{{
| jedn_cena | decimal(12,3) | NO | | NULL |
|
}}}
python3 manage.py sqlmigrate ft 0011_auto_20200103_1523
{{{
BEGIN;
--
-- Alter field jedn_cena on polozkydokl
--
COMMIT;
}}}

--

Comment:

I cannot reproduce this issues with `DecimalField` or
`djmoney.models.fields.MoneyField`.

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

Reply all
Reply to author
Forward
0 new messages