Skip to content

Instantly share code, notes, and snippets.

@zhaohangbo
Created September 1, 2016 04:41
Show Gist options
  • Save zhaohangbo/8bfaa9c344ec7c7f33702ee89998c693 to your computer and use it in GitHub Desktop.
Save zhaohangbo/8bfaa9c344ec7c7f33702ee89998c693 to your computer and use it in GitHub Desktop.
sql-migrate工具
工具:sql-migrate
https://github.com/rubenv/sql-migrate
模板:mysql代码库from公司
http://git.yottabyte.cn/summary/mysql.git
Available commands are:
down Undo a database migration(只恢复一个)
redo Reapply the last migration
status Show migration status
up Migrates the database to the most recent version available
Status命令
sql-migrate status -config ~/yottabyte/mysql/migrate/rizhiyi_system/rizhiyi_system.yml -env="mysql"
Up命令
sql-migrate up -config ~/yottabyte/mysql/migrate/rizhiyi_system/rizhiyi_system.yml -env="mysql"
Down命令
sql-migrate down -config ~/yottabyte/mysql/migrate/rizhiyi_system/rizhiyi_system.yml -env="mysql"
注意.yml中的Datasource格式和路径配置
出错解决:
https://stackoverflow.com/questions/25244089/go-error-connecting-to-database-with-mysqldriver
https://github.com/go-sql-driver/mysql#examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment