Skip to content

Possible unsafe migrations warning #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dkuku opened this issue Jan 15, 2025 · 2 comments
Open

Possible unsafe migrations warning #462

dkuku opened this issue Jan 15, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@dkuku
Copy link

dkuku commented Jan 15, 2025

I'm working through the book and I see that when a migration is generated for new index it's not applying concurrently: true

  def up do
    create unique_index(:albums, [:name, :artist_id],
             name: "albums_unique_album_names_per_artist_index"
           )
  end

This locks the table and with bigger databases can cause problems:
postgres docs
there are some libraries that will let you know about unsafe migrations where you can check what to avoid
rails - there is also one for elixir but as ash generates the migrations most of the stuff can be applied by changing the codegen.

@dkuku dkuku added enhancement New feature or request needs review labels Jan 15, 2025
@zachdaniel
Copy link
Contributor

There are some extra considerations with concurrent index creation, because it can't be done in a transaction. We have tools for it with custom indexes and we could potentially do it by default or allow the default to be configured for identities.

@zachdaniel
Copy link
Contributor

Yeah, I think we could do it by default for identities on tables that we didn't just create, and shuffle them into their own separate migration with the transaction disabled like we do for concurrent custom indexes. PRs welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Someday
Development

No branches or pull requests

2 participants