diff --git a/viewer/migrations/0074_auto_20241018_1028.py b/viewer/migrations/0074_auto_20241018_1028.py index 8465218e..201f570c 100644 --- a/viewer/migrations/0074_auto_20241018_1028.py +++ b/viewer/migrations/0074_auto_20241018_1028.py @@ -19,66 +19,28 @@ def temporary_name(apps, schema_editor): def reverse_temporary_name(apps, schema_editor): pass - def relink_type(apps, schema_editor): - CompoundIdentifier = apps.get_model('viewer', 'CompoundIdentifier') - CompoundIdentifierType = apps.get_model('viewer', 'CompoundIdentifierType') - - for idf in CompoundIdentifier.objects.all(): - idf.type = CompoundIdentifierType.objects.get(name=idf.name_type) - idf.save() - def reverse_relink_type(apps, schema_editor): - pass - - # with my edits: + # this contains some edits, the automatically constructed + # migration was not in the correct order, so I had to move things + # around to preserve data operations = [ - # migrations.RunPython(lambda apps, schema_editor: print('first migration')), - # migrations.AlterField( - # model_name='compoundidentifiertype', - # name='name', - # field=models.TextField(unique=True), - # ), - # add new foreign key field to CompoundIdentifier - # migrations.RunPython(lambda apps, schema_editor: print('second migration')), - # migrations.AddField( - # model_name='compoundidentifier', - # name='name_type', - # field=models.ForeignKey(null=True, to_field='name', on_delete=django.db.models.deletion.CASCADE, to='viewer.compoundidentifiertype'), - # ), migrations.AddField( model_name='compoundidentifier', name='name_type', field=models.TextField(null=True), ), - # populate values in new field - migrations.RunPython(lambda apps, schema_editor: print('third migration, data')), migrations.RunPython(temporary_name, reverse_temporary_name), - - # continue with the original migration, remove field, set the new pk - migrations.RunPython(lambda apps, schema_editor: print('fourth migration')), migrations.RemoveField( model_name='compoundidentifier', name='type', ), - migrations.RunPython(lambda apps, schema_editor: print('fifth migration')), migrations.RemoveField( model_name='compoundidentifiertype', name='id', ), - # migrations.AlterField( - # model_name='compoundidentifier', - # name='name', - # field=models.TextField(), - # ), - migrations.RunPython(lambda apps, schema_editor: print('6th migration')), migrations.AlterField( model_name='compoundidentifiertype', name='name', field=models.TextField(primary_key=True, serialize=False), ), - # migrations.RemoveField( - # model_name='compoundidentifiertype', - # name='id', - # ), - ] diff --git a/viewer/migrations/0075_remove_compoundidentifier_type.py b/viewer/migrations/0075_remove_compoundidentifier_type.py index d33043ee..41745183 100644 --- a/viewer/migrations/0075_remove_compoundidentifier_type.py +++ b/viewer/migrations/0075_remove_compoundidentifier_type.py @@ -22,11 +22,6 @@ def reverse_relink_type(apps, schema_editor): pass operations = [ - migrations.RunPython(lambda apps, schema_editor: print('migration 0075')), - # migrations.RemoveField( - # model_name='compoundidentifier', - # name='type', - # ), migrations.AddField( model_name='compoundidentifier', name='type', diff --git a/viewer/migrations/0076_compoundidentifier_type.py b/viewer/migrations/0076_compoundidentifier_type.py index f136b25d..ff568900 100644 --- a/viewer/migrations/0076_compoundidentifier_type.py +++ b/viewer/migrations/0076_compoundidentifier_type.py @@ -11,18 +11,6 @@ class Migration(migrations.Migration): ] operations = [ - # migrations.AddField( - # model_name='compoundidentifier', - # name='type', - # field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='viewer.compoundidentifiertype'), - # ), - # continuing the migration tweak that started in 0074 - migrations.RunPython(lambda apps, schema_editor: print('migration 0076')), - # migrations.RenameField( - # model_name='compoundidentifier', - # old_name='name_type', - # new_name='type', - # ), migrations.RemoveField( model_name='compoundidentifier', name='name_type', diff --git a/viewer/migrations/0077_alter_compoundidentifier_type.py b/viewer/migrations/0077_alter_compoundidentifier_type.py index 45be75ea..b92d0067 100644 --- a/viewer/migrations/0077_alter_compoundidentifier_type.py +++ b/viewer/migrations/0077_alter_compoundidentifier_type.py @@ -11,7 +11,6 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython(lambda apps, schema_editor: print('migration 0077')), migrations.AlterField( model_name='compoundidentifier', name='type', diff --git a/viewer/migrations/0078_compoundidentifier_unique_compoundidentifier.py b/viewer/migrations/0078_compoundidentifier_unique_compoundidentifier.py index bc742ea4..bd5be56f 100644 --- a/viewer/migrations/0078_compoundidentifier_unique_compoundidentifier.py +++ b/viewer/migrations/0078_compoundidentifier_unique_compoundidentifier.py @@ -10,7 +10,6 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython(lambda apps, schema_editor: print('migration 0078')), migrations.AddConstraint( model_name='compoundidentifier', constraint=models.UniqueConstraint(fields=('type', 'compound', 'name'), name='unique_compoundidentifier'), diff --git a/viewer/migrations/0079_auto_20241023_1439.py b/viewer/migrations/0079_auto_20241023_1439.py index 5bfd26db..6ae4c2c9 100644 --- a/viewer/migrations/0079_auto_20241023_1439.py +++ b/viewer/migrations/0079_auto_20241023_1439.py @@ -10,27 +10,6 @@ class Migration(migrations.Migration): ('viewer', '0078_compoundidentifier_unique_compoundidentifier'), ] - # def temporary_name(apps, schema_editor): - # Compound = apps.get_model('viewer', 'Compound') - - # for compound in Compound.objects.all(): - # compound.id_current_identifier = compound.type.name - # compound.save() - - # def reverse_temporary_name(apps, schema_editor): - # pass - - # def relink_type(apps, schema_editor): - # CompoundIdentifier = apps.get_model('viewer', 'CompoundIdentifier') - # CompoundIdentifierType = apps.get_model('viewer', 'CompoundIdentifierType') - - # for idf in CompoundIdentifier.objects.all(): - # idf.type = CompoundIdentifierType.objects.get(name=idf.name_type) - # idf.save() - - # def reverse_relink_type(apps, schema_editor): - # pass - def move_contents(apps, schema_editor): Compound = apps.get_model('viewer', 'Compound') @@ -45,18 +24,11 @@ def reverse_move_contents(apps, schema_editor): operations = [ - migrations.RunPython(lambda apps, schema_editor: print('migration 0079, first')), migrations.RemoveField( model_name='compound', name='all_identifiers', ), - migrations.RunPython(lambda apps, schema_editor: print('migration 0079, second')), - # migrations.AddField( - # model_name='compoundid', - # name='name_current_identifier', - # field=models.TextField(null=True), - # ), migrations.RunPython(move_contents, reverse_move_contents), migrations.RemoveField( model_name='compound', diff --git a/viewer/migrations/0080_alter_compoundidentifier_compound.py b/viewer/migrations/0080_alter_compoundidentifier_compound.py index c940b018..8b0cfbfa 100644 --- a/viewer/migrations/0080_alter_compoundidentifier_compound.py +++ b/viewer/migrations/0080_alter_compoundidentifier_compound.py @@ -11,7 +11,6 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython(lambda apps, schema_editor: print('migration 0080')), migrations.AlterField( model_name='compoundidentifier', name='compound', diff --git a/viewer/migrations/0081_alter_compound_current_identifier.py b/viewer/migrations/0081_alter_compound_current_identifier.py index ee701680..f8fb0f26 100644 --- a/viewer/migrations/0081_alter_compound_current_identifier.py +++ b/viewer/migrations/0081_alter_compound_current_identifier.py @@ -11,7 +11,6 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython(lambda apps, schema_editor: print('migration 0081')), migrations.AlterField( model_name='compound', name='current_identifier',