2024-08-20 06:12:13 +00:00
|
|
|
# migrate
|
|
|
|
數據庫遷移工具
|
|
|
|
|
|
|
|
[golang-migrate](https://github.com/golang-migrate/migrate)
|
|
|
|
|
|
|
|
## 安裝 make
|
|
|
|
```shell
|
2024-08-20 06:35:14 +00:00
|
|
|
brew install Makefile
|
2024-08-20 06:12:13 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## 安裝 golang-migrate
|
|
|
|
```shell
|
|
|
|
brew install golang-migrate
|
|
|
|
```
|
|
|
|
|
|
|
|
## 執行刪除 mysql schema
|
|
|
|
|
|
|
|
```shell
|
|
|
|
migrate -source file://database/migrations/mysql -database 'mysql://account:password@tcp(127.0.0.1:3306)/esc_c2c' down
|
|
|
|
```
|
|
|
|
|
|
|
|
## 執行安裝 mysql schema
|
|
|
|
|
|
|
|
```shell
|
|
|
|
migrate -source file://database/migrations/mysql -database 'mysql://account:password@tcp(127.0.0.1:3306)/esc_c2c' up
|
|
|
|
```
|
|
|
|
|
|
|
|
## 執行刪除 mongo schema
|
|
|
|
|
|
|
|
```shell
|
|
|
|
migrate -source file://database/migrations/mongodb -database 'mongodb://127.0.0.1:27017/esc_c2c' down
|
|
|
|
```
|
|
|
|
|
|
|
|
## 執行安裝 mongo schema
|
|
|
|
|
|
|
|
```shell
|
|
|
|
migrate -source file://database/migrations/mongodb -database 'mongodb://127.0.0.1:27017/esc_c2c' up
|
|
|
|
```
|
|
|
|
|