#32968: Migration errors from SQLite to Postgres
-------------------------------------+-------------------------------------
Reporter: Song Yang | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: postgres, sqlite, | Triage Stage:
programmingerror, migration | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Song Yang:
Old description:
> To put my app on Heroku, I am changing my database from SQLite to
> Postgres at the end of my project. Everything works fine locally on
> SQLite. But during `python manage.py migrate --run-syncdb`, I get a
> `ProgrammingError`. I was planning on loading the dumped json later in
> Postgres.
>
> I created a branch on my repo for you to reproduce this bug. The branch
> is `postgres` and the link is https://github.com/XsongyangX/uml-fragment-
> labeling/tree/postgres
>
> Here is the log.
>
> {{{
>
> $ py manage.py migrate --run-syncdb
> Traceback (most recent call last):
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\ba
> ckends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
> psycopg2.errors.UndefinedTable: relation "labeling_model" does not exist
> LINE 1: ...del"."classes", "labeling_model"."relations" FROM
> "labeling_...
> ^
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
> File "C:\Users\Song\Documents\UDEM\master thesis\uml
> data\database\umllabels\m
> anage.py", line 22, in <module>
> main()
> File "C:\Users\Song\Documents\UDEM\master thesis\uml
> data\database\umllabels\m
> anage.py", line 18, in main
> execute_from_command_line(sys.argv)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\core\
> management\__init__.py", line 419, in execute_from_command_line
> utility.execute()
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\core\
> management\__init__.py", line 413, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\core\
> management\base.py", line 354, in run_from_argv
> self.execute(*args, **cmd_options)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\core\
> management\base.py", line 398, in execute
> output = self.handle(*args, **options)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\core\
> management\base.py", line 89, in wrapped
> res = handle_func(*args, **kwargs)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\core\
> management\commands\migrate.py", line 75, in handle
> self.check(databases=[database])
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\core\
> management\base.py", line 419, in check
> all_issues = checks.run_checks(
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\core\
> checks\registry.py", line 76, in run_checks
> new_errors = check(app_configs=app_configs, databases=databases)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\core\
> checks\urls.py", line 13, in check_url_config
> return check_resolver(resolver)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\core\
> checks\urls.py", line 23, in check_resolver
> return check_method()
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\urls\
> resolvers.py", line 412, in check
> for pattern in self.url_patterns:
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\utils
> \functional.py", line 48, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\urls\
> resolvers.py", line 598, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\utils
> \functional.py", line 48, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\urls\
> resolvers.py", line 591, in urlconf_module
> return import_module(self.urlconf_name)
> File "C:\Program Files\Python39\lib\importlib\__init__.py", line 127,
> in impor
> t_module
> return _bootstrap._gcd_import(name[level:], package, level)
> File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
> File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
> File "<frozen importlib._bootstrap>", line 986, in
> _find_and_load_unlocked
> File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
> File "<frozen importlib._bootstrap_external>", line 790, in exec_module
> File "<frozen importlib._bootstrap>", line 228, in
> _call_with_frames_removed
> File "C:\Users\Song\Documents\UDEM\master thesis\uml
> data\database\umllabels\u
> mllabels\urls.py", line 24, in <module>
> path('labeling/', include(('labeling.urls', 'labeling'),
> namespace="labeling
> ")),
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\urls\
> conf.py", line 34, in include
> urlconf_module = import_module(urlconf_module)
> File "C:\Program Files\Python39\lib\importlib\__init__.py", line 127,
> in impor
> t_module
> return _bootstrap._gcd_import(name[level:], package, level)
> File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
> File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
> File "<frozen importlib._bootstrap>", line 986, in
> _find_and_load_unlocked
> File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
> File "<frozen importlib._bootstrap_external>", line 790, in exec_module
> File "<frozen importlib._bootstrap>", line 228, in
> _call_with_frames_removed
> File "C:\Users\Song\Documents\UDEM\master thesis\uml
> data\database\umllabels\l
> abeling\urls.py", line 3, in <module>
> from . import views
> File "C:\Users\Song\Documents\UDEM\master thesis\uml
> data\database\umllabels\l
> abeling\views.py", line 2, in <module>
> from labeling.sampler import Sampler, block
> File "C:\Users\Song\Documents\UDEM\master thesis\uml
> data\database\umllabels\l
> abeling\sampler.py", line 108, in <module>
> class Sampler:
> File "C:\Users\Song\Documents\UDEM\master thesis\uml
> data\database\umllabels\l
> abeling\sampler.py", line 111, in Sampler
> largest_class_count =
> Model.objects.order_by("-classes").first().classes
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\mo
> dels\query.py", line 674, in first
> for obj in (self if self.ordered else self.order_by('pk'))[:1]:
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\mo
> dels\query.py", line 280, in __iter__
> self._fetch_all()
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\mo
> dels\query.py", line 1324, in _fetch_all
> self._result_cache = list(self._iterable_class(self))
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\mo
> dels\query.py", line 51, in __iter__
> results = compiler.execute_sql(chunked_fetch=self.chunked_fetch,
> chunk_size=
> self.chunk_size)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\mo
> dels\sql\compiler.py", line 1175, in execute_sql
> cursor.execute(sql, params)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\ba
> ckends\utils.py", line 66, in execute
> return self._execute_with_wrappers(sql, params, many=False,
> executor=self._e
> xecute)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\ba
> ckends\utils.py", line 75, in _execute_with_wrappers
> return executor(sql, params, many, context)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\ba
> ckends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\ut
> ils.py", line 90, in __exit__
> raise dj_exc_value.with_traceback(traceback) from exc_value
> File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
> packages\django\db\ba
> ckends\utils.py", line 84, in _execute
> return self.cursor.execute(sql, params)
> django.db.utils.ProgrammingError: relation "labeling_model" does not
> exist
> LINE 1: ...del"."classes", "labeling_model"."relations" FROM
> "labeling_...
>
> }}}
New description:
To put my app on Heroku, I am changing my database from SQLite to Postgres
at the end of my project. Everything works fine locally on SQLite. But
during `python manage.py migrate --run-syncdb`, I get a
`ProgrammingError`. I was planning on loading the dumped json later in
Postgres.
I created a branch on my repo for you to reproduce this bug. The branch is
`postgres` and the commit is https://github.com/XsongyangX/uml-fragment-
labeling/commit/c14a49990b115bd0b8ba74640a7c65da301562d3
Here is the log.
{{{
$ py manage.py migrate --run-syncdb
Traceback (most recent call last):
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\ba
ckends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "labeling_model" does not exist
LINE 1: ...del"."classes", "labeling_model"."relations" FROM "labeling_...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Song\Documents\UDEM\master thesis\uml
data\database\umllabels\m
anage.py", line 22, in <module>
main()
File "C:\Users\Song\Documents\UDEM\master thesis\uml
data\database\umllabels\m
anage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\core\
management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\core\
management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\core\
management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\core\
management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\core\
management\base.py", line 89, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\core\
management\commands\migrate.py", line 75, in handle
self.check(databases=[database])
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\core\
management\base.py", line 419, in check
all_issues = checks.run_checks(
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\core\
checks\registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\core\
checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\core\
checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\urls\
resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\utils
\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\urls\
resolvers.py", line 598, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\utils
\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\urls\
resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Program Files\Python39\lib\importlib\__init__.py", line 127, in
impor
t_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in
_call_with_frames_removed
File "C:\Users\Song\Documents\UDEM\master thesis\uml
data\database\umllabels\u
mllabels\urls.py", line 24, in <module>
path('labeling/', include(('labeling.urls', 'labeling'),
namespace="labeling
")),
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\urls\
conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Program Files\Python39\lib\importlib\__init__.py", line 127, in
impor
t_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in
_call_with_frames_removed
File "C:\Users\Song\Documents\UDEM\master thesis\uml
data\database\umllabels\l
abeling\urls.py", line 3, in <module>
from . import views
File "C:\Users\Song\Documents\UDEM\master thesis\uml
data\database\umllabels\l
abeling\views.py", line 2, in <module>
from labeling.sampler import Sampler, block
File "C:\Users\Song\Documents\UDEM\master thesis\uml
data\database\umllabels\l
abeling\sampler.py", line 108, in <module>
class Sampler:
File "C:\Users\Song\Documents\UDEM\master thesis\uml
data\database\umllabels\l
abeling\sampler.py", line 111, in Sampler
largest_class_count =
Model.objects.order_by("-classes").first().classes
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\mo
dels\query.py", line 674, in first
for obj in (self if self.ordered else self.order_by('pk'))[:1]:
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\mo
dels\query.py", line 280, in __iter__
self._fetch_all()
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\mo
dels\query.py", line 1324, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\mo
dels\query.py", line 51, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch,
chunk_size=
self.chunk_size)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\mo
dels\sql\compiler.py", line 1175, in execute_sql
cursor.execute(sql, params)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\ba
ckends\utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False,
executor=self._e
xecute)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\ba
ckends\utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\ba
ckends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\ut
ils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\Song\AppData\Roaming\Python\Python39\site-
packages\django\db\ba
ckends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "labeling_model" does not exist
LINE 1: ...del"."classes", "labeling_model"."relations" FROM "labeling_...
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32968#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.e197abd70ec000496e662c21cf2d1c6b%40djangoproject.com.