Last active
January 4, 2016 16:08
-
-
Save andialbrecht/8644979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Migrate from sentry-comments to build in notes. | |
# | |
# See also https://github.com/andialbrecht/sentry-comments/issues/11 | |
# Especially when you're upgrading from Sentry 6.3. | |
# | |
# To run this script: | |
# sentry --config=your.conf.py shell | |
# >>> import migratecomments.py | |
# >>> migratecomments.migrate() | |
# | |
# After migration you can safely remove the sentry_comments plugin | |
# from your setup. | |
from django.contrib.auth import get_user_model | |
from sentry_comments.models import GroupComments | |
from sentry.models import Activity | |
from sentry.models import Group | |
User = get_user_model() | |
def migrate(): | |
for gc in GroupComments.objects.all(): | |
print('Migrating %d' % gc.pk) | |
try: | |
group = gc.group | |
except Group.DoesNotExist: | |
print('--> skipping. Group does not exist anymore.') | |
continue | |
user = User.objects.get(pk=gc.author.pk) | |
Activity.objects.create( | |
group=gc.group, event=None, project=gc.group.project, | |
type=Activity.NOTE, user=user, | |
data={'text': gc.message}, | |
datetime=gc.created | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment