https://github.com/deedlefake/migration
An experimental DSL-based database migration system for Go.
https://github.com/deedlefake/migration
database go golang migrations sql
Last synced: about 2 months ago
JSON representation
An experimental DSL-based database migration system for Go.
- Host: GitHub
- URL: https://github.com/deedlefake/migration
- Owner: DeedleFake
- License: mit
- Created: 2021-12-02T00:01:03.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-04T05:16:13.000Z (about 4 years ago)
- Last Synced: 2025-09-26T03:57:35.740Z (9 months ago)
- Topics: database, go, golang, migrations, sql
- Language: Go
- Homepage:
- Size: 62.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
migration
=========
migration is a project to create a Go framework for handling database migrations using actual Go code. It is still in early development, but the general idea is to pattern migration definition after `go test` unit test definitions. A user should be able to write a package containing functions that look like the example below, run `go generate`, and get a package that they can import elsewhere in their module that will perform the desired migrations on an `*sql.DB` instance.
Example of Intended Functionality
---------------------------------
This is very early design and hasn't been thought through completely yet. The idea is to pattern after ActiveRecord's migrations, but with some changes. In particular, a dependency system is planned that will hopefully make it easier to structure migrations in a project being worked on by multiple people simultaneously.
```go
func MigrateInit(m *migration.M) {
m.CreateTable("example", func(t *migration.T) {
t.AddColumn("id", migration.BigInt).PrimaryKey()
t.AddColumn("name", migration.String).NotNull(),
t.AddColumn("val", migration.String)
})
}
func MigrateMakeValNotNull(m *migration.M) {
m.Require("Init")
m.AlterTable("example", func(t *migration.T) {
t.Column("val").NotNull()
})
}
```