Ok, this was easier than anticipated.
I created a macro like this:
defmacro sqlite_or_postgres(do: code) do
quote do
if unquote(App.Config.use_sqlite?()) do
import AshSqlite.DataLayer
sqlite do
unquote(code)
end
else
import AshPostgres.DataLayer
postgres do
unquote(code)
end
end
end
end
And can use it like this:
sqlite_or_postgres do
table "things"
repo App.Repo
# ...
end
I’m sure this will shoot me in the foot at some point when I need to use a feature that only exist in postgres, but for now it seems to work nicely ![]()


















