Open exalate-issue-sync[bot] opened 1 week ago
Laura Beaufort commented: After talking to [~accountid:712020:2a1493e5-adee-45bd-b27e-868a5c8d3f62] I think we can use the {{preserve_default=False}} field to achieve this. I’ll verify this locally.
{noformat}# Generated by Django 5.1.1 on 2024-11-14 21:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cash_on_hand', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='cashonhandyearly',
name='cash_on_hand',
field=models.DecimalField(decimal_places=2, default=0, max_digits=11),
preserve_default=False,
),
migrations.AlterField(
model_name='cashonhandyearly',
name='year',
field=models.TextField(default=2020, unique=True),
preserve_default=False,
),
]{noformat}
Laura Beaufort commented: I also verified on dev/stage/test that none of these fields are {{NULL}}:
select count(*) from cash_on_hand_yearly where cash_on_hand is null or year is null;# dev: 0
Create a migration that addresses the mismatch.
QA Notes
null
DEV Notes
The model definition has cash_on_hand and year as non-nullable. The initial migration has them as nullable. Because the initial migration has already been run, we can’t just use AlterField in a new migration. We’ll need to do a swap where we put the values into a non-nullable placeholder, remove the old cash_on_hand and year columns, then add new ones with the correct configuration.
The placeholder columns will need to have default values for the theoretical scenario where the original columns are null. Practically, there will be none that are null, but this step ensures the schema updates will work.
Design
null
See full ticket and images here: FECFILE-1765