Skip to content

Commit

Permalink
Merge pull request #1697 from dandi/zarr-rename-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnesbitt authored Oct 12, 2023
2 parents 6c959f6 + 3d52b4b commit 29b4962
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Generated by Django 4.1.11 on 2023-10-04 15:34

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
('zarr', '0002_remove_zarruploadfile_zarr_archive_and_more'),
]

# This renaming is necessary as there is a mismatch between what Django thinks the name of
# database indexes/constraints are, and what they actually are.
operations = [
# Tables
migrations.AlterModelTable(name='zarrarchive', table=None),
migrations.AlterModelTable(name='embargoedzarrarchive', table=None),
# Sequences
migrations.RunSQL(
'ALTER SEQUENCE api_zarrarchive_id_seq RENAME to zarr_zarrarchive_id_seq;'
),
migrations.RunSQL(
'ALTER SEQUENCE api_embargoedzarrarchive_id_seq RENAME to '
'zarr_embargoedzarrarchive_id_seq;'
),
# zarr_id unique constraint
migrations.RunSQL(
'ALTER TABLE zarr_zarrarchive RENAME CONSTRAINT "api_zarrarchive_zarr_id_key" to '
'"zarr_zarrarchive_zarr_id_key";'
),
migrations.RunSQL(
'ALTER TABLE zarr_embargoedzarrarchive RENAME CONSTRAINT '
'"api_embargoedzarrarchive_zarr_id_key" to "zarr_embargoedzarrarchive_zarr_id_key";'
),
# primary key index
migrations.RunSQL('ALTER INDEX "api_zarrarchive_pkey" RENAME TO "zarr_zarrarchive_pkey";'),
migrations.RunSQL(
'ALTER INDEX "api_embargoedzarrarchive_pkey" RENAME TO '
'"zarr_embargoedzarrarchive_pkey";'
),
# dandiset_id index
migrations.RunSQL(
'ALTER INDEX "api_zarrarchive_dandiset_id_68510762" RENAME TO '
'"zarr_zarrarchive_dandiset_id_2fdb93be";'
),
migrations.RunSQL(
'ALTER INDEX "api_embargoedzarrarchive_dandiset_id_b61f0a08" RENAME TO '
'"zarr_embargoedzarrarchive_dandiset_id_9a6f3365";'
),
# dandiset_id foreign key constraint
migrations.RunSQL(
'ALTER TABLE zarr_zarrarchive RENAME CONSTRAINT '
'"api_zarrarchive_dandiset_id_68510762_fk" TO '
'"zarr_zarrarchive_dandiset_id_2fdb93be_fk";'
),
migrations.RunSQL(
'ALTER TABLE zarr_embargoedzarrarchive RENAME CONSTRAINT '
'"api_embargoedzarrarchive_dandiset_id_b61f0a08_fk" TO '
'"zarr_embargoedzarrarchive_dandiset_id_9a6f3365_fk";'
),
# Constraints defined in Django
migrations.RunSQL(
'ALTER TABLE zarr_zarrarchive RENAME CONSTRAINT '
'"api-zarrarchive-consistent-checksum-status" TO '
'"zarr-zarrarchive-consistent-checksum-status";'
),
migrations.RunSQL(
'ALTER TABLE zarr_zarrarchive RENAME CONSTRAINT "api-zarrarchive-unique-name" TO '
'"zarr-zarrarchive-unique-name";'
),
migrations.RunSQL(
'ALTER TABLE zarr_embargoedzarrarchive RENAME CONSTRAINT '
'"api-embargoedzarrarchive-consistent-checksum-status" TO '
'"zarr-embargoedzarrarchive-consistent-checksum-status";'
),
migrations.RunSQL(
'ALTER TABLE zarr_embargoedzarrarchive RENAME CONSTRAINT '
'"api-embargoedzarrarchive-unique-name" TO "zarr-embargoedzarrarchive-unique-name";'
),
]
6 changes: 0 additions & 6 deletions dandiapi/zarr/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ def delete_files(self, paths: list[str]):


class ZarrArchive(BaseZarrArchive):
class Meta(BaseZarrArchive.Meta):
db_table = 'api_zarrarchive'

storage = get_storage()
dandiset = models.ForeignKey(Dandiset, related_name='zarr_archives', on_delete=models.CASCADE)

Expand All @@ -105,9 +102,6 @@ def s3_path(self, zarr_path: str | Path):


class EmbargoedZarrArchive(BaseZarrArchive):
class Meta(BaseZarrArchive.Meta):
db_table = 'api_embargoedzarrarchive'

storage = get_embargo_storage()
dandiset = models.ForeignKey(
Dandiset, related_name='embargoed_zarr_archives', on_delete=models.CASCADE
Expand Down

0 comments on commit 29b4962

Please sign in to comment.