ash-project / ash-project/ash_postgres

Add mix task to undo latest codegen/delete latest migration

Open
#490 16 comments 0 reactions 0 assignees View on GitHub
enhancement needs review
Dominant language
Elixir
Stars
189
Forks
168
Avg merge
13h 1m
Merged PRs (30d)
22

Description

**Is your feature request related to a problem? Please describe.**

Codegen to generate a migration is really awesome, but sometimes you generate a migration and then you realize you missed something, so you want to delete that migration, make the change, and then generate it again. Currently that's a manual process - go find the migration, find the snapshots for all the relevant tables, delete them all, and do it again. It's pretty annoying!

**Describe the solution you'd like**

A task like `ash_postgres.delete_latest_migration` that will delete the last migration, and any snapshots that were created at the same time. No option to delete other migrations or anything like that - only the last one.

And it should probably confirm the name of the migration just to make sure!

**Describe alternatives you've considered**

You could just generate another migration with the added changes, but snapshot files are big and ugly and if you haven't even run the first migration, being able to undo/regenerate it seems like the smarter approach.

Contributor guide

Open the contributing guide

Research direction

Start by locating the mix task that generates migrations and the code responsible for migration and table snapshot files. Trace how the latest migration and its associated snapshots are identified, then review existing task tests or migration-generation tests. Done means a task named ash_postgres.delete_latest_migration removes only the latest migration and its snapshots after confirming the migration name.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir, postgresql
Domain
cli, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.