Skip to content

Migration 03 branch. #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: feature/migration-test-01
Choose a base branch
from
28 changes: 28 additions & 0 deletions migrations/0002_testmodel_created_by.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2021-07-08 13:04
from __future__ import unicode_literals

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("demo", "0001_initial"),
]

operations = [
migrations.AddField(
model_name="testmodel",
name="created_by",
field=models.ForeignKey(
null=True,
blank=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
]
40 changes: 40 additions & 0 deletions migrations/0003_auto_20210708_1317.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2021-07-08 13:17
from __future__ import unicode_literals

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("demo", "0002_testmodel_created_by"),
]

operations = [
migrations.AddField(
model_name="testmodel",
name="updated_by",
field=models.ForeignKey(
null=True,
blank=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name="testmodel",
name="created_by",
field=models.ForeignKey(
null=True,
blank=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
]
16 changes: 16 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import django
from django.conf import settings
from django.db import models
from django.utils.translation import gettext_lazy as _

@@ -9,6 +10,21 @@ class TestModel(models.Model):
name = models.CharField(max_length=500)
age = models.PositiveIntegerField(default=500)

created_by = models.ForeignKey(
settings.AUTH_USER_MODEL,
null=True,
related_name="+",
on_delete=models.CASCADE,
blank=True,
)
updated_by = models.ForeignKey(
settings.AUTH_USER_MODEL,
null=True,
related_name="+",
on_delete=models.CASCADE,
blank=True,
)

if django.VERSION < (2, 1):
active = models.NullBooleanField()
else: