MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / checkForced

Function checkForced

plugins/destination/mssql/client/migrate.go:52–74  ·  view source on GitHub ↗
(have, want schema.Tables, messages message.WriteMigrateTables)

Source from the content-addressed store, hash-verified

50}
51
52func 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
76func (c *Client) autoMigrateTable(ctx context.Context, have, want *schema.Table) error {
77 changes := want.GetChanges(have)

Callers 1

MigrateTablesMethod · 0.85

Calls 3

ErrorfMethod · 0.80
unsafeChangesFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected