~cedric/freshermeat#1: 
`flask db_create` fails with `relation "organization" does not exist`

Full trace:

Traceback (most recent call last):
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
psycopg2.errors.UndefinedTable: relation "organization" does not exist
LINE 2: FROM organization
             ^


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

Traceback (most recent call last):
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/bin/flask", line 8, in <module>
    sys.exit(main())
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/flask/cli.py", line 986, in main
    cli.main()
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/flask/cli.py", line 567, in main
    return super().main(*args, **kwargs)
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/click/core.py", line 1651, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/click/core.py", line 1698, in resolve_command
    cmd = self.get_command(ctx, cmd_name)
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/flask/cli.py", line 523, in get_command
    return info.load_app().cli.get_command(ctx, name)
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/flask/cli.py", line 373, in load_app
    app = locate_app(import_name, None, raise_if_not_found=False)
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/flask/cli.py", line 214, in locate_app
    __import__(module_name)
  File "/Volumes/TOSHIBA-EXT/ghq/github.com/cedricbonhomme/freshermeat/runserver.py", line 43, in <module>
    from freshermeat.web import views
  File "/Volumes/TOSHIBA-EXT/ghq/github.com/cedricbonhomme/freshermeat/freshermeat/web/views/__init__.py", line 1, in <module>
    from freshermeat.web.views import session_mgmt
  File "/Volumes/TOSHIBA-EXT/ghq/github.com/cedricbonhomme/freshermeat/freshermeat/web/views/session_mgmt.py", line 40, in <module>
    from freshermeat.web.forms import SigninForm
  File "/Volumes/TOSHIBA-EXT/ghq/github.com/cedricbonhomme/freshermeat/freshermeat/web/forms.py", line 105, in <module>
    class AddProjectForm(FlaskForm):
  File "/Volumes/TOSHIBA-EXT/ghq/github.com/cedricbonhomme/freshermeat/freshermeat/web/forms.py", line 124, in AddProjectForm
    [(org.id, org.name) for org in Organization.query.all()]
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 2772, in all
    return self._iter().all()
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 2907, in _iter
    result = self.session.execute(
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1712, in execute
    result = conn._execute_20(statement, params or {}, execution_options)
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1705, in _execute_20
    return meth(self, args_10style, kwargs_10style, execution_options)
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/sql/elements.py", line 333, in _execute_on_connection
    return connection._execute_clauseelement(
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1572, in _execute_clauseelement
    ret = self._execute_context(
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context
    self._handle_dbapi_exception(
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2124, in _handle_dbapi_exception
    util.raise_(
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
    raise exception
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/Users/fermigier/envs/freshermeat-8SDzs2bJ-py3.10/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "organization" does not exist
LINE 2: FROM organization
             ^

[SQL: SELECT organization.id AS organization_id, organization.name AS organization_name, organization.description AS organization_description, organization.short_description AS organization_short_description, organization.organization_type AS organization_organization_type, organization.website AS organization_website, organization.last_updated AS organization_last_updated, organization.cve_vendor AS organization_cve_vendor, organization.icon_url AS organization_icon_url
FROM organization]
(Background on this error at: https://sqlalche.me/e/14/f405)
Status
REPORTED
Submitter
~sfermigier
Assigned to
No-one
Submitted
1 year, 8 months ago
Updated
1 year, 8 months ago
Labels
No labels applied.

~cedric 1 year, 8 months ago

Hello,

Thank you for the report!

Could you please try with:

FLASK_APP=freshermeat/commands flask db_create
FLASK_APP=freshermeat/commands flask db_init

It should work with this.

I see the error, but I must spend more time on it.

~sfermigier 1 year, 8 months ago

Thanks, it works.

Register here or Log in to comment, or comment via email.