Skip to content

cascade option for dbRemoveTable() #463

@asadow

Description

@asadow

I'm not sure how to create a temporary Postgres to reprex this.

Is a cascade option for dbRemoveTable() worth it? I was playing around with the dm package and wanted to clean my database of all tables. I got the below error. Then I checked for a cascade option. However the challenge was easily circumvented by dropping the child table manually first, before running map().

purrr::map(dbListTables(conn), \(x) dbRemoveTable(conn, x))
Error in `purrr::map()`:
ℹ In index: 1.
Caused by error:
! Failed to fetch row : ERROR:  cannot drop table department because other objects depend on it
DETAIL:  constraint employee_dept_fkey on table employee depends on table department
HINT:  Use DROP ... CASCADE to drop the dependent objects too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions