https://github.com/qustavo/migrate
Easy migrations for Go
https://github.com/qustavo/migrate
Last synced: 2 months ago
JSON representation
Easy migrations for Go
- Host: GitHub
- URL: https://github.com/qustavo/migrate
- Owner: qustavo
- License: bsd-2-clause
- Created: 2020-03-26T09:18:45.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T12:09:28.000Z (about 5 years ago)
- Last Synced: 2025-02-15T06:16:20.053Z (2 months ago)
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Migrate
Migrate is a DSL for the Go programming lanuage that helps to migrate your SQL database.
Migrate is vendor independent and currently SQLite, MySQL and Postgres dialects are supported.This is experimental software and the API will change.
# Usage
```go
type migration struct {
CreateT1 CreateTable `version:"1"`
ChangeT1 ChangeTable `version:"2"`
RemoveT1 RemoveTable `version:"3"`
}var Migration = &migration{
CreateT1: func() (*Table, error) {
return NewTable("t1", func(t *Table) {
t.Field("id", SERIAL, PrimaryKey)
t.Field("email", VARCHAR, NotNull)
t.Field("username", VARCHAR, NotNull)
t.Field("password", VARCHAR, NotNull)
t.Field("pin", VARCHAR, Args(4)) // This produces a VARCHAR(4)
}), nil
},ChangeT1: func() (*Change, error) {
return NewChange("t1", func(c *Change) {
c.Remove("pin")
c.Add("address", TEXT)
}), nil
},RemoveT1: func() (string, error) {
return "t1", nil
},
}
```