rubenv / rubenv/sql-migrate

Ability to extend the sql-migrate#Migration

Open
#59 0 comments 3 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

Currently the https://godoc.org/github.com/rubenv/sql-migrate#Migration has the Up, Down []string which I guess will be read and run by migrate.Exec.
It would be nice if the Migration is an interface then we can do some update that need more than SQL script. For example:

type ComplexPwdGenMigration {
	DB
}
func (m *ComplexMigration) Up() []string {
// then something like:
// people := m.DB.GetAll()
// for each person in fo person.password = veryComplexPasswordGenerate(person.id) + m.DB.Save(person)
	return nil
}
//  and implement the rest method of 
migrations := &MixMigrationSource{
	Migrations: []Migrator{
		&migrate.Migration{
			Id:   "123",
			Up:   []string{"CREATE TABLE people (id int, password var)"},
			Down: []string{"DROP TABLE people"},
		},
		&ComplexPwdGenMigration,
		&AnotherComplexProcessMigration,
		&migrate.Migration{
			Id:   "123",
			Up:   []string{"...."},
			Down: []string{"....."},
		},
	},
}

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 with Migration, migrate.Exec, MixMigrationSource, and Migrator to understand the current SQL-only contract. Compare how existing migrations are represented and executed, then define and verify support for custom migration work alongside SQL Up and Down operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.