Open dbazhal opened 7 years ago
let me check
Are you using MySQL or MariaDB?
It's mariadb
That's where the problem lies. I had similar problems when using MariaDB and ended up chucking it and going back to MySQL via the community repos. I simply forgot to file a ticket about it while having the problem, but I can confirm it's related to the interactiong with MariaDB.
I found it was a permissions issue. I had created the openduty user before the database. all I had to do was grant the user permissions on the DB. I chose to just give them full permissions as this is my initial test.
GRANT ALL ON openduty.* TO 'openduty'@'%';
You can also do the following:
python manage.py migrate auth
python manage.py migrate
python manage.py syncdb
since @sofixa helped with this one i'm closing this one.
Hi @deathowl, I tried to create database from scratch in docker (openduty and database are in different containers), but I got the same error as @dbazhal had. I've tried mysql 5.5/5.6 and mariadb 10.1, and got errors about foreign key on all the three. in addition, I've tried steps provided by @sofixa as well. My script is shown below. NOTE: openduty docker is from https://github.com/openduty/openduty
if ! mysql -h $DATABASES_DEFAULT_HOST -u $DATABASES_DEFAULT_USER -p$DATABASES_DEFAULT_PASSWORD -e 'SHOW DATABASES;' | grep -q $DATABASES_DEFAULT_NAME; then
mysql -h $DATABASES_DEFAULT_HOST -u $DATABASES_DEFAULT_USER -p$DATABASES_DEFAULT_PASSWORD -e "CREATE DATABASE $DATABASES_DEFAULT_NAME;"
export DJANGO_SETTINGS_MODULE=openduty.settings_docker
python manage.py syncdb
python manage.py migrate
python manage.py collectstatic --noinput
fi
Same here. Manually tried with all solutions in the thread, both with MySQL and MariaDB and always getting foreign key errors. In both cases I've manually granted ALL privileges to OD MySQL user, just slightly different error texts: With MySQL 5.6.x:
/usr/local/lib/python2.7/site-packages/schedule/models/calendars.py:8: RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes.
from django.contrib.contenttypes import generic
Operations to perform:
Synchronize unmigrated apps: openduty, staticfiles, djcelery, messages, templatetags, django_tables2, notification, rest_framework, bootstrap3, django_tables2_simplefilter
Apply all migrations: schedule, admin, django_twilio, sessions, kombu_transport_django, contenttypes, auth
Synchronizing apps without migrations:
Creating tables...
Creating table openduty_token
Creating table openduty_schedulepolicy
Creating table openduty_service
Creating table openduty_eventlog
Creating table openduty_incident
Creating table openduty_servicetokens
Creating table openduty_schedulepolicyrule
Creating table openduty_userprofile
Creating table openduty_servicesilenced
Creating table openduty_incidentsilenced
Creating table celery_taskmeta
Creating table celery_tasksetmeta
Creating table djcelery_intervalschedule
Creating table djcelery_crontabschedule
Creating table djcelery_periodictasks
Creating table djcelery_periodictask
Creating table djcelery_workerstate
Creating table djcelery_taskstate
Creating table openduty_usernotificationmethod
Creating table openduty_schedulednotification
Running deferred SQL...
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 179, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 318, in sync_apps
cursor.execute(statement)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.IntegrityError: (1215, 'Cannot add foreign key constraint')
With MariaDB 10.x:
/usr/local/lib/python2.7/site-packages/schedule/models/calendars.py:8: RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes.
from django.contrib.contenttypes import generic
Operations to perform:
Synchronize unmigrated apps: openduty, staticfiles, djcelery, messages, templatetags, django_tables2, notification, rest_framework, bootstrap3, django_tables2_simplefilter
Apply all migrations: schedule, admin, django_twilio, sessions, kombu_transport_django, contenttypes, auth
Synchronizing apps without migrations:
Creating tables...
Creating table openduty_token
Creating table openduty_schedulepolicy
Creating table openduty_service
Creating table openduty_eventlog
Creating table openduty_incident
Creating table openduty_servicetokens
Creating table openduty_schedulepolicyrule
Creating table openduty_userprofile
Creating table openduty_servicesilenced
Creating table openduty_incidentsilenced
Creating table celery_taskmeta
Creating table celery_tasksetmeta
Creating table djcelery_intervalschedule
Creating table djcelery_crontabschedule
Creating table djcelery_periodictasks
Creating table djcelery_periodictask
Creating table djcelery_workerstate
Creating table djcelery_taskstate
Creating table openduty_usernotificationmethod
Creating table openduty_schedulednotification
Running deferred SQL...
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 179, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 318, in sync_apps
cursor.execute(statement)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.OperationalError: (1005, 'Can\'t create table `openduty`.`#sql-1_6` (errno: 150 "Foreign key constraint is incorrectly formed")')
It's the same with me. I can not install it
@deathowl : Any tips? Anything else needed from us to help diagnose where is the problem? TIA.
I got the same error, but changed the order to this instead: python manage.py migrate auth python manage.py migrate python manage.py syncdb python manage.py collectstatic python manage.py runserver
got through without errors
guys, please help me out. Stuck on this:
self.build_graph()
Unfortunately, I did not get through . Here is the database portion of settings.py. I am using Mysql 5.7(which is sort of running perfect.).
if 'test' in sys.argv: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'test', 'USER': 'openduty', 'PASSWORD': 'Openduty@123', 'HOST': 'localhost', 'PORT': '3306', } }
Any idea where I am going wrong @deathowl @pataquets @dbazhal
The installation docs should be updated
Did nothing, just created mysql db, user, started using "getting started" instructions and it fails: