当前位置:网站首页>Golang migrate is easy to use
Golang migrate is easy to use
2022-07-24 10:19:00 【Not Lao Wang who lives next door】
For more convenient database operation , Constantly adapt to business development needs ,migrate Used for database operation . Use migrate Will create a schema_migrations surface , To record migrate Records of operation , Whenever running migrate When , I will check this form first , If the in the table is True, May be an error .
golang-migrate Address :
golang-migrate Address :
https://github.com/golang-migrate/migrate
install :
windows10:
cmd Command input :
scoop install migrate
After installation :
cmd Command line input :
migrate -version
When the version information appears, the installation is successful .
Create migration file
grammar :
create [-ext E] [-dir D] [-seq] [-digits N] [-format] [-tz] NAME
migrate create -ext sql -dir db/migrate -seq init_schema
After successful operation, it will be automatically in db/migrate The corresponding migration file is generated under the folder . Here's the picture
Insert picture description here 
Move up
The corresponding sql Statement write generated
000001_init_schema.up In file , And then execute the command
command :
migrate -path db/migration -database "mysql://root:[email protected](localhost:3306)/blog" -verbose up
Roll back
The corresponding sql Statement write generated
000001_init_schema.down In file , And then execute the command
migrate -path db/migration -database "mysql://root:[email protected](localhost:3306)/blog" -verbose down
After success in the database
边栏推荐
- [STM32 learning] (9) stm32f1 general timer realizes simple breathing lamp
- Websocket 协议解读-RFC6455
- How many indexes are associated indexes under MySQL InnoDB?
- [STM32 learning] (17) STM32 realizes LCD12864 display serial implementation
- [recommendation system] the classic technical architecture of the data flow of the recommendation system + the most complete evolution map of the top 10 deep learning CTR models of Microsoft, Alibaba,
- Dynamic programming -- a collection of stock problems
- SMTP automatic mail sending function code
- 差分约束系统---1且2--2022年5月27日
- Common Unicode encoding range
- Do you really understand the concept of buffer? Take you to uncover the buffer zone~
猜你喜欢

JMeter setting default startup Chinese

ffmpeg花屏解决(修改源码,丢弃不完整帧)

CMS vulnerability recurrence - ultra vires vulnerability
![[STM32 learning] (12) STM32 realizes LCD1602 simple static reality](/img/78/954ebaae0cce5d9387e7032fa85e60.png)
[STM32 learning] (12) STM32 realizes LCD1602 simple static reality

Dynamic programming -- a collection of stock problems

【机器人学习】机构运动学分析与matlab仿真(三维模型+word报告+matlab程序)
![[STM32 learning] (4) press the key to control the flow light](/img/2a/b26860e2c65c0790a60ac207bf52ec.png)
[STM32 learning] (4) press the key to control the flow light

图像处理:RGB565转RGB888

分布式锁-Redission 原理分析

How to solve the problem of robot positioning and navigation in large indoor scenes with low-cost solutions?
随机推荐
[STM32 learning] (10) stm32f1 general timer realizes pulse counter
OpenGL drawing simple triangles
Rust tokio:: task:: localset running mode
Ribbon's loadbalancerclient, zoneawareloadbalancer and zoneavoidancerule are three musketeers by default
[robot learning] mechanism kinematics analysis and MATLAB simulation (3D model +word report +matlab program)
Balance between management / business and technology
[correcting Hongming] what? I forgot to take the "math required course"!
zoj-Swordfish-2022-5-6
Binary original code, inverse code, complement code
[STM32 learning] (15) STM32 realizes DHT11 temperature and humidity acquisition and display
Taurus. How to upgrade and run MVC on net6 and net7
Erlang学习番外
Dr. water 3
2022, enterprise informatization construction based on Unified Process Platform refers to thubierv0.1
Uniapp uses PWA
【LeeCode】获取2个字符串的最长公共子串
脚手架文件目录说明、文件暴露
Implementation and traversal of binary tree and binary tree sorting tree
第五章 修改实现(IMPL)类
[STM32 learning] (13) STM32 realizes ultrasonic ranging (hc-sr04)