Create SQL queries for migrations not related to a resource

Basically I want to be able to run something similar to a custom_statements but outside any resource, probably in a custom type or repo level. To be more specific, I'm porting this type https://github.com/elixirmoney/money/blob/v1.12.2/lib/money/ecto/composite_type.ex into a Ash.Type. For that type to work, I need to run execute "CREATE TYPE public.money_with_currency AS (amount integer, currency varchar(3))" in a migration file to actually create the custom type inside postgres. Of course, I can just create a migration file and add that line there manually, that would just work. But, if possible, I would like to do this thing in a more automatic way since that would prevent me from forgetting to add that migration when I copy that custom type to other projects. Is there any way to do that today? Or creating the migration manually is the only option?
GitHub
money/lib/money/ecto/composite_type.ex at v1.12.2 · elixirmoney/money
Elixir library for working with Money safer, easier, and fun... Is an interpretation of the Fowler's Money pattern in fun.prog. - money/lib/money/ecto/composite_type.ex at v1.12.2 · elixirm...
1 Reply
ZachDaniel
ZachDaniel2y ago
Currently creating a migration manually would be the only option. Or you can put it in the custom_statements of one of your resources. Which lets you do arbitrary migration stuff, but it has to be in a resource

Did you find this page helpful?