该Ecto.Migration.execute/1功能就是您要寻找的。您可以使用它来执行任意的SQL命令,例如创建用户,模式或向数据库添加扩展。
Ecto.Migration.execute/1
defmodule Example.Migrations.MakeSchema do use Ecto.Migration execute "CREATE SCHEMA example" end