Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cascade option for dbRemoveTable() #463

Open
asadow opened this issue Feb 8, 2024 · 2 comments
Open

cascade option for dbRemoveTable() #463

asadow opened this issue Feb 8, 2024 · 2 comments

Comments

@asadow
Copy link

asadow commented Feb 8, 2024

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.
@krlmlr
Copy link
Member

krlmlr commented Feb 8, 2024

Thanks. Not all databases support CASCADE, and it seems very easy to create an SQL that does just that. I'd be open to supporting sqlRemoveTable(), similarly to sqlCreateTable() .

@krlmlr
Copy link
Member

krlmlr commented Feb 8, 2024

The objective would be to make it easy for the user to append " CASCADE" to a query created by that function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants