Skip to content

Commit

Permalink
Soft delete via a delete_at nullable column, rather than a bool
Browse files Browse the repository at this point in the history
  • Loading branch information
joshSzep committed Jul 26, 2024
1 parent 998cf89 commit 1047323
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 5.0.7 on 2024-07-26 18:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0002_typingspeed'),
]

operations = [
migrations.RemoveField(
model_name='challenge',
name='active',
),
migrations.RemoveField(
model_name='challengegroup',
name='active',
),
migrations.RemoveField(
model_name='typingspeed',
name='active',
),
migrations.AddField(
model_name='challenge',
name='deleted_at',
field=models.DateTimeField(blank=True, default=None, null=True),
),
migrations.AddField(
model_name='challengegroup',
name='deleted_at',
field=models.DateTimeField(blank=True, default=None, null=True),
),
migrations.AddField(
model_name='typingspeed',
name='deleted_at',
field=models.DateTimeField(blank=True, default=None, null=True),
),
]
2 changes: 1 addition & 1 deletion core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class CoreBaseModel(models.Model):
editable=False,
unique=True,
)
active = models.BooleanField(default=True) # Soft delete field
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
deleted_at = models.DateTimeField(null=True, blank=True, default=None)

class Meta:
abstract = True
Expand Down

0 comments on commit 1047323

Please sign in to comment.