Changes between Initial Version and Version 1 of Ticket #37208, comment 1


Ignore:
Timestamp:
Jul 8, 2026, 3:13:14 AM (98 minutes ago)
Author:
Twili Spar

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #37208, comment 1

    initial v1  
    11== A quick fix
    2 I didn't changed the migration file, keep that as like:
     2
     3I played with the migration files, when I changed the `db_persist=True` in my `models.py` file, I knew that if I run `makemigrations` one more time, django will create a new migration file for me which changes my VIRTUAL column to STORED, that I didn't wanted, so I did like:
     4
     51. Updated the models.py, `db_persist=True`
     62. Run `makemigrations` one more time to have a migration file like:
    37{{{
    48operations = [
    5         migrations.AddField(
     9        migrations.AlterField(
    610            model_name="symbol",
    711            name="tmp",
    812            field=models.GeneratedField(
    9                 db_persist=False,  # 👈 NOTE, this hasn't changed
     13                db_persist=True,
    1014                expression=models.Q(("standard_symbol_tmp__isnull", False)),
    1115                null=True,
     
    1519    ]
    1620}}}
     213. I didn't want to run migrate with --fake, so I migration file to
     22{{{
     23operations = [
     24        migrations.SeparateDatabaseAndState(
     25            state_operations=[
     26                migrations.AlterField(
     27                    model_name="symbol",
     28                    name="tmp",
     29                    field=models.GeneratedField(
     30                        db_persist=True,
     31                        expression=models.Q(("standard_symbol_tmp__isnull", False)),
     32                        null=True,
     33                        output_field=models.BooleanField(),
     34                    ),
     35                ),
     36            ],
     37            database_operations=[],  # 👈 nothing runs against the DB
     38        ),
     39    ]
     40}}}
    1741
    18 And changed the model and set `db_persist=True`, then DID NOT create new migration file, then all things worked.
    19 I know I could also do a fake migration too.
     42Then when I run the `migrate`, Django's migration state updated and my DB DIDN'T CHANGED.
Back to Top