Only use implicit AutoFields for primary keys

django really doesn't handle updating PKs well, so don't bother.

Reset migrations, because I don't really have enough data for it to be
worth the effort to migrate
This commit is contained in:
Adam Goldsmith 2021-05-19 13:28:38 -04:00
parent e19df73642
commit cf6bf97e45
7 changed files with 44 additions and 111 deletions

25
Pipfile.lock generated
View File

@ -72,14 +72,6 @@
"index": "pypi",
"version": "==1.4.8"
},
"importlib-metadata": {
"hashes": [
"sha256:8c501196e49fb9df5df43833bdb1e4328f64847763ec8a50703148b73784d581",
"sha256:d7eb1dea6d6a6086f8be21784cc9e3bcfa55872b52309bc5fad53a8ea444465d"
],
"markers": "python_version < '3.8'",
"version": "==4.0.1"
},
"markdown": {
"hashes": [
"sha256:31b5b491868dcc87d6c24b7e3d19a0d730d59d3e46f4eea6430a321bed387a49",
@ -217,29 +209,12 @@
"markers": "python_version >= '3.5'",
"version": "==0.4.1"
},
"typing-extensions": {
"hashes": [
"sha256:0ac0f89795dd19de6b97debb0c6af1c70987fd80a2d62d1958f7e56fcc31b497",
"sha256:50b6f157849174217d0656f99dc82fe932884fb250826c18350e159ec6cdf342",
"sha256:779383f6086d90c99ae41cf0ff39aac8a7937a9283ce0a414e5dd782f4c94a84"
],
"markers": "python_version < '3.8'",
"version": "==3.10.0.0"
},
"webencodings": {
"hashes": [
"sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78",
"sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"
],
"version": "==0.5.1"
},
"zipp": {
"hashes": [
"sha256:3607921face881ba3e026887d8150cca609d517579abe052ac81fc5aeffdbd76",
"sha256:51cb66cc54621609dd593d1787f286ee42a5c0adbb4b29abea5a63edc3e03098"
],
"markers": "python_version >= '3.6'",
"version": "==3.4.1"
}
},
"develop": {}

View File

@ -62,6 +62,8 @@ TEMPLATES = [
},
]
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
WSGI_APPLICATION = 'recmaint.wsgi.application'

View File

@ -1,8 +1,9 @@
# Generated by Django 3.1.3 on 2020-12-02 20:39
# Generated by Django 3.2.3 on 2021-05-19 18:05
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import markdownx.models
class Migration(migrations.Migration):
@ -11,34 +12,65 @@ class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('auth', '0012_alter_user_first_name_max_length'),
]
operations = [
migrations.CreateModel(
name='Tool',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('asset_tag', models.CharField(max_length=10, primary_key=True, serialize=False)),
('asset_tag', models.CharField(blank=True, max_length=10, unique=True)),
],
),
migrations.CreateModel(
name='Task',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('slug', models.SlugField(primary_key=True, serialize=False)),
('slug', models.SlugField()),
('description', markdownx.models.MarkdownxField(blank=True)),
('recurrence_interval', models.CharField(max_length=200)),
('recurrence_base', models.DateField(blank=True, null=True)),
('tool', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tasks.tool')),
],
options={
'unique_together': {('tool', 'slug')},
},
),
migrations.CreateModel(
name='Event',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateField()),
('notes', models.TextField(blank=True)),
('notes', markdownx.models.MarkdownxField(blank=True)),
('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tasks.task')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='GroupToolSubscription',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('days_before', models.PositiveIntegerField()),
('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.group')),
('tool', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tasks.tool')),
],
options={
'unique_together': {('group', 'tool')},
},
),
migrations.CreateModel(
name='GroupTaskSubscription',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('days_before', models.PositiveIntegerField()),
('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.group')),
('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tasks.task')),
],
options={
'unique_together': {('group', 'task')},
},
),
]

View File

@ -1,39 +0,0 @@
# Generated by Django 3.1.4 on 2020-12-17 16:46
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
('tasks', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='GroupToolSubscription',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('days_before', models.PositiveIntegerField()),
('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.group')),
('tool', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tasks.tool')),
],
options={
'unique_together': {('group', 'tool')},
},
),
migrations.CreateModel(
name='GroupTaskSubscription',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('days_before', models.PositiveIntegerField()),
('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.group')),
('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tasks.task')),
],
options={
'unique_together': {('group', 'task')},
},
),
]

View File

@ -1,19 +0,0 @@
# Generated by Django 3.1.4 on 2020-12-22 19:17
from django.db import migrations
import markdownx.models
class Migration(migrations.Migration):
dependencies = [
('tasks', '0002_grouptasksubscription_grouptoolsubscription'),
]
operations = [
migrations.AlterField(
model_name='event',
name='notes',
field=markdownx.models.MarkdownxField(blank=True),
),
]

View File

@ -1,19 +0,0 @@
# Generated by Django 3.1.4 on 2020-12-22 19:37
from django.db import migrations
import markdownx.models
class Migration(migrations.Migration):
dependencies = [
('tasks', '0003_auto_20201222_1417'),
]
operations = [
migrations.AddField(
model_name='task',
name='description',
field=markdownx.models.MarkdownxField(blank=True),
),
]

View File

@ -9,7 +9,7 @@ from markdownx.models import MarkdownxField
class Tool(models.Model):
name = models.CharField(max_length=200)
asset_tag = models.CharField(max_length=10, primary_key=True)
asset_tag = models.CharField(max_length=10, unique=True, blank=True)
def __str__(self):
return f"{self.name} - {self.asset_tag}"
@ -20,12 +20,15 @@ class Tool(models.Model):
class Task(models.Model):
name = models.CharField(max_length=200)
slug = models.SlugField(primary_key=True)
slug = models.SlugField()
tool = models.ForeignKey(Tool, on_delete=models.CASCADE)
description = MarkdownxField(blank=True)
recurrence_interval = models.CharField(max_length=200)
recurrence_base = models.DateField(null=True, blank=True)
class Meta:
unique_together = (("tool", "slug"),)
def __str__(self):
return f"{self.tool.name}: {self.name}"
@ -82,7 +85,6 @@ class GroupToolSubscription(SubscriptionSettings):
task=task)
class Meta:
# Django doesn't support multiple-column primary keys
unique_together = (("group", "tool"),)
def __str__(self):
@ -94,7 +96,6 @@ class GroupTaskSubscription(SubscriptionSettings):
task = models.ForeignKey(Task, on_delete=models.CASCADE)
class Meta:
# Django doesn't support multiple-column primary keys
unique_together = (("group", "task"),)
@property