Skip to content

Commit

Permalink
chore: Rename datalayer id to old_id
Browse files Browse the repository at this point in the history
  • Loading branch information
almet committed Feb 29, 2024
1 parent f82897f commit 1d5ac14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion umap/migrations/0018_datalayer_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
EXECUTE 'ALTER TABLE umap_datalayer DROP CONSTRAINT ' || (
SELECT indexname
FROM pg_indexes
WHERE tablename = 'umap_datalayer' AND indexname LIKE '%pk'
WHERE tablename = 'umap_datalayer' AND indexname LIKE '%pk%'
);
END $$;
"""
Expand Down Expand Up @@ -40,6 +40,10 @@ class Migration(migrations.Migration):
migrations.AlterField(
"datalayer", name="id", field=models.IntegerField(null=True, blank=True)
),
# Rename "id" to "old id"
migrations.RenameField(
model_name="datalayer", old_name="id", new_name="old_id"
),
# … to put it back on the "uuid"
migrations.AlterField(
model_name="datalayer",
Expand All @@ -52,5 +56,7 @@ class Migration(migrations.Migration):
serialize=False,
),
),
# When applying the migration backwards, we need to drop the pk index
# Before addding a new one.
migrations.RunSQL(migrations.RunSQL.noop, reverse_sql=drop_index),
]
2 changes: 1 addition & 1 deletion umap/migrations/0019_migrate_internal_remote_datalayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def migrate_datalayers(apps, schema_editor):
remote_id = match.group("datalayer_id")
map_id = match.group("map_id")
try:
remote_uuid = DataLayer.objects.get(id=remote_id).uuid
remote_uuid = DataLayer.objects.get(old_id=remote_id).uuid
except DataLayer.DoesNotExist:
pass
else:
Expand Down

0 comments on commit 1d5ac14

Please sign in to comment.