rubenv / rubenv/sql-migrate

Need way to show merged status of schema

Open
#106 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
3.4k
Forks
292
PR merge metrics
No merged PRs in 30d

Description

We recently had a nasty issue where someone dropped a prod table because they ran the migration file directly (another discussion) instead of using sql-migrate.

But when it came time to re-create the table, they simply found a migration that had the CREATE TABLE and used that schema. Obviously there is no guarantee that later migrations don't further update that schema. I couldn't find an easy way to suggest how to identify what the schema should look like, despite having spent months on this versioning work.

So, would there be any support for introducing a new option like :
sql-migrate --show


which would print out a valid schema for a particular table at some point in the versioning life-cycle?

I.t.o. implementing such a function, I imagine it would require creating a tmp table&db and running against that, and then extracting the final schema, cleaning it up and printing the output.

Any thoughts appreciated.

Contributor guide

No contributing guide indexed for this repository

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

Start by reviewing sql-migrate's CLI option handling and migration execution path; the issue names no files or tests to begin with. Determine the expected meaning of the table and optional level arguments, then define completion as producing the table schema at the requested point without altering the real database, with cleanup and output behavior covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
cli, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.