How to Delete Resource?
Dirigible:
I have a resource that has attributes and relationships to other resources. I want to delete it completely, how would I do that?
Dirigible:
Ok so I figured this out, in the end, posting here for posterity.
These are the steps I took:
-
Take note of what the resource is called in the db (in my case
cards
) - Delete the resource.
- remove the resource in the Registry, and in any other resource where its has a relationship.
-
generate a migration
mix ash_postgres.create_migrations --name
-
add
drop table(
in my case) drop table(:cards)
into theup/0
function. -
Run
mix ash_postgres.migrate
This worked for me, <@197905764424089601> hop in if I missed something. (Is there a topic for AshHQ on this, if not there probably should be?)
ZachDaniel:
Lol, go for it
ZachDaniel:
You may not have any changes when you generate migrations. So you may want to use
mix ecto.gen.migration
zimt28:
You might also need to remove constrains & indexes I guess? Would be nice if there was a generator for this 🙂
ZachDaniel:
Yeah, that’s true. I think the migration generator should do it. PRs welcome ❤️