MCPcopy Index your code
hub / github.com/rilldata/rill / parseMigration

Method parseMigration

runtime/parser/parse_migration.go:13–39  ·  view source on GitHub ↗

parseMigration parses a migration definition and adds the resulting resource to p.Resources.

(node *Node)

Source from the content-addressed store, hash-verified

11
12// parseMigration parses a migration definition and adds the resulting resource to p.Resources.
13func (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}

Callers 1

parseNodeMethod · 0.95

Calls 2

decodeNodeYAMLMethod · 0.95
insertResourceMethod · 0.95

Tested by

no test coverage detected