Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added missing migrations #120

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

vasekch
Copy link
Contributor

@vasekch vasekch commented May 4, 2023

Description

Adding missing migrations for newer Django (couldn't find particular version, but migrations for OneToOneField are generated with a slight difference).

# older django - currently in migrations
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, related_name='djangocms_picture_picture', primary_key=True, serialize=False, to='cms.CMSPlugin'),

# new django v4.1 - in this PR
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='%(app_label)s_%(class)s', serialize=False, to='cms.cmsplugin'),

Related resources

Checklist

  • I have opened this pull request against master
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined #workgroup-pr-review on
    Slack to find a “pr review buddy” who is going to review my pull request.

@vasekch vasekch changed the title Create 0012_alter_picture_cmsplugin_ptr.py fix: added missing migrations May 4, 2023
Removed dependency on non-existent cms migration
@vasekch vasekch marked this pull request as ready for review May 4, 2023 15:27
@vasekch
Copy link
Contributor Author

vasekch commented May 4, 2023

this is a duplicate with #118
and actually I don't like the migration dependency being last cms migration from v4, that breaks backward compatibility

will try to improve this

drop dependency to the first cms migration as it's sufficient and provides the best backward compatibility
@vasekch
Copy link
Contributor Author

vasekch commented May 4, 2023

Changed migration dependency to the first migration of CMS

newer Django treat migrations for OneToOneField with a slight difference (couldn't find particular version where this change occurs)

It seems sensible to update migrations to the newer standard.

# older django - currently in migrations
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, related_name='djangocms_picture_picture', primary_key=True, serialize=False, to='cms.CMSPlugin'),

# new django (tested in v4.1.8) - in this PR
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='%(app_label)s_%(class)s', serialize=False, to='cms.cmsplugin'),

@vasekch vasekch marked this pull request as draft May 4, 2023 16:25
@mogoh mogoh mentioned this pull request Jul 10, 2023
11 tasks
@mogoh
Copy link
Contributor

mogoh commented Jul 10, 2023

Changed migration dependency to the first migration of CMS

What is the reason for that?

@vasekch
Copy link
Contributor Author

vasekch commented Jul 17, 2023

Changed migration dependency to the first migration of CMS

What is the reason for that?

It seems to me, that it brings more independence in version of DjangoCMS as the latest migrations may not be present in older versions.

@vasekch vasekch marked this pull request as ready for review July 17, 2023 15:28
class Migration(migrations.Migration):

dependencies = [
('cms', '__first__'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather this be latest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest migration from develop branch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed code to use latest migration found in the develop branch of django-cms repo.

now the code is the same with #118

The original idea was to accommodate cases where users update djangocms-picture, but may keep django-cms in older version than does not includes the latest migration. I've chosen the first migration, because that's where cmsplugin_ptr is created.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @marksweb referred to '__latest__' instead of '__first__'. This would allow you to keep cms outdated (for whatever reason ;-) )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking back at this, I think it needs to be __first__ because if if's latest and we release a new migration, the applied migration here would depend on a migration yet to be applied and that causes an error.

@vasekch
Copy link
Contributor Author

vasekch commented Jul 18, 2023

Thanks @marksweb and @fsbraun for the lesson 👨‍🎓

@marksweb
Copy link
Member

Thanks @marksweb and @fsbraun for the lesson 👨‍🎓

Thanks for contributing. I went looking for this migration trick again and I think it's undocumented. Just one of those things you pick up from people that have found it from others I think.

@mogoh mogoh mentioned this pull request Jul 18, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants