Upload
thuc-le-dong
View
406
Download
0
Embed Size (px)
Citation preview
Database VersioningIn Golang
- Missing changes.- Code’s version and database’s version.- Missing setting’s versioning.
Problem
What way we have
Communication
Beego migration
Beego migration
Beego migration
Beego migration
- Miss version
- Can’t delete or edit
- Miss default setting
- Depend on beego framework
Good database versioning tool
mattes/migratehttps://github.com/mattes/migrate
- Versioning database.- Support default setting records.- Support rollback and change version.- Independence tool.
mattes/migrateSupported databases: - Postgresql - Mysql - Sqlite - CassandraAllows custom to add unsupported databases.
step 1: Create simple project:go get github.com/ledongthuc/simple-golang-app
cd $GOPATH/src/github.com/ledongthuc/simple-golang-app/
step 1: Create simple project:
step 2: Add mattes/migrate library
go get github.com/mattes/migrate
https://gist.github.com/ledongthuc/f452eb0d6dfe97d0b4de
step 2: Add mattes/migrate library
Add folder sql
Using with command line
1 - up all migration
2 - down all migration
3 - Redo an action
4 - Reset database
5 - Go to specific version