Skip to content

Commit

Permalink
Rebase migrations onto core 0091
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellweg committed Dec 5, 2024
1 parent 7c3ebbf commit 7302fa9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 34 deletions.
14 changes: 7 additions & 7 deletions pulp_gem/app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.2.5 on 2019-09-19 15:56
# Generated by Django 4.2.16 on 2024-12-05 16:05

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -9,14 +9,14 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('core', '0005_progressreport_code'),
('core', '0091_systemid'),
]

operations = [
migrations.CreateModel(
name='GemPublication',
fields=[
('publication_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='gem_gempublication', serialize=False, to='core.Publication')),
('publication_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='gem_gempublication', serialize=False, to='core.publication')),
],
options={
'default_related_name': '%(app_label)s_%(model_name)s',
Expand All @@ -26,7 +26,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='GemRemote',
fields=[
('remote_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='gem_gemremote', serialize=False, to='core.Remote')),
('remote_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='gem_gemremote', serialize=False, to='core.remote')),
],
options={
'default_related_name': '%(app_label)s_%(model_name)s',
Expand All @@ -36,8 +36,8 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='GemDistribution',
fields=[
('basedistribution_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='gem_gemdistribution', serialize=False, to='core.BaseDistribution')),
('publication', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='gem_gemdistribution', to='core.Publication')),
('basedistribution_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='gem_gemdistribution', serialize=False, to='core.basedistribution')),
('publication', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='gem_gemdistribution', to='core.publication')),
],
options={
'default_related_name': '%(app_label)s_%(model_name)s',
Expand All @@ -47,7 +47,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='GemContent',
fields=[
('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='gem_gemcontent', serialize=False, to='core.Content')),
('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='gem_gemcontent', serialize=False, to='core.content')),
('name', models.TextField()),
('version', models.TextField()),
],
Expand Down
5 changes: 2 additions & 3 deletions pulp_gem/app/migrations/0002_gemrepository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.2.13 on 2020-06-28 02:22
# Generated by Django 4.2.16 on 2024-12-05 16:05

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -7,15 +7,14 @@
class Migration(migrations.Migration):

dependencies = [
('core', '0033_increase_remote_artifact_size_field'),
('gem', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='GemRepository',
fields=[
('repository_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='gem_gemrepository', serialize=False, to='core.Repository')),
('repository_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='gem_gemrepository', serialize=False, to='core.repository')),
],
options={
'default_related_name': '%(app_label)s_%(model_name)s',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@


def migrate_data_from_old_master_model_to_new_master_model(apps, schema_editor):
GemDistribution = apps.get_model('gem', 'GemDistribution')
CoreDistribution = apps.get_model('core', 'Distribution')
GemDistribution = apps.get_model("gem", "GemDistribution")
CoreDistribution = apps.get_model("core", "Distribution")
for old_gem_distribution in GemDistribution.objects.all():
with transaction.atomic():
new_master_model_entry = CoreDistribution(
Expand Down Expand Up @@ -36,39 +36,48 @@ def delete_remaining_old_master_model_entries(apps, schema_editor):
class Migration(migrations.Migration):

dependencies = [
('core', '0062_add_new_distribution_mastermodel'),
('gem', '0002_gemrepository'),
("gem", "0002_gemrepository"),
]

operations = [
migrations.AddField(
model_name='GemDistribution',
name='distribution_ptr',
field=models.OneToOneField(auto_created=True, null=True, default=None,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True, primary_key=False,
related_name='gem_gemdistribution', serialize=False,
to='core.Distribution'),
model_name="GemDistribution",
name="distribution_ptr",
field=models.OneToOneField(
auto_created=True,
null=True,
default=None,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=False,
related_name="gem_gemdistribution",
serialize=False,
to="core.Distribution",
),
preserve_default=False,
),
migrations.RunPython(migrate_data_from_old_master_model_to_new_master_model),
migrations.RunPython(migrate_data_from_old_master_model_to_new_master_model, elidable=True),
migrations.RemoveField(
model_name='GemDistribution',
name='basedistribution_ptr',
model_name="GemDistribution",
name="basedistribution_ptr",
),
migrations.AlterField(
model_name='GemDistribution',
name='distribution_ptr',
field=models.OneToOneField(auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True, primary_key=True,
related_name='gem_gemdistribution', serialize=False,
to='core.distribution'),
model_name="GemDistribution",
name="distribution_ptr",
field=models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
related_name="gem_gemdistribution",
serialize=False,
to="core.distribution",
),
preserve_default=False,
),
migrations.RemoveField(
model_name='GemDistribution',
name='publication',
model_name="GemDistribution",
name="publication",
),
migrations.RunPython(delete_remaining_old_master_model_entries),
migrations.RunPython(delete_remaining_old_master_model_entries, elidable=True),
]

0 comments on commit 7302fa9

Please sign in to comment.