sezaru
Migrations are applied incorrectly in all repos
In my system I’m adding a second repo to connect. To do that I did the following changes:
config/config.exs
config :marketplace, Marketplace.ApRepo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "ap_dev",
port: 5432,
show_sensitive_data_on_connection_error: true,
pool_size: 10
lib/ap_repo.ex
defmodule Marketplace.ApRepo do
use AshPostgres.Repo, otp_app: :marketplace
end
lib/application.ex
defmodule Marketplace.Application do
def start(_, _) do
children = [
...
ApRepo
]
...
end
end
Then I added one resource to it and generated the migration.
A new migration file was correctly added to the priv/ap_repo/migrations directory.
But, when I ran the mix ash_postgres.migrate, the migration process applied all the migrations I have in my original Repo to the ApRepo and not only that new resource I created.
I did notice this warning from the documentation:
This is only really useful if your api or apis only use a single repo. If you
have multiple repos and you want to run a single migration and/or migrate/roll
them back to different points, you will need to use the ecto specific task, mix
ecto.migrate and provide your repo name.
So, does this means that I need to start using ecto.migrate from now on or only if more than one repo uses the same api?
Marked As Solved
zachdaniel
Also Liked
sezaru
Took me some time, but here is a small project that triggers the bug GitHub - sezaru/test_ash_multi_repo · GitHub
Basically it has 3 resources, resource 1 and 2 uses repo 1, resource 3 uses repo 2.
If you run mix reset Ash will generate the 3 resources in both DBs.
zachdaniel
You would want to mix ash_postgres.rollback -n 1 -r TheOnlyRepo. mix ash_postgres.rollback -n 1 couldn’t know which repo you want to do by default.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









