kjaymiller / cookiecutter-relecloud

Cookiecutter template for the Cloud Advocacy Relecloud Demo Application
MIT License
7 stars 5 forks source link

Unable to drop() in FastAPI #244

Closed pamelafox closed 11 months ago

pamelafox commented 11 months ago

Getting this when running the tests:

2023-11-03 12:50:16,474 INFO sqlalchemy.engine.Engine ROLLBACK
Traceback (most recent call last):
  File "/Users/pamelafox/cookiecutter-repos/azure-fastapi-postgres-flexible-aca/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/Users/pamelafox/cookiecutter-repos/azure-fastapi-postgres-flexible-aca/.venv/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
psycopg2.errors.DependentObjectsStillExist: cannot drop table cruise because other objects depend on it
DETAIL:  constraint cruise_destination_link_cruise_id_fkey on table cruise_destination_link depends on table cruise
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
pamelafox commented 11 months ago

Noting the schema uses REFERENCES-

REATE TABLE cruisedestinationlink ( destination_id INTEGER NOT NULL, cruise_id INTEGER NOT NULL, PRIMARY KEY (destination_id, cruise_id), FOREIGN KEY(destination_id) REFERENCES destination (id), FOREIGN KEY(cruise_id) REFERENCES cruise (id) )

INFO sqlalchemy.engine.Engine:base.py:1472 [no key 0.00009s] {} INFO sqlalchemy.engine.Engine:base.py:1472 CREATE TABLE inforequest ( id SERIAL NOT NULL, name VARCHAR NOT NULL, email VARCHAR NOT NULL, notes VARCHAR NOT NULL, cruise_id INTEGER, PRIMARY KEY (id), FOREIGN KEY(cruise_id) REFERENCES cruise (id) )