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

Merge data from "created_by" to "authors" field #3259

Merged
merged 1 commit into from Mar 26, 2023
Merged

Conversation

jonasdeluna
Copy link
Member

@jonasdeluna jonasdeluna commented Mar 23, 2023

Migrate data from the old created_by field to the new authors field holding multiple authors instead of one.

@jonasdeluna jonasdeluna added the do-not-merge/WIP Pull requests that are "work in progress", and should not be merged label Mar 23, 2023
().py Outdated Show resolved Hide resolved
@jonasdeluna jonasdeluna force-pushed the migrate_authors branch 2 times, most recently from 684fe19 to 1dbe286 Compare March 24, 2023 13:00
@jonasdeluna jonasdeluna added bug-fix Pull requests that fix a bug and removed do-not-merge/WIP Pull requests that are "work in progress", and should not be merged labels Mar 24, 2023
@codecov
Copy link

codecov bot commented Mar 24, 2023

Codecov Report

Patch coverage: 72.72% and project coverage change: -0.01 ⚠️

Comparison is base (2860fed) 88.33% compared to head (67aa136) 88.32%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3259      +/-   ##
==========================================
- Coverage   88.33%   88.32%   -0.01%     
==========================================
  Files         660      661       +1     
  Lines       20857    20868      +11     
==========================================
+ Hits        18423    18431       +8     
- Misses       2434     2437       +3     
Impacted Files Coverage Δ
...o/apps/articles/migrations/0012_migrate_authors.py 72.72% <72.72%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@LudvigHz LudvigHz left a comment

Choose a reason for hiding this comment

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

Nice 👌

Fix up the comments (and preferably also change the commit message to something that makes more sense) and we're good to go 💯

def merge_authors(apps, schema_editor):
Article = apps.get_model("articles", "Article")
for e in Article.objects.all():
if e.created_by != None and e.authors == None:
Copy link
Member

Choose a reason for hiding this comment

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

Should't this be e.authors != None, or can you do .add() anyways?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seemed to run fine for me. From testing in shell, the field is None if there's no entries and adding still works.

@jonasdeluna jonasdeluna merged commit 58011a0 into master Mar 26, 2023
0 of 2 checks passed
@jonasdeluna jonasdeluna deleted the migrate_authors branch March 26, 2023 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix Pull requests that fix a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants