Forums

Django Migration Issue.

When running python manage.py migrate I get the following error. It looks like it has something to do with allauth but I can't find any information on it.

(venv) 05:52 ~/simple_login_demo (master)$ python manage.py migrate                                                                      
Operations to perform:                                                                                                                   
  Apply all migrations: account, admin, auth, contenttypes, profiles, sessions, sites, socialaccount                                     
Running migrations:                                                                                                                      
  No migrations to apply.                                                                                                                
Traceback (most recent call last):                                                                                                       
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute                           
    return self.cursor.execute(sql, params)                                                                                              
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 71, in execute                       
    return self.cursor.execute(query, args)                                                                                              
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute                                    
    self.errorhandler(self, exc, value)                                                                                                  
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler                     
    raise errorvalue                                                                                                                     
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute                                    
    res = self._query(query)                                                                                                             
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 412, in _query                                     
    rowcount = self._do_query(q)                                                                                                         
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 375, in _do_query                                  
    db.query(q)                                                                                                                          
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 276, in query                                  
    _mysql.connection.query(self, query)                                                                                                 
_mysql_exceptions.DataError: (1264, "Out of range value for column 'id' at row 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):                                                                                                       
  File "manage.py", line 15, in <module>                                                                                                 
    execute_from_command_line(sys.argv)                                                                                                  
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line  
    utility.execute()
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 226, in handle
    self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan,
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/sql.py", line 51, in emit_post_migrate_signal
    **kwargs
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in send
    for receiver in self._live_receivers(sender)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in <listcomp>
    for receiver in self._live_receivers(sender)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/contrib/sites/management.py", line 28, in create_default_site
    Site(pk=getattr(settings, 'SITE_ID', 1), domain="example.com", name="example.com").save(using=using)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/base.py", line 718, in save
    force_update=force_update, update_fields=update_fields)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/base.py", line 748, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/base.py", line 831, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/base.py", line 869, in _do_insert
    using=using, raw=raw)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/query.py", line 1136, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1289, in execute_sql
    cursor.execute(sql, params)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute
    self.errorhandler(self, exc, value)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute
    res = self._query(query)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 412, in _query
    rowcount = self._do_query(q)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 375, in _do_query
    db.query(q)
  File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 276, in query
    _mysql.connection.query(self, query)
django.db.utils.DataError: (1264, "Out of range value for column 'id' at row 1")

[edit by admin: formatting]

That looks a bit odd. Is this running against a new database? Or one that already has data in it?

He is what it looks like again a fresh db. That one was a second try.

(venv) 17:41 ~/simple_login_demo (master)$ python manage.py migrate
Operations to perform:
Apply all migrations: account, admin, auth, contenttypes, profiles, sessions, sites, socialaccount
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying account.0001_initial... OK
Applying account.0002_email_max_length... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying profiles.0001_initial... OK
Applying sessions.0001_initial... OK
Applying sites.0001_initial... OK
Applying sites.0002_alter_domain_unique... OK
Applying socialaccount.0001_initial... OK
Applying socialaccount.0002_token_max_lengths... OK
Applying socialaccount.0003_extra_data_default_dict... OK Traceback (most recent call last): File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 71, in execute return self.cursor.execute(query, args) File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute self.errorhandler(self, exc, value) File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler raise errorvalue File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute res = self._query(query) File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 412, in _query rowcount = self._do_query(q) File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 375, in _do_query db.query(q) File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 276, in query _mysql.connection.query(self, query) _mysql_exceptions.DataError: (1264, "Out of range value for column 'id' at row 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/init.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv self.execute(args, cmd_options) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute output = self.handle(args, options) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped res = handle_func(*args, kwargs) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 226, in handle self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan, File "/home/orisolutions/venv/lib/python3.6/site-packages/django/core/management/sql.py", line 51, in emit_post_migrate_signal kwargs File "/home/orisolutions/venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in send for receiver in self._live_receivers(sender) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 175, in <listcomp> for receiver in self._live_receivers(sender) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/contrib/sites/management.py", line 28, in create_default_site Site(pk=getattr(settings, 'SITE_ID', 1), domain="example.com", name="example.com").save(using=using) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/base.py", line 718, in save force_update=force_update, update_fields=update_fields) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/base.py", line 748, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/base.py", line 831, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/base.py", line 869, in _do_insert using=using, raw=raw) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, kwargs) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/query.py", line 1136, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1289, in execute_sql cursor.execute(sql, params) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute return super().execute(sql, params) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers return executor(sql, params, many, context) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/utils.py", line 89, in exit raise dj_exc_value.with_traceback(traceback) from exc_value File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/home/orisolutions/venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 71, in execute return self.cursor.execute(query, args) File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute self.errorhandler(self, exc, value) File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler raise errorvalue File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute res = self._query(query) File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 412, in _query rowcount = self._do_query(q) File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 375, in _do_query db.query(q) File "/home/orisolutions/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 276, in query _mysql.connection.query(self, query) django.db.utils.DataError: (1264, "Out of range value for column 'id' at row 1")

Also it the migrations apply with no issues using sqlite.

I found it. My Site ID was too large. Hope this helps someone else.

Interesting- you just manually set a SITE_ID in settings.py and that was too large?

Yeah. For MySQL but not with sqlite.

Out of interest, how large was the ID?