-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Model Collection SchemaVersions and migrations on Collections
- Loading branch information
1 parent
8ebb8fd
commit 2909d8e
Showing
56 changed files
with
2,139 additions
and
1,156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2023 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package cli | ||
|
||
import ( | ||
"encoding/json" | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/lens-vm/lens/host-go/config/model" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func MakeSchemaMigrationSetRegistryCommand() *cobra.Command { | ||
var cmd = &cobra.Command{ | ||
Use: "set-registry [collectionID] [cfg]", | ||
Short: "Set a schema migration within the DefraDB LensRegistry", | ||
Long: `Set a migration to a collection within the LensRegistry of the local DefraDB node. | ||
Does not persist the migration after restart. | ||
Example: set from an argument string: | ||
defradb client schema migration set-registry 2 '{"lenses": [...' | ||
Learn more about the DefraDB GraphQL Schema Language on https://docs.source.network.`, | ||
Args: cobra.ExactArgs(2), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
store := mustGetStoreContext(cmd) | ||
|
||
decoder := json.NewDecoder(strings.NewReader(args[1])) | ||
decoder.DisallowUnknownFields() | ||
|
||
var lensCfg model.Lens | ||
if err := decoder.Decode(&lensCfg); err != nil { | ||
return NewErrInvalidLensConfig(err) | ||
} | ||
|
||
collectionID, err := strconv.ParseUint(args[0], 10, 64) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return store.LensRegistry().SetMigration(cmd.Context(), uint32(collectionID), lensCfg) | ||
}, | ||
} | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.