luckyframework / luckyframework/avram

Running migrations asynchronously

Open
#1,125 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Crystal
Stars
183
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Not sure if this is a good idea or not, but I have this index I'm trying to run and as of this writing, it's now been running for 30 minutes. Luckily I ran this in a console, but then I got to thinking "What if I ran this in a migration? 🤔 "... In my case, migrations happen when I deploy. This would mean that the deployment wouldn't complete until this migration finished.

Assuming I ran just a raw sql execute here, could I run this asynchronously? I guess the first major issue would be that if the very next migration required knowledge that the previous one ran, it would just all blow up... I guess this would be one of those dangerous use at your own risk situations....

Would this work? Maybe we don't need to build something directly in to Avram?

def migrate
  spawn do
    execute <<-SQL
    CREATE INDEX CONCURRENTLY .....
    SQL
  end
end

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names Avram migrations, the migrate method, Crystal's spawn, and raw SQL using CREATE INDEX CONCURRENTLY, but no files or tests. Start by locating the migration runner and checking how it sequences execute calls; done requires deciding whether asynchronous migrations are supported and how completion and migration dependencies are handled.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal, postgres
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.