File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,15 @@ func FileExists(fileName string) bool {
3333 return false
3434}
3535
36+ func TouchFile (fileName string ) error {
37+ f , err := os .OpenFile (fileName , os .O_APPEND | os .O_CREATE , 0755 )
38+ if err != nil {
39+ return (err )
40+ }
41+ defer f .Close ()
42+ return nil
43+ }
44+
3645// StringContainsAll returns true if `s` contains all non empty given `substrings`
3746// The function returns `false` if no non-empty arguments are given.
3847func StringContainsAll (s string , substrings ... string ) bool {
Original file line number Diff line number Diff line change @@ -281,6 +281,18 @@ func (this *Migrator) countTableRows() (err error) {
281281 return countRowsFunc ()
282282}
283283
284+ func (this * Migrator ) createFlagFiles () (err error ) {
285+ if this .migrationContext .PostponeCutOverFlagFile != "" {
286+ if ! base .FileExists (this .migrationContext .PostponeCutOverFlagFile ) {
287+ if err := base .TouchFile (this .migrationContext .PostponeCutOverFlagFile ); err != nil {
288+ return err
289+ }
290+ log .Infof ("Created postpone-cut-over-flag-file: %s" , this .migrationContext .PostponeCutOverFlagFile )
291+ }
292+ }
293+ return nil
294+ }
295+
284296// Migrate executes the complete migration logic. This is *the* major gh-ost function.
285297func (this * Migrator ) Migrate () (err error ) {
286298 log .Infof ("Migrating %s.%s" , sql .EscapeName (this .migrationContext .DatabaseName ), sql .EscapeName (this .migrationContext .OriginalTableName ))
@@ -312,6 +324,9 @@ func (this *Migrator) Migrate() (err error) {
312324 if err := this .initiateApplier (); err != nil {
313325 return err
314326 }
327+ if err := this .createFlagFiles (); err != nil {
328+ return err
329+ }
315330
316331 initialLag , _ := this .inspector .getReplicationLag ()
317332 log .Infof ("Waiting for ghost table to be migrated. Current lag is %+v" , initialLag )
You can’t perform that action at this time.
0 commit comments