MCPcopy Index your code
hub / github.com/helm/helm / checkAlreadyApplied

Method checkAlreadyApplied

pkg/storage/driver/sql.go:103–134  ·  view source on GitHub ↗

Check if all migrations al

(migrations []*migrate.Migration)

Source from the content-addressed store, hash-verified

101
102// Check if all migrations al
103func (s *SQL) checkAlreadyApplied(migrations []*migrate.Migration) bool {
104 // make map (set) of ids for fast search
105 migrationsIDs := make(map[string]struct{})
106 for _, migration := range migrations {
107 migrationsIDs[migration.Id] = struct{}{}
108 }
109
110 // get list of applied migrations
111 migrate.SetDisableCreateTable(true)
112 records, err := migrate.GetMigrationRecords(s.db.DB, postgreSQLDialect)
113 migrate.SetDisableCreateTable(false)
114 if err != nil {
115 s.Logger().Debug("failed to get migration records", slog.Any("error", err))
116 return false
117 }
118
119 for _, record := range records {
120 if _, ok := migrationsIDs[record.Id]; ok {
121 s.Logger().Debug("found previous migration", "id", record.Id, "appliedAt", record.AppliedAt)
122 delete(migrationsIDs, record.Id)
123 }
124 }
125
126 // check if all migrations applied
127 if len(migrationsIDs) != 0 {
128 for id := range migrationsIDs {
129 s.Logger().Debug("find unapplied migration", "id", id)
130 }
131 return false
132 }
133 return true
134}
135
136func (s *SQL) ensureDBSetup() error {
137

Callers 2

ensureDBSetupMethod · 0.95

Calls 1

LoggerMethod · 0.65

Tested by 1