Executing Multiple SQL Statements in Elixir
Working with raw SQL in the Elixir/Ecto world is not easy. I thought executing a multi-line SQL file in a database migration would be easy; it’s not. Here’s what I learned: The execute function does not support executing multiple statements at once. It’s perplexing that there’s no direct solution for this in Elixir. While AyeSQL claims raw SQL support, it mandates a one-statement-at-a-time approach. This limitation is particularly problematic when importing SQL designed to create triggers spanning multiple lines. For simple SQL tasks, you might consider splitting the raw SQL into multiple lines: But only if your SQL is well-formed and relatively simple…
Continue Reading