@@ -57,9 +57,11 @@ func (env *ServiceEnv) InitDB(config config.Config) error {
57
57
return err
58
58
}
59
59
60
- err = db .Migrate (ctx , MySQLDatastoreMigrationVersion )
61
- if err != nil {
62
- return err
60
+ if config .AutoMigrate {
61
+ err = db .Migrate (ctx , MySQLDatastoreMigrationVersion )
62
+ if err != nil {
63
+ return err
64
+ }
63
65
}
64
66
65
67
env .Datastore = db
@@ -73,9 +75,11 @@ func (env *ServiceEnv) InitDB(config config.Config) error {
73
75
return err
74
76
}
75
77
76
- err = db .Migrate (ctx , PostgresDatastoreMigrationVersion )
77
- if err != nil {
78
- return err
78
+ if config .AutoMigrate {
79
+ err = db .Migrate (ctx , PostgresDatastoreMigrationVersion )
80
+ if err != nil {
81
+ return err
82
+ }
79
83
}
80
84
81
85
env .Datastore = db
@@ -89,9 +93,11 @@ func (env *ServiceEnv) InitDB(config config.Config) error {
89
93
return err
90
94
}
91
95
92
- err = db .Migrate (ctx , SQLiteDatastoreMigrationVersion )
93
- if err != nil {
94
- return err
96
+ if config .AutoMigrate {
97
+ err = db .Migrate (ctx , SQLiteDatastoreMigrationVersion )
98
+ if err != nil {
99
+ return err
100
+ }
95
101
}
96
102
97
103
env .Datastore = db
@@ -112,9 +118,11 @@ func (env *ServiceEnv) InitEventDB(config config.Config) error {
112
118
return err
113
119
}
114
120
115
- err = db .Migrate (ctx , MySQLEventstoreMigrationVersion )
116
- if err != nil {
117
- return err
121
+ if config .AutoMigrate {
122
+ err = db .Migrate (ctx , MySQLEventstoreMigrationVersion )
123
+ if err != nil {
124
+ return err
125
+ }
118
126
}
119
127
120
128
env .Eventstore = db
@@ -128,9 +136,11 @@ func (env *ServiceEnv) InitEventDB(config config.Config) error {
128
136
return err
129
137
}
130
138
131
- err = db .Migrate (ctx , PostgresEventstoreMigrationVersion )
132
- if err != nil {
133
- return err
139
+ if config .AutoMigrate {
140
+ err = db .Migrate (ctx , PostgresEventstoreMigrationVersion )
141
+ if err != nil {
142
+ return err
143
+ }
134
144
}
135
145
136
146
env .Eventstore = db
@@ -144,9 +154,11 @@ func (env *ServiceEnv) InitEventDB(config config.Config) error {
144
154
return err
145
155
}
146
156
147
- err = db .Migrate (ctx , SQLiteEventstoreMigrationVersion )
148
- if err != nil {
149
- return err
157
+ if config .AutoMigrate {
158
+ err = db .Migrate (ctx , SQLiteEventstoreMigrationVersion )
159
+ if err != nil {
160
+ return err
161
+ }
150
162
}
151
163
152
164
env .Eventstore = db
0 commit comments