diff --git a/backend/toolshed/migrations/0018_ownerstoragelocationsequence.py b/backend/toolshed/migrations/0018_ownerstoragelocationsequence.py new file mode 100644 index 0000000..cc405b0 --- /dev/null +++ b/backend/toolshed/migrations/0018_ownerstoragelocationsequence.py @@ -0,0 +1,23 @@ +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('toolshed', '0017_inventoryitem_id_not_null_and_unique'), + ] + + operations = [ + migrations.CreateModel( + name='OwnerStorageLocationSequence', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('last_id', models.PositiveIntegerField(default=0)), + ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', + to=settings.AUTH_USER_MODEL, unique=True)), + ], + ), + ] diff --git a/backend/toolshed/migrations/0019_rename_id_storagelocation_internal_id.py b/backend/toolshed/migrations/0019_rename_id_storagelocation_internal_id.py new file mode 100644 index 0000000..5d8f4fd --- /dev/null +++ b/backend/toolshed/migrations/0019_rename_id_storagelocation_internal_id.py @@ -0,0 +1,21 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('toolshed', '0018_ownerstoragelocationsequence'), + ] + + operations = [ + migrations.RenameField( + model_name='storagelocation', + old_name='id', + new_name='internal_id', + ), + migrations.AlterField( + model_name='storagelocation', + name='internal_id', + field=models.AutoField(primary_key=True, serialize=False), + ), + ] diff --git a/backend/toolshed/migrations/0020_storagelocation_id.py b/backend/toolshed/migrations/0020_storagelocation_id.py new file mode 100644 index 0000000..0c27590 --- /dev/null +++ b/backend/toolshed/migrations/0020_storagelocation_id.py @@ -0,0 +1,16 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('toolshed', '0019_rename_id_storagelocation_internal_id'), + ] + + operations = [ + migrations.AddField( + model_name='storagelocation', + name='id', + field=models.PositiveIntegerField(editable=False, null=True), + ), + ] diff --git a/backend/toolshed/migrations/0021_backfill_storagelocation_id.py b/backend/toolshed/migrations/0021_backfill_storagelocation_id.py new file mode 100644 index 0000000..3516cd2 --- /dev/null +++ b/backend/toolshed/migrations/0021_backfill_storagelocation_id.py @@ -0,0 +1,40 @@ +from django.db import migrations + + +def collapse_ids(apps, schema_editor): + """Collapse each owner's StorageLocation ids from the sparse global range they had before this + migration down to a continuous 1..N range, in original creation order (internal_id order). Then + seed OwnerStorageLocationSequence so future allocation continues right after.""" + StorageLocation = apps.get_model('toolshed', 'StorageLocation') + OwnerStorageLocationSequence = apps.get_model('toolshed', 'OwnerStorageLocationSequence') + + scope = None + next_id = 0 + counts = {} + for location in StorageLocation.objects.order_by('owner_id', 'internal_id'): + key = location.owner_id + if key != scope: + scope = key + next_id = 0 + next_id += 1 + location.id = next_id + location.save(update_fields=['id']) + counts[key] = next_id + + for owner_id, count in counts.items(): + OwnerStorageLocationSequence.objects.update_or_create(owner_id=owner_id, defaults={'last_id': count}) + + +def noop_reverse(apps, schema_editor): + pass + + +class Migration(migrations.Migration): + + dependencies = [ + ('toolshed', '0020_storagelocation_id'), + ] + + operations = [ + migrations.RunPython(collapse_ids, noop_reverse), + ] diff --git a/backend/toolshed/migrations/0022_storagelocation_id_not_null_and_unique.py b/backend/toolshed/migrations/0022_storagelocation_id_not_null_and_unique.py new file mode 100644 index 0000000..7c5b178 --- /dev/null +++ b/backend/toolshed/migrations/0022_storagelocation_id_not_null_and_unique.py @@ -0,0 +1,20 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('toolshed', '0021_backfill_storagelocation_id'), + ] + + operations = [ + migrations.AlterField( + model_name='storagelocation', + name='id', + field=models.PositiveIntegerField(editable=False), + ), + migrations.AddConstraint( + model_name='storagelocation', + constraint=models.UniqueConstraint(fields=('owner', 'id'), name='storagelocation_unique_owner_scoped_id'), + ), + ] diff --git a/frontend/src/assets/fonts/pixel/Silkscreen.ttf b/frontend/src/assets/fonts/pixel/Silkscreen.ttf new file mode 100644 index 0000000..8caff81 Binary files /dev/null and b/frontend/src/assets/fonts/pixel/Silkscreen.ttf differ