Ecto Mix Tasks CREATE EXTENSION

I’d like to run the following command after I create my db using mix ecto.create but before I run my migrations.

CREATE EXTENSION btree_gist

I require this extension for an exclusion constraint on one of my tables. Can I do this with Ecto?

2 Likes

Ecto has the execute function you can use: https://hexdocs.pm/ecto/Ecto.Migration.html#execute/1

So inside of a migration up/change you can put: execute "CREATE EXTENSION IF NOT EXISTS btree_gist"

4 Likes

Yes, that did it. Thanks!