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