File tree Expand file tree Collapse file tree 1 file changed +5
-38
lines changed Expand file tree Collapse file tree 1 file changed +5
-38
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,6 @@ import (
13
13
" gorm.io/gorm"
14
14
)
15
15
16
- var migrateFlag *bool
17
-
18
- func init () {
19
- migrateFlag = flag.Bool (" migrate" , false , " run the migration." )
20
- }
21
-
22
16
23
17
func main () {
24
18
db , _ := gorm.Open (sqlite.Open (" gorm.db" ), &gorm.Config {})
@@ -71,38 +65,11 @@ func main() {
71
65
},
72
66
}
73
67
74
- flag.Parse ()
75
- if *migrateFlag {
76
- err := migo.Run (db, migrations)
77
- if err != nil {
78
- log.Fatalln (err)
79
- }
68
+ err := migo.Run (dbClient, migrations, " up" , *migo.DefaultOptions .WithPgSchema (" <YOUR PGSCHEMA>" ))
69
+ if err != nil {
70
+ log.Fatalln (err)
80
71
}
81
- }
82
-
83
- ```
84
- # Usage
85
72
86
- ## up
87
-
88
- Apply all available migrations.
89
- ``` sh
90
- $ go run main.go -migrate -pgschema=my_schema_name up
91
- $ 2022/08/25 02:07:27 Migration ran
92
- ```
93
-
94
- ## down
95
-
96
- Roll back a single migration from the current version.
97
- ``` sh
98
- $ go run main.go -migrate -pgschema=my_schema_name down
99
- $ 2022/08/25 02:07:27 Migration ran
100
- ```
101
-
102
- ## gen
73
+ }
103
74
104
- Generates the current timestamp, you can copy it to use it as an ID to you new migration
105
- ``` sh
106
- $ go run main.go -migrate gen
107
- $ 20220825031134
108
- ```
75
+ ```
You can’t perform that action at this time.
0 commit comments