MTG / dunya

The Dunya music browser
http://dunya.compmusic.upf.edu
GNU Affero General Public License v3.0
29 stars 20 forks source link

Problem importing collections in Dunya #210

Closed sankalpg closed 9 years ago

sankalpg commented 9 years ago

While importing releases into Dunya I get this error (you mentioned uninitialized/null rows as the reason for this error)

Traceback (most recent call last): File "/srv/dunya/dashboard/jobs.py", line 168, in import_release ri.import_release(release.mbid, directories) File "/srv/dunya/dashboard/release_importer.py", line 91, in import_release artist = self.add_and_get_release_artist(artistid) File "/srv/dunya/dashboard/release_importer.py", line 194, in add_and_get_release_artist return self.add_and_get_artist(artistid) File "/srv/dunya/dashboard/release_importer.py", line 202, in add_and_get_artist artist = self._create_artist_object(self._ArtistClass, self._ArtistAliasClass, mbartist) File "/srv/dunya/dashboard/release_importer.py", line 139, in _create_artist_object defaults={"name": mbartist["name"]}) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method return getattr(self.get_queryset(), name)(_args, *_kwargs) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 407, in get_or_create return self._create_object_from_params(lookup, params) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 447, in _create_object_from_params six.reraise(_exc_info) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 439, in _create_object_from_params obj = self.create(params) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 348, in create obj.save(force_insert=True, using=self.db) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 710, in save force_update=force_update, update_fields=update_fields) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 738, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 822, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/base.py", line 861, in _do_insert using=using, raw=raw) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method return getattr(self.get_queryset(), name)(_args, **kwargs) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 920, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 963, in execute_sql cursor.execute(sql, params) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/utils.py", line 97, in exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/srv/dunya/env/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) IntegrityError: null value in column "description_edited" violates not-null constraint DETAIL: Failing row contains (812, null, null, KP Nandini, 8b4d7483-1637-46fe-a10a-cdce6de6b5dd, null, null, null, P, null, null, f, null).

Thanks

alastair commented 9 years ago

@andrebola can you look at this? I guess the easiest fix would be to make Artist.description_edited to be default=False

andrebola commented 9 years ago

@alastair the field already has default=False. I see that the sql generated from the migrations doesn't has the default value:

#python manage.py sqlmigrate hindustani 0003_artist_description_edited
BEGIN;
ALTER TABLE "hindustani_artist" ADD COLUMN "description_edited" boolean DEFAULT false NOT NULL;
ALTER TABLE "hindustani_artist" ALTER COLUMN "description_edited" DROP DEFAULT;

So, after looking this issue on google, I'm not sure if is a bug or it's supposed to work this way, since the default value should be handled by python (in this case would be a problem in the get_or_create method). The only solution I see is allowing NULL values on this field, by changing the BooleanField to NullBooleanField.

alastair commented 9 years ago

The problem was that we forgot to restart the celery process that performs imports, and so it didn't know about the new field in the model. I'm just fixing one more related issue and then the imports should complete