IntegrityError at /imports/create-project null value in column "published" violates not-null constraint
Opened this issue · 4 comments
mfindeisen commented
The following error occurred while attempting to create a new project:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty
Python Version: 3.4.0
Exception Type: IntegrityError
Exception Value:
null value in column "published" violates not-null constraint
DETAIL: Failing row contains (79e7356c-4039-4007-ad43-b1e37bdc38a3, 79e7356c-4039-4007-ad43-b1e37bdc38a3, manual, projects, , , 0-1, 1, , 00-0000-000001-000000-000000-000000-000000-000000-000000-000000, 0, null, null, null, null, 2015-06-07 16:03:02.788332+00, 2015-06-07 16:03:02.790821+00).
Exception Location: /home/m/oc-venv/lib/python3.4/site-packages/django/db/backends/utils.py in execute, line 65
Environment:
Request Method: POST
Request URL: http://***/imports/create-project
Django Version: 1.7.2
Python Version: 3.4.0
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.humanize',
'opencontext_py.apps.entities.uri',
'opencontext_py.apps.entities.entity',
'opencontext_py.apps.ocitems.namespaces',
'opencontext_py.apps.ocitems.subjects',
'opencontext_py.apps.ocitems.ocitem',
'opencontext_py.apps.ocitems.manifest',
'opencontext_py.apps.ocitems.assertions',
'opencontext_py.apps.ocitems.events',
'opencontext_py.apps.ocitems.geospace',
'opencontext_py.apps.ocitems.mediafiles',
'opencontext_py.apps.ocitems.documents',
'opencontext_py.apps.ocitems.persons',
'opencontext_py.apps.ocitems.projects',
'opencontext_py.apps.ocitems.strings',
'opencontext_py.apps.ocitems.octypes',
'opencontext_py.apps.ocitems.octypetree',
'opencontext_py.apps.ocitems.predicates',
'opencontext_py.apps.ocitems.predicatetree',
'opencontext_py.apps.ocitems.identifiers',
'opencontext_py.apps.ocitems.obsmetadata',
'opencontext_py.apps.imports.ocmysql',
'opencontext_py.apps.imports.fields',
'opencontext_py.apps.imports.fieldannotations',
'opencontext_py.apps.imports.records',
'opencontext_py.apps.imports.sources',
'opencontext_py.apps.ldata.linkannotations',
'opencontext_py.apps.ldata.linkentities',
'opencontext_py.apps.exports.expfields',
'opencontext_py.apps.exports.exprecords',
'opencontext_py.apps.indexer',
'opencontext_py.apps.searcher.sets')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/home/m/oc-venv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "./opencontext_py/apps/imports/sources/views.py" in create_project
41. short_des)
File "./opencontext_py/apps/imports/sources/projects.py" in create_project
182. man_proj.save()
File "./opencontext_py/apps/ocitems/manifest/models.py" in save
97. super(Manifest, self).save(*args, **kwargs)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/models/base.py" in save
589. force_update=force_update, update_fields=update_fields)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/models/base.py" in save_base
617. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/models/base.py" in _save_table
698. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/models/base.py" in _do_insert
731. using=using, raw=raw)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/models/manager.py" in manager_method
92. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/models/query.py" in _insert
921. return query.get_compiler(using=using).execute_sql(return_id)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in execute_sql
920. cursor.execute(sql, params)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
81. return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/utils.py" in __exit__
94. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/utils/six.py" in reraise
658. raise value.with_traceback(tb)
File "/home/m/oc-venv/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)
Exception Type: IntegrityError at /imports/create-project
Exception Value: null value in column "published" violates not-null constraint
DETAIL: Failing row contains (79e7356c-4039-4007-ad43-b1e37bdc38a3, 79e7356c-4039-4007-ad43-b1e37bdc38a3, manual, projects, , , 0-1, 1, , 00-0000-000001-000000-000000-000000-000000-000000-000000-000000, 0, null, null, null, null, 2015-06-07 16:03:02.788332+00, 2015-06-07 16:03:02.790821+00).
python manage.py inspectdb
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
#
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [app_label]'
# into your database.
from __future__ import unicode_literals
from django.db import models
class AuthGroup(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
name = models.CharField(unique=True, max_length=80)
class Meta:
managed = False
db_table = 'auth_group'
class AuthGroupPermissions(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
group = models.ForeignKey(AuthGroup)
permission = models.ForeignKey('AuthPermission')
class Meta:
managed = False
db_table = 'auth_group_permissions'
class AuthPermission(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
name = models.CharField(max_length=50)
content_type = models.ForeignKey('DjangoContentType')
codename = models.CharField(max_length=100)
class Meta:
managed = False
db_table = 'auth_permission'
class AuthUser(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
password = models.CharField(max_length=128)
last_login = models.DateTimeField()
is_superuser = models.BooleanField()
username = models.CharField(unique=True, max_length=30)
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
email = models.CharField(max_length=75)
is_staff = models.BooleanField()
is_active = models.BooleanField()
date_joined = models.DateTimeField()
class Meta:
managed = False
db_table = 'auth_user'
class AuthUserGroups(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
user = models.ForeignKey(AuthUser)
group = models.ForeignKey(AuthGroup)
class Meta:
managed = False
db_table = 'auth_user_groups'
class AuthUserUserPermissions(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
user = models.ForeignKey(AuthUser)
permission = models.ForeignKey(AuthPermission)
class Meta:
managed = False
db_table = 'auth_user_user_permissions'
class DjangoAdminLog(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
action_time = models.DateTimeField()
object_id = models.TextField(blank=True)
object_repr = models.CharField(max_length=200)
action_flag = models.SmallIntegerField()
change_message = models.TextField()
content_type = models.ForeignKey('DjangoContentType', blank=True, null=True)
user = models.ForeignKey(AuthUser)
class Meta:
managed = False
db_table = 'django_admin_log'
class DjangoContentType(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
name = models.CharField(max_length=100)
app_label = models.CharField(max_length=100)
model = models.CharField(max_length=100)
class Meta:
managed = False
db_table = 'django_content_type'
class DjangoMigrations(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
app = models.CharField(max_length=255)
name = models.CharField(max_length=255)
applied = models.DateTimeField()
class Meta:
managed = False
db_table = 'django_migrations'
class DjangoSession(models.Model):
session_key = models.CharField(primary_key=True, max_length=40)
session_data = models.TextField()
expire_date = models.DateTimeField()
class Meta:
managed = False
db_table = 'django_session'
class ExpFields(models.Model):
hash_id = models.CharField(primary_key=True, max_length=50)
table_id = models.CharField(max_length=50)
field_num = models.IntegerField()
label = models.CharField(max_length=200)
rel_ids = models.TextField()
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'exp_fields'
class ExpRecords(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
table_id = models.CharField(max_length=50)
uuid = models.CharField(max_length=50)
project_uuid = models.CharField(max_length=50)
row_num = models.IntegerField()
field_num = models.IntegerField()
record = models.TextField()
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'exp_records'
class ImpFieldAnnotations(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
source_id = models.CharField(max_length=50)
project_uuid = models.CharField(max_length=50)
field_num = models.IntegerField()
predicate = models.CharField(max_length=50)
predicate_field_num = models.IntegerField()
object_field_num = models.IntegerField()
object_uuid = models.CharField(max_length=50)
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'imp_field_annotations'
class ImpFields(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
source_id = models.CharField(max_length=50)
project_uuid = models.CharField(max_length=50)
field_num = models.IntegerField()
is_keycell = models.BooleanField()
ref_name = models.CharField(max_length=200)
ref_orig_name = models.CharField(max_length=200)
field_type = models.CharField(max_length=50)
field_data_type = models.CharField(max_length=50)
field_value_cat = models.CharField(max_length=50)
obs_num = models.IntegerField()
label = models.CharField(max_length=200)
value_prefix = models.CharField(max_length=50)
unique_count = models.IntegerField()
f_uuid = models.CharField(max_length=50)
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'imp_fields'
class ImpRecords(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
source_id = models.CharField(max_length=50)
project_uuid = models.CharField(max_length=50)
row_num = models.IntegerField()
field_num = models.IntegerField()
rec_hash = models.CharField(max_length=50)
fl_uuid = models.CharField(max_length=50)
l_uuid = models.CharField(max_length=50)
cell_ok = models.BooleanField()
record = models.TextField()
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'imp_records'
class ImpSources(models.Model):
source_id = models.CharField(primary_key=True, max_length=50)
project_uuid = models.CharField(max_length=50)
label = models.CharField(max_length=200)
field_count = models.IntegerField()
row_count = models.IntegerField()
source_type = models.CharField(max_length=50)
is_current = models.BooleanField()
imp_status = models.CharField(max_length=50)
created = models.DateTimeField()
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'imp_sources'
class LinkAnnotations(models.Model):
hash_id = models.CharField(primary_key=True, max_length=50)
sort = models.DecimalField(max_digits=8, decimal_places=3)
subject = models.CharField(max_length=200)
subject_type = models.CharField(max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=200)
predicate_uri = models.CharField(max_length=200)
object_uri = models.CharField(max_length=200)
creator_uuid = models.CharField(max_length=50)
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'link_annotations'
class LinkEntities(models.Model):
uri = models.CharField(primary_key=True, max_length=200)
slug = models.CharField(unique=True, max_length=70)
label = models.CharField(max_length=200)
alt_label = models.CharField(max_length=200)
sort = models.CharField(max_length=60)
vocab_uri = models.CharField(max_length=200)
ent_type = models.CharField(max_length=50)
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'link_entities'
class OcAssertions(models.Model):
hash_id = models.CharField(primary_key=True, max_length=50)
uuid = models.CharField(max_length=50)
subject_type = models.CharField(max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
obs_node = models.CharField(max_length=50)
obs_num = models.IntegerField()
sort = models.DecimalField(max_digits=8, decimal_places=3)
visibility = models.IntegerField()
predicate_uuid = models.CharField(max_length=50)
object_uuid = models.CharField(max_length=50)
object_type = models.CharField(max_length=50)
data_num = models.DecimalField(max_digits=19, decimal_places=10)
data_date = models.DateTimeField()
created = models.DateTimeField()
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'oc_assertions'
class OcDocuments(models.Model):
uuid = models.CharField(primary_key=True, max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
updated = models.DateTimeField()
content = models.TextField()
class Meta:
managed = False
db_table = 'oc_documents'
class OcEvents(models.Model):
hash_id = models.CharField(primary_key=True, max_length=50)
uuid = models.CharField(max_length=50)
item_type = models.CharField(max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
event_id = models.IntegerField()
meta_type = models.CharField(max_length=50)
when_type = models.CharField(max_length=50)
feature_id = models.IntegerField()
earliest = models.DecimalField(max_digits=19, decimal_places=5)
start = models.DecimalField(max_digits=19, decimal_places=5)
stop = models.DecimalField(max_digits=19, decimal_places=5)
latest = models.DecimalField(max_digits=19, decimal_places=5)
updated = models.DateTimeField()
note = models.TextField()
class Meta:
managed = False
db_table = 'oc_events'
class OcGeospace(models.Model):
hash_id = models.CharField(primary_key=True, max_length=50)
uuid = models.CharField(max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
item_type = models.CharField(max_length=50)
feature_id = models.IntegerField()
meta_type = models.CharField(max_length=50)
ftype = models.CharField(max_length=200)
latitude = models.DecimalField(max_digits=24, decimal_places=21)
longitude = models.DecimalField(max_digits=24, decimal_places=21)
specificity = models.IntegerField()
updated = models.DateTimeField()
coordinates = models.TextField()
note = models.TextField()
class Meta:
managed = False
db_table = 'oc_geospace'
class OcIdentifiers(models.Model):
stable_id = models.CharField(primary_key=True, max_length=200)
stable_type = models.CharField(max_length=50)
uuid = models.CharField(max_length=50)
project_uuid = models.CharField(max_length=50)
item_type = models.CharField(max_length=50)
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'oc_identifiers'
class OcManifest(models.Model):
uuid = models.CharField(primary_key=True, max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
item_type = models.CharField(max_length=50)
repo = models.CharField(max_length=200)
class_uri = models.CharField(max_length=200)
slug = models.CharField(unique=True, max_length=70)
label = models.CharField(max_length=200)
des_predicate_uuid = models.CharField(max_length=50)
sort = models.CharField(max_length=70)
views = models.IntegerField()
indexed = models.DateTimeField(blank=True, null=True)
vcontrol = models.DateTimeField(blank=True, null=True)
archived = models.DateTimeField(blank=True, null=True)
published = models.DateTimeField()
revised = models.DateTimeField()
record_updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'oc_manifest'
class OcMediafiles(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
uuid = models.CharField(max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
file_type = models.CharField(max_length=50)
mime_type_uri = models.CharField(max_length=200)
file_uri = models.CharField(max_length=400)
filesize = models.DecimalField(max_digits=19, decimal_places=3)
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'oc_mediafiles'
class OcObsmetadata(models.Model):
id = models.IntegerField(primary_key=True) # AutoField?
source_id = models.CharField(max_length=200)
project_uuid = models.CharField(max_length=50)
obs_num = models.IntegerField()
label = models.CharField(max_length=200)
obs_type = models.CharField(max_length=50)
updated = models.DateTimeField()
note = models.TextField()
class Meta:
managed = False
db_table = 'oc_obsmetadata'
class OcPersons(models.Model):
uuid = models.CharField(primary_key=True, max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
foaf_type = models.CharField(max_length=50)
combined_name = models.CharField(max_length=200)
given_name = models.CharField(max_length=200)
surname = models.CharField(max_length=200)
mid_init = models.CharField(max_length=5)
initials = models.CharField(max_length=50)
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'oc_persons'
class OcPredicates(models.Model):
uuid = models.CharField(primary_key=True, max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
data_type = models.CharField(max_length=50)
sort = models.DecimalField(max_digits=8, decimal_places=3)
created = models.DateTimeField()
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'oc_predicates'
class OcProjects(models.Model):
uuid = models.CharField(primary_key=True, max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
updated = models.DateTimeField()
short_id = models.IntegerField(unique=True)
view_group_id = models.IntegerField()
edit_group_id = models.IntegerField()
edit_status = models.IntegerField()
label = models.CharField(max_length=200)
short_des = models.CharField(max_length=200)
content = models.TextField()
class Meta:
managed = False
db_table = 'oc_projects'
class OcStrings(models.Model):
uuid = models.CharField(primary_key=True, max_length=50)
hash_id = models.CharField(unique=True, max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
updated = models.DateTimeField()
content = models.TextField()
class Meta:
managed = False
db_table = 'oc_strings'
class OcSubjects(models.Model):
uuid = models.CharField(primary_key=True, max_length=50)
hash_id = models.CharField(unique=True, max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
context = models.CharField(max_length=400)
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'oc_subjects'
class OcTypes(models.Model):
uuid = models.CharField(primary_key=True, max_length=50)
project_uuid = models.CharField(max_length=50)
source_id = models.CharField(max_length=50)
predicate_uuid = models.CharField(max_length=50)
content_uuid = models.CharField(max_length=50)
rank = models.DecimalField(max_digits=8, decimal_places=3)
updated = models.DateTimeField()
class Meta:
managed = False
db_table = 'oc_types'
List of databases:
Name | Owner | Encoding | Collate | Ctype | Access privileges |
---|---|---|---|---|---|
opencontext | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
mfindeisen commented
after
opencontext=# ALTER TABLE oc_manifest ALTER COLUMN published DROP NOT NULL;
TypeError at /imports/create-project
unsupported operand type(s) for +: 'NoneType' and 'int'
Exception Value:
unsupported operand type(s) for +: 'NoneType' and 'int'
Exception Location: ./opencontext_py/apps/ocitems/projects/models.py in get_make_short_id, line 62
Environment:
Request Method: POST
Request URL: http://***/imports/create-project
Django Version: 1.7.2
Python Version: 3.4.0
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.humanize',
'opencontext_py.apps.entities.uri',
'opencontext_py.apps.entities.entity',
'opencontext_py.apps.ocitems.namespaces',
'opencontext_py.apps.ocitems.subjects',
'opencontext_py.apps.ocitems.ocitem',
'opencontext_py.apps.ocitems.manifest',
'opencontext_py.apps.ocitems.assertions',
'opencontext_py.apps.ocitems.events',
'opencontext_py.apps.ocitems.geospace',
'opencontext_py.apps.ocitems.mediafiles',
'opencontext_py.apps.ocitems.documents',
'opencontext_py.apps.ocitems.persons',
'opencontext_py.apps.ocitems.projects',
'opencontext_py.apps.ocitems.strings',
'opencontext_py.apps.ocitems.octypes',
'opencontext_py.apps.ocitems.octypetree',
'opencontext_py.apps.ocitems.predicates',
'opencontext_py.apps.ocitems.predicatetree',
'opencontext_py.apps.ocitems.identifiers',
'opencontext_py.apps.ocitems.obsmetadata',
'opencontext_py.apps.imports.ocmysql',
'opencontext_py.apps.imports.fields',
'opencontext_py.apps.imports.fieldannotations',
'opencontext_py.apps.imports.records',
'opencontext_py.apps.imports.sources',
'opencontext_py.apps.ldata.linkannotations',
'opencontext_py.apps.ldata.linkentities',
'opencontext_py.apps.exports.expfields',
'opencontext_py.apps.exports.exprecords',
'opencontext_py.apps.indexer',
'opencontext_py.apps.searcher.sets')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/home/m/oc-venv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "./opencontext_py/apps/imports/sources/views.py" in create_project
41. short_des)
File "./opencontext_py/apps/imports/sources/projects.py" in create_project
191. pobj.save()
File "./opencontext_py/apps/ocitems/projects/models.py" in save
33. self.short_id)
File "./opencontext_py/apps/ocitems/projects/models.py" in get_make_short_id
62. short_id = sumps['short_id__max'] + 1
Exception Type: TypeError at /imports/create-project
Exception Value: unsupported operand type(s) for +: 'NoneType' and 'int'
However, this time a project was created.
ekansa commented
Hmmm... Interesting. I will try to reproduce the error on my end. I may need to add some more logic to the model.
Allan-Nava commented
Any news?
I have this problem:
When i dropped the table and reacreate manually
django.db.utils.IntegrityError: null value in column "id" violates not-null constraint
DETAIL: Failing row contains