ash-project / ash_postgres

The PostgreSQL data layer for Ash Framework
https://hexdocs.pm/ash_postgres
MIT License
134 stars 73 forks source link

Tenant migrations won't run without --domains #357

Closed TobiasFroberg closed 1 month ago

TobiasFroberg commented 1 month ago

Describe the bug I was trying to migrate my context-based tenant migrations today but couldn't and it seems like there could possibly be a bug in AshPostgres.Mix.Helpers introduced in this commit.

If I just do mix ash_postgres.migrate --tenants I get nothing at all as output. If I do supply --domains MyApp.MyDomain however, the migrations run. I also ensured that I do have config :my_app, ash_domains: [...] set in my config

To Reproduce

Expected behavior I expect the migration to run

Runtime

zachdaniel commented 1 month ago

🤔 interesting. Oh, are your ecto repos in config :my_app, ecto_repos: [...]? That is also a necessary set up step.

TobiasFroberg commented 1 month ago

🤔 interesting. Oh, are your ecto repos in config :my_app, ecto_repos: [...]? That is also a necessary set up step.

Yep, I also have that!

zachdaniel commented 1 month ago

🤔 🤔 this is pretty strange. Would you be able to provide a sample project that reproduces this behavior?

TobiasFroberg commented 1 month ago

Have a look here: https://github.com/TobiasFroberg/ash_postgres_357

➜ helpdesk git:(main) mix ash_postgres.migrate
➜ helpdesk git:(main)

But if I do:

➜ helpdesk git:(main) mix ash_postgres.migrate --domains Helpdesk.Support

15:25:00.954 [info] == Running 20240724131330 Helpdesk.Repo.Migrations.AddColumnsToCompanyTable.up/0 forward

Please note I'm still pretty new to Ash so I might'v done something wrong while trying to create a small reproduction.

zachdaniel commented 1 month ago

Awesome, thank you for the reproduction 🙇 This has been fixed in ash_postgres main and will be available in the next release.

zachdaniel commented 1 month ago

Fixed in e49b678351495d0b6b9e50252912b5247092d8d1