mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-15 12:29:29 -05:00
Explicitly truncate during migration
This commit is contained in:
parent
2506b479e6
commit
1af66c8125
@ -5,6 +5,12 @@ import datetime
|
|||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.db.models.functions import TruncDate
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_date(apps, schema_editor):
|
||||||
|
Document = apps.get_model("documents", "Document")
|
||||||
|
Document.objects.update(created_date=TruncDate("created"))
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@ -13,6 +19,21 @@ class Migration(migrations.Migration):
|
|||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="document",
|
||||||
|
name="created_date",
|
||||||
|
field=models.DateField(null=True),
|
||||||
|
),
|
||||||
|
migrations.RunPython(migrate_date, reverse_code=migrations.RunPython.noop),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="document",
|
||||||
|
name="created",
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="document",
|
||||||
|
old_name="created_date",
|
||||||
|
new_name="created",
|
||||||
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name="document",
|
model_name="document",
|
||||||
name="created",
|
name="created",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user