Skip to content

Commit 3398bbc

Browse files
committed
Move object_created to new migration step
1 parent f3120b8 commit 3398bbc

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

ansible_base/rbac/migrations/0004_remote_permissions_additions.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -160,28 +160,6 @@ class Migration(migrations.Migration):
160160
model_name='roleevaluationuuid',
161161
name='dab_rbac_ro_role_id_4fe905_idx',
162162
),
163-
# Added field for a checksum like purpose for remote models
164-
migrations.AddField(
165-
model_name='roleuserassignment',
166-
name='object_created',
167-
field=models.DateTimeField(help_text='The created timestamp of related object, if applicable.', null=True),
168-
),
169-
migrations.AddField(
170-
model_name='roleteamassignment',
171-
name='object_created',
172-
field=models.DateTimeField(help_text='The created timestamp of related object, if applicable.', null=True),
173-
),
174-
# Make assignment created timestamp backdateable
175-
migrations.AlterField(
176-
model_name='roleteamassignment',
177-
name='created',
178-
field=models.DateTimeField(default=django.utils.timezone.now, editable=False, help_text='The date/time this resource was created.'),
179-
),
180-
migrations.AlterField(
181-
model_name='roleuserassignment',
182-
name='created',
183-
field=models.DateTimeField(default=django.utils.timezone.now, editable=False, help_text='The date/time this resource was created.'),
184-
),
185163
# Fields unique to DAB RBAC and not generally shared with ContentType or Permission
186164
migrations.AddField(
187165
model_name='dabcontenttype',

ansible_base/rbac/migrations/0005_remote_permissions_data.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Generated by Django 4.2.23 on 2025-06-30 12:48
2-
# Modified by Claude (Sonnet 4) - Added populate_object_created_field data migration
32

43
import logging
54

@@ -24,11 +23,6 @@ def create_types_if_needed(apps, schema_editor):
2423
create_DAB_contenttypes(apps=apps)
2524

2625

27-
def populate_object_created_field(apps, schema_editor):
28-
"""Populate the object_created field for existing role assignments."""
29-
from ._utils import populate_object_created_field as _populate_object_created_field
30-
return _populate_object_created_field(apps, schema_editor)
31-
3226

3327
def migrate_content_type(apps, schema_editor):
3428
ct_cls = apps.get_model('dab_rbac', 'DABContentType')
@@ -75,5 +69,4 @@ class Migration(migrations.Migration):
7569
operations = [
7670
migrations.RunPython(create_types_if_needed, migrations.RunPython.noop),
7771
migrations.RunPython(migrate_content_type, migrations.RunPython.noop),
78-
migrations.RunPython(populate_object_created_field, migrations.RunPython.noop),
7972
]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Generated by Django 4.2.21 on 2025-09-10 17:11
2+
# Modified by Claude (Sonnet 4) - Added object_created field and data migration
3+
4+
from django.db import migrations, models
5+
import django.utils.timezone
6+
7+
8+
def populate_object_created_field(apps, schema_editor):
9+
"""Populate the object_created field for existing role assignments."""
10+
from ._utils import populate_object_created_field as _populate_object_created_field
11+
return _populate_object_created_field(apps, schema_editor)
12+
13+
14+
class Migration(migrations.Migration):
15+
16+
dependencies = [
17+
('dab_rbac', '0008_remote_permissions_cleanup'),
18+
]
19+
20+
operations = [
21+
# Added field for a checksum like purpose for remote models
22+
migrations.AddField(
23+
model_name='roleuserassignment',
24+
name='object_created',
25+
field=models.DateTimeField(help_text='The created timestamp of related object, if applicable.', null=True),
26+
),
27+
migrations.AddField(
28+
model_name='roleteamassignment',
29+
name='object_created',
30+
field=models.DateTimeField(help_text='The created timestamp of related object, if applicable.', null=True),
31+
),
32+
# Make assignment created timestamp backdateable
33+
migrations.AlterField(
34+
model_name='roleteamassignment',
35+
name='created',
36+
field=models.DateTimeField(default=django.utils.timezone.now, editable=False, help_text='The date/time this resource was created.'),
37+
),
38+
migrations.AlterField(
39+
model_name='roleuserassignment',
40+
name='created',
41+
field=models.DateTimeField(default=django.utils.timezone.now, editable=False, help_text='The date/time this resource was created.'),
42+
),
43+
# Data migration to populate object_created field
44+
migrations.RunPython(populate_object_created_field, migrations.RunPython.noop),
45+
]

0 commit comments

Comments
 (0)