sezaru

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

zachdaniel

Creator of Ash

Fixed in AshPostgres main branch.

Also Liked

sezaru

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

zachdaniel

Creator of Ash

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.

Where Next?

Popular in Questions Top

beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54250 245
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement