Re: [Django] #32968: Migration errors from SQLite to Postgres

2021-07-27 Thread Django
#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 
> 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 

Re: [Django] #32968: Migration errors from SQLite to Postgres

2021-07-27 Thread Django
#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
-+-
Changes (by Tim Graham):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 This isn't a bug. You have [https://github.com/XsongyangX/uml-fragment-
 labeling/blob/c14a49990b115bd0b8ba74640a7c65da301562d3/labeling/sampler.py#L111
 a query running at the module level] which isn't safe. See
 [https://groups.google.com/g/django-developers/c/7JwWatLfP44 django-
 developers discussion] for more details.

 Next time, please use TicketClosingReasons/UseSupportChannels to debug
 your issue and open an issue here only if you confirm that Django is at
 fault. Thanks!

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.7f8ac03046812d1c3fe2e4c03fce7cff%40djangoproject.com.