(have, want schema.Tables, messages message.WriteMigrateTables)
| 50 | } |
| 51 | |
| 52 | func checkForced(have, want schema.Tables, messages message.WriteMigrateTables) error { |
| 53 | nonAutoMigratableTables := make(map[string][]schema.TableColumnChange) |
| 54 | for _, m := range messages { |
| 55 | if m.MigrateForce { |
| 56 | continue |
| 57 | } |
| 58 | |
| 59 | // check that this migration can go through |
| 60 | have := have.Get(m.Table.Name) |
| 61 | if have == nil { |
| 62 | continue // create new is always OK |
| 63 | } |
| 64 | want := want.Get(m.Table.Name) // and it should never be nil |
| 65 | if unsafe := unsafeChanges(want.GetChanges(have)); len(unsafe) > 0 { |
| 66 | nonAutoMigratableTables[m.Table.Name] = unsafe |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | if len(nonAutoMigratableTables) > 0 { |
| 71 | return fmt.Errorf("\nCan't migrate tables automatically, migrate manually or consider using 'migrate_mode: forced'. Non auto migratable tables changes:\n\n%s", schema.GetChangesSummary(nonAutoMigratableTables)) |
| 72 | } |
| 73 | return nil |
| 74 | } |
| 75 | |
| 76 | func (c *Client) autoMigrateTable(ctx context.Context, have, want *schema.Table) error { |
| 77 | changes := want.GetChanges(have) |
no test coverage detected