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

0.9.x url shortener #938

Merged
merged 3 commits into from
Sep 6, 2014
Merged

0.9.x url shortener #938

merged 3 commits into from
Sep 6, 2014

Conversation

deniszh
Copy link
Member

@deniszh deniszh commented Sep 6, 2014

Backport of PR #158 (URL shortener) to 0.9.x branch.
Tested on syntehzize@0.9.x -
screen shot 2014-09-07 at 00 18 35

@obfuscurity
Copy link
Member

Looks fine. ⚡

obfuscurity added a commit that referenced this pull request Sep 6, 2014
@obfuscurity obfuscurity merged commit 79aada6 into graphite-project:0.9.x Sep 6, 2014
@obfuscurity
Copy link
Member

@deniszh Please add this to the release notes for 0.9.13 in both branches.

@deniszh deniszh deleted the 0.9.x_url_shortener branch September 7, 2014 19:25
@deniszh
Copy link
Member Author

deniszh commented Sep 7, 2014

Done - #939 and #940

@obfuscurity
Copy link
Member

@obfuscurity
Copy link
Member

Do we have any documentation around migrating the fixture for this?

@brutasse
Copy link
Member

@obfuscurity you mean for upgrading? It's just a new table so django-admin.py syncdb creates it.

@obfuscurity
Copy link
Member

@brutasse I'm not having any luck with that. Attempted a migration from a "clean" 0.9.12 installation to 0.9.14. Django 1.4 syncdb fails as such:

$ sudo PYTHONPATH=/opt/graphite/webapp django-admin.py syncdb --settings=graphite.settings
Creating tables ...
Creating table url_shortener_link
The following content types are stale and need to be deleted:

    auth | message

Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.

    Type 'yes' to continue, or 'no' to cancel: yes
Installing custom SQL ...
Installing indexes ...
Problem installing fixture 'initial_data.json': Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/loaddata.py", line 196, in handle
    obj.save(using=using)
  File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/base.py", line 165, in save
    models.Model.save_base(self.object, using=using, raw=True)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 529, in save_base
    rows = manager.using(using).filter(pk=pk_val)._update(values)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 557, in _update
    return query.get_compiler(self.db).execute_sql(None)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 986, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 337, in execute
    return Database.Cursor.execute(self, query, params)
IntegrityError: Could not load contenttypes.ContentType(pk=10): UNIQUE constraint failed: django_content_type.app_label, django_content_type.model

Upgrading to Django 1.7 offers the migrate command, but it doesn't fare any better:

$ sudo PYTHONPATH=/opt/graphite/webapp django-admin.py migrate --settings=graphite.settings
System check identified some issues:

WARNINGS:
?: (1_6.W001) Some project unittests may not execute as expected.
    HINT: Django 1.6 introduced a new default test runner. It looks like this project was generated using Django 1.5 or earlier. You should ensure your tests are all running & behaving as expected. See https://docs.djangoproject.com/en/dev/releases/1.6/#new-test-runner for more information.
Operations to perform:
  Synchronize unmigrated apps: url_shortener, account, dashboard, tagging, events
  Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
    Creating table url_shortener_link
  Installing custom SQL...
  Installing indexes...
Traceback (most recent call last):
  File "/usr/local/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 128, in handle
    created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 297, in sync_apps
    call_command('loaddata', 'initial_data', verbosity=self.verbosity, database=connection.alias, skip_validation=True, app_label=app_label, hide_empty=True)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 115, in call_command
    return klass.execute(*args, **defaults)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/loaddata.py", line 61, in handle
    self.loaddata(fixture_labels)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/loaddata.py", line 91, in loaddata
    self.load_label(fixture_label)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/loaddata.py", line 148, in load_label
    obj.save(using=self.using)
  File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/base.py", line 173, in save
    models.Model.save_base(self.object, using=using, raw=True)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 618, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 680, in _save_table
    forced_update)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 724, in _do_update
    return filtered._update(values) > 0
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 600, in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 1004, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 485, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: Problem installing fixture '/opt/graphite/webapp/graphite/initial_data.json': Could not load contenttypes.ContentType(pk=10): UNIQUE constraint failed: django_content_type.app_label, django_content_type.model

At this point even a manual "dump-and-restore" method would be acceptable.

@obfuscurity obfuscurity mentioned this pull request Nov 7, 2015
13 tasks
@obfuscurity
Copy link
Member

Sorry, disregard. This appears to be an issue with the initial-data.json left in place by Synthesize.

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.

None yet

3 participants