|
@@ -0,0 +1,32 @@
|
|
|
+#!/bin/bash
|
|
|
+
|
|
|
+
|
|
|
+# 定义函数
|
|
|
+function up {
|
|
|
+ migrate -verbose -source file://database/migrations -database "mysql://root:root@tcp(127.0.0.1)/ppadmin" up
|
|
|
+}
|
|
|
+
|
|
|
+function down {
|
|
|
+ migrate -verbose -source file://database/migrations -database "mysql://root:root@tcp(127.0.0.1)/ppadmin" down
|
|
|
+}
|
|
|
+
|
|
|
+function status {
|
|
|
+ migrate -verbose -source file://database/migrations -database "mysql://root:root@tcp(127.0.0.1)/ppadmin" version
|
|
|
+}
|
|
|
+
|
|
|
+function create {
|
|
|
+ migrate create -ext sql -dir database/migrations -seq "$1"
|
|
|
+}
|
|
|
+
|
|
|
+# 根据参数执行不同的函数
|
|
|
+if [ "$1" == "up" ]; then
|
|
|
+ up
|
|
|
+elif [ "$1" == "down" ]; then
|
|
|
+ down
|
|
|
+elif [ "$1" == "status" ]; then
|
|
|
+ status
|
|
|
+elif [ "$1" == "create" ]; then
|
|
|
+ create $2
|
|
|
+else
|
|
|
+ echo "nothing to do"
|
|
|
+fi
|