rubenv / rubenv/sql-migrate

Add a 'new' command

Open
#23 8 comments 2 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

Just wondered if others would find this useful...

I'd like to see a new command so when using the command line I can do

sql-migrate new udf-ParseDate

and it create a templated file in the ./migration folder (or what ever this is set in the config) named <current epoch>-<name>.sql, eg: 1443610373-udf-ParseDate.sql

The templating would have the -- +migrate Up and -- +migrate Down defined.

An enhancement to this would be to take the name and scan for the last migration matching the name and populate the migrate Down section of the template from the last migrate Up script.

Comments appreciated, if people like this I'll look at PR.

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 tracing the CLI command handling for sql-migrate and how the configured migration directory is resolved. Define the basic new command around the requested epoch-name filename and Up/Down template; the optional reuse of a previous migration's Up section should be treated as separate scope. Done means a generated file appears in the configured directory with the requested contents.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
cli, database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.