parseMigration parses a migration definition and adds the resulting resource to p.Resources.
(node *Node)
| 11 | |
| 12 | // parseMigration parses a migration definition and adds the resulting resource to p.Resources. |
| 13 | func (p *Parser) parseMigration(node *Node) error { |
| 14 | // Parse YAML |
| 15 | tmp := &MigrationYAML{} |
| 16 | err := p.decodeNodeYAML(node, false, tmp) |
| 17 | if err != nil { |
| 18 | return err |
| 19 | } |
| 20 | |
| 21 | // Add resource |
| 22 | r, err := p.insertResource(ResourceKindMigration, node.Name, node.Paths, node.Refs...) |
| 23 | if err != nil { |
| 24 | return err |
| 25 | } |
| 26 | // NOTE: After calling insertResource, an error must not be returned. Any validation should be done before calling it. |
| 27 | |
| 28 | if node.Connector != "" { |
| 29 | r.MigrationSpec.Connector = node.Connector |
| 30 | } |
| 31 | if node.SQL != "" { |
| 32 | r.MigrationSpec.Sql = strings.TrimSpace(node.SQL) |
| 33 | } |
| 34 | if tmp.MaxVersion > 0 { |
| 35 | r.MigrationSpec.Version = uint32(tmp.MaxVersion) |
| 36 | } |
| 37 | |
| 38 | return nil |
| 39 | } |
no test coverage detected