From 171d5d633ec613958cbb718b367e3e768c415766 Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Thu, 5 Dec 2019 20:43:47 +0000 Subject: [PATCH] CMULTI is a thing, and therefore a max prefix length of 5 cannot be a thing --- ..._1937_squashed_0009_auto_20191205_2041.py} | 22 ++++++++++++++++--- assets/models.py | 4 ++-- 2 files changed, 21 insertions(+), 5 deletions(-) rename assets/migrations/{0008_auto_20191205_1937.py => 0008_auto_20191205_1937_squashed_0009_auto_20191205_2041.py} (67%) diff --git a/assets/migrations/0008_auto_20191205_1937.py b/assets/migrations/0008_auto_20191205_1937_squashed_0009_auto_20191205_2041.py similarity index 67% rename from assets/migrations/0008_auto_20191205_1937.py rename to assets/migrations/0008_auto_20191205_1937_squashed_0009_auto_20191205_2041.py index a2a87484..15898dc8 100644 --- a/assets/migrations/0008_auto_20191205_1937.py +++ b/assets/migrations/0008_auto_20191205_1937_squashed_0009_auto_20191205_2041.py @@ -1,8 +1,7 @@ -# Generated by Django 2.0.13 on 2019-12-05 19:37 +# Generated by Django 2.0.13 on 2019-12-05 20:42 -import re from django.db import migrations, models -import django.db.migrations +import django.db.migrations.operations.special def forwards(apps, schema_editor): AssetModel = apps.get_model('assets', 'Asset') @@ -20,8 +19,15 @@ def forwards(apps, schema_editor): row.save(update_fields=['asset_id', 'asset_id_prefix', 'asset_id_number']) +# Functions from the following migrations need manual copying. +# Move them and any dependencies into this file, then update the +# RunPython operations to refer to the local versions: +# assets.migrations.0008_auto_20191205_1937 + class Migration(migrations.Migration): + replaces = [('assets', '0008_auto_20191205_1937'), ('assets', '0009_auto_20191205_2041')] + dependencies = [ ('assets', '0007_auto_20190108_0202_squashed_0014_auto_20191017_2052'), ] @@ -45,4 +51,14 @@ class Migration(migrations.Migration): name='asset', options={'ordering': ['asset_id_prefix', 'asset_id_number'], 'permissions': (('asset_finance', 'Can see financial data for assets'), ('view_asset', 'Can view an asset'))}, ), + migrations.AlterField( + model_name='asset', + name='asset_id', + field=models.CharField(max_length=15, unique=True), + ), + migrations.AlterField( + model_name='asset', + name='asset_id_prefix', + field=models.CharField(default='', max_length=8), + ), ] diff --git a/assets/models.py b/assets/models.py index b6793cdd..993c8c34 100644 --- a/assets/models.py +++ b/assets/models.py @@ -64,7 +64,7 @@ class Asset(models.Model): ) parent = models.ForeignKey(to='self', related_name='asset_parent', blank=True, null=True, on_delete=models.SET_NULL) - asset_id = models.CharField(max_length=10, unique=True) + asset_id = models.CharField(max_length=15, unique=True) description = models.CharField(max_length=120) category = models.ForeignKey(to=AssetCategory, on_delete=models.CASCADE) status = models.ForeignKey(to=AssetStatus, on_delete=models.CASCADE) @@ -88,7 +88,7 @@ class Asset(models.Model): # Hidden asset_id components # For example, if asset_id was "C1001" then asset_id_prefix would be "C" and number "1001" - asset_id_prefix = models.CharField(max_length=5, default="") + asset_id_prefix = models.CharField(max_length=8, default="") asset_id_number = models.IntegerField(default=1) def get_available_asset_id(wanted_prefix=""):