OpenEnergyPlatform / oeplatform

Repository for the code of the Open Energy Platform (OEP) website. The OEP provides an interface to the Open Energy Family
http://openenergyplatform.org/
GNU Affero General Public License v3.0
62 stars 19 forks source link

[API] Create table fails if whitelisted schema not exist #1220

Closed jh-RLI closed 1 year ago

jh-RLI commented 1 year ago

Description of the issue

This is bug is problematic mostly for developers who want to create a table in an empty database. The whitelisted schemas do not exist in this database. If one wants to create a table using the wizard there is an error "Internal Server error" the user cant understand what is going on. Looking at the django terminal, this error is raised:


sqlalchemy.exc.programmingerror: (psycopg2.errors.InvalidSchemaName) schema "model_draft" does not exist

LINE 2: CREATE TABLE model_[draft.tetet](https://draft.tetet/) (

^

[SQL:

CREATE TABLE model_[draft.tetet](https://draft.tetet/) (

id BIGSERIAL NOT NULL,

name CHAR(5),

PRIMARY KEY (id)

)

]

(Background on this error at: http://sqlalche.me/e/13/f405)

[08/May/2023 09:25:05] "PUT /api/v0/schema/model_draft/tables/tetet/ HTTP/1.1" 500 200062

[08/May/2023 09:25:35] "GET /dataedit/wizard/ HTTP/1.1" 200 23052

ERROR:root:READING

Steps to Reproduce

  1. Create empty database
  2. Start oeplatform django application
  3. User wizzard or api to create a table

Ideas of solution

As the schemas will not be part of the oep there should we should keep in mind to remove this code.

alternative solution:

Context and Environment

Workflow checklist

wingechr commented 1 year ago

mh.. did you run python manage.py alembic upgrade head

this should create the schemata in the oedb (oedb_datamodels/versions/5c098aa81e2c_create_schemas.py)

NOTE

this is NOT the django migration, but the oedb alembic migration

jh-RLI commented 1 year ago

Ahhh i knew i forgot something!

I try again.

jh-RLI commented 1 year ago

Thanks again for refreshing my memory. This solves this issue.