(args []string, interactive bool)
| 194 | } |
| 195 | |
| 196 | func (p *plugin) migrateCollectionsHandler(args []string, interactive bool) (string, error) { |
| 197 | createArgs := []string{"collections_snapshot"} |
| 198 | createArgs = append(createArgs, args...) |
| 199 | |
| 200 | collections := []*core.Collection{} |
| 201 | if err := p.app.CollectionQuery().OrderBy("created ASC").All(&collections); err != nil { |
| 202 | return "", fmt.Errorf("failed to fetch migrations list: %v", err) |
| 203 | } |
| 204 | |
| 205 | var template string |
| 206 | var templateErr error |
| 207 | if p.config.TemplateLang == TemplateLangJS { |
| 208 | template, templateErr = p.jsSnapshotTemplate(collections) |
| 209 | } else { |
| 210 | template, templateErr = p.goSnapshotTemplate(collections) |
| 211 | } |
| 212 | if templateErr != nil { |
| 213 | return "", fmt.Errorf("failed to resolve template: %v", templateErr) |
| 214 | } |
| 215 | |
| 216 | return p.migrateCreateHandler(template, createArgs, interactive) |
| 217 | } |
no test coverage detected