Skip to content

When auto migration is not enough to covering your cases

Notifications You must be signed in to change notification settings

crowdedev/upgrade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Crowde Upgrader

Motivation

Deployment to production is hard step when we have many changes in database including create new table, remove unused table, add new record, makesurement that records in some table is not duplicate and many others step.

We need to make sure each processes are predictable, maintainable, easy to trace and separate between checking condition and executing upgrade to prevent human errors

Install

go get github.com/crowdeco/upgrade

Usage

type AddNewRecordInSomethingTable struct {
    DB *gorm.DB
}

func (a *AddNewRecordInSomethingTable) Upgrade() {
    //AddNewRecordInSomethingTable Logic without need to check if record exist or not because checking is handled by Support() function
}

func (a *AddNewRecordInSomethingTable) Support() bool {
    a := checkIfRecordExistInSomethingTable()
    if a {
        return false
    }

    return true
}

func (a *AddNewRecordInSomethingTable) Order() int {
    return 1
}
upgrade := AddNewRecordInSomethingTable{DB: db}

upgrader := Upgrader{}
upgrader.Register([]{upgrade})
upgrader.Run()

About

When auto migration is not enough to covering your cases

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages