kolibri cannot start after switching from sqlite to postgresql database
See original GitHub issueObserved behavior
Kolibri cannot start when the database switches from sqlite to postgresql because there are no migrations applied to the postgresql database.
Running kolibri manage migrate
doesn’t help because the command errors out before actually running migrations.
I had to delete the .data_version
file to force running migrations on postgresql database.
Expected behavior
users should be able to start kolibri successfully after they switch from sqlite to postgresql if they run some additional commands, e.g. kolibri manage migrate.
User-facing consequences
users cannot start kolibri after they switch from sqlite to postgresql
Errors and logs
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "./kolibri/core/device/middleware.py", line 31, in __call__
request
File "./kolibri/core/device/translation.py", line 81, in get_language_from_request_and_is_from_path
if not getattr(resolve(request.path_info).func, "translated", False):
File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/base.py", line 27, in resolve
return get_resolver(urlconf).resolve(path)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/resolvers.py", line 366, in resolve
sub_match = pattern.resolve(new_path)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/resolvers.py", line 366, in resolve
sub_match = pattern.resolve(new_path)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/resolvers.py", line 366, in resolve
sub_match = pattern.resolve(new_path)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/resolvers.py", line 366, in resolve
sub_match = pattern.resolve(new_path)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/resolvers.py", line 366, in resolve
sub_match = pattern.resolve(new_path)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/resolvers.py", line 361, in resolve
match = self.regex.search(path)
File "./kolibri/core/device/translation.py", line 164, in regex
device_language = get_device_language() or get_settings_language()
File "./kolibri/core/device/translation.py", line 35, in get_device_language
DEVICE_LANGUAGE_CACHE_KEY, DeviceSettings.objects.get().language_id, 600
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 374, in get
num = len(clone)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 232, in __len__
self._fetch_all()
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 1121, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/sql/compiler.py", line 899, in execute_sql
raise original_exception
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/models/sql/compiler.py", line 889, in execute_sql
cursor.execute(sql, params)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/kolibri/dist/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "device_devicesettings" does not exist
LINE 1: ...device_devicesettings"."default_facility_id" FROM "device_de...
Steps to reproduce
- start kolibri with sqlite database, so the migrations are applied there
- stop kolibri server
- put the postgresql database settings to options.ini file
- start kolibri
Context
kolibri version: 0.12.5 operating system: OSX and Ubuntu 16.04
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
Kolibri fails to start when using Postgresql DB with a big ...
Kolibri fails to start with PostgreSQL when trying to import a big content dataset (from Khan Academy). When copying a large amount of...
Read more >Support for other databases - Kolibri
I have been having issues with the sqlite database that became corrupt (I/O errors) after many requests. I feel postgres is a better...
Read more >Switching from SQLite to PostgreSQL at Windows
Open config/production.json and change it back to sqlite. But I'm pretty sure my connection info is ok because I use it to connect...
Read more >Change from SQLite to PostgreSQL in a fresh Rails project
Since I am moving to heroku, I want to convert my database to PostgreSQL. Anyways, I heard that the local, development, database does...
Read more >Moving Data from SQLite to PostgreSQL: 4 Easy Steps
Step 1: Create SQLite DB Dumpdata Backup · Step 2: Generate a Postgres DB and User · Step 3: Configure Settings.py · Step...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Nope, this is the first case I hear of somebody attempting it.
It would certainly need to be placed among the advanced management topics, but if there’s consensus that we need to cover it, I’m all for it! 👍
See https://www.notion.so/learningequality/Move-a-SQLite-database-to-PostgreSQL-Using-PGLoader-8807b6515d8d4dc0a08b78934a6aebfa