djaodjin / djaoapp

Web/API Gateway with user profiles, billing, and subscription-based access control
https://djaodjin.com/
Other
127 stars 33 forks source link

Cannot init the database #72

Open ramv opened 5 years ago

ramv commented 5 years ago
make initdb-testing
WARNINGS:
?: (1_10.W001) The MIDDLEWARE_CLASSES setting is deprecated in Django 1.10 and the MIDDLEWARE setting takes precedence. Since you've set MIDDLEWARE, the value of MIDDLEWARE_CLASSES is ignored.
Traceback (most recent call last):
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 326, in execute
    return Database.Cursor.execute(self, query)
sqlite3.OperationalError: no such table: saas_organization__old

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

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/deployutils/apps/django/management/commands/loadfixtures.py", line 44, in handle
    result = super(Command, self).handle(*fixture_tmps, **options)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 69, in handle
    self.loaddata(fixture_labels)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 115, in loaddata
    connection.check_constraints(table_names=table_names)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 286, in check_constraints
    column_name, referenced_column_name,
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/Users/ramv/Documents/workspace/_installTop_/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 326, in execute
    return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: Problem installing fixtures: no such table: saas_organization__old
make: *** [initdb-testing] Error 1
smirolo commented 5 years ago

This is a bug due to a change in SQLite that Django did not like. See SQLite 3.26 breaks database migration ForeignKey constraint, leaving __old in db schema for details.

At this point, the best bet, assuming you are running Django==1.11.18, is to downgrade to an earlier version of SQLite. SQLite 3.24.0 works with Django 1.11.18.

smirolo commented 5 years ago

If you are using brew to install SQLite, this will help.

jpoechill commented 5 years ago

For future reference, installs SQlite 3.24.0:

brew install --force https://raw.githubusercontent.com/Homebrew/homebrew-core/b3217181a55f9061c455c48b4bcca749d1ba54bf/Formula/sqlite.rb

adamhos commented 5 years ago

Works if you delete saas/migrations, run ./manage.py makemigrations and then migrate.