AddMigrations appends migrations to the list of migrations. Migrations are executed in the order they are added to the list. De-duplicates migrations using their Version field.
(migrations ...Migration)
| 69 | // AddMigrations appends migrations to the list of migrations. Migrations are executed |
| 70 | // in the order they are added to the list. De-duplicates migrations using their Version field. |
| 71 | func (m *Migrator) AddMigrations(migrations ...Migration) { |
| 72 | m.mutex.Lock() |
| 73 | defer m.mutex.Unlock() |
| 74 | for _, mig := range migrations { |
| 75 | if _, ok := m.knownMigrations[mig.Version]; !ok { |
| 76 | m.migrations = append(m.migrations, mig) |
| 77 | m.knownMigrations[mig.Version] = struct{}{} |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | // Up executes all migrations in order they were added. |
| 83 | func (m *Migrator) Up(ctx context.Context) error { |