updated WIP:v0.9.0 changelog
This commit is contained in:
@@ -95,10 +95,10 @@ func Register(app core.App, rootCmd *cobra.Command, options *Options) error {
|
||||
|
||||
func (p *plugin) createCommand() *cobra.Command {
|
||||
const cmdDesc = `Supported arguments are:
|
||||
- up - runs all available migrations
|
||||
- down [number] - reverts the last [number] applied migrations
|
||||
- create name [folder] - creates new blank migration template file
|
||||
- collections [folder] - creates new migration file with the latest local collections snapshot (similar to the automigrate but allows editing)
|
||||
- up - runs all available migrations
|
||||
- down [number] - reverts the last [number] applied migrations
|
||||
- create name - creates new blank migration template file
|
||||
- collections - creates new migration file with snapshot of the local collections configuration
|
||||
`
|
||||
|
||||
command := &cobra.Command{
|
||||
@@ -143,14 +143,7 @@ func (p *plugin) migrateCreateHandler(template string, args []string) error {
|
||||
}
|
||||
|
||||
name := args[0]
|
||||
|
||||
var dir string
|
||||
if len(args) == 2 {
|
||||
dir = args[1]
|
||||
}
|
||||
if dir == "" {
|
||||
dir = p.options.Dir
|
||||
}
|
||||
dir := p.options.Dir
|
||||
|
||||
resultFilePath := path.Join(
|
||||
dir,
|
||||
|
||||
@@ -164,7 +164,7 @@ func init() {
|
||||
|
||||
expectedName := "_created_new_name." + s.lang
|
||||
if !strings.Contains(files[0].Name(), expectedName) {
|
||||
t.Fatalf("Expected filename to contains %q, got %q", expectedName, files[0].Name())
|
||||
t.Fatalf("[%d] Expected filename to contains %q, got %q", i, expectedName, files[0].Name())
|
||||
}
|
||||
|
||||
fullPath := filepath.Join(migrationsDir, files[0].Name())
|
||||
@@ -335,7 +335,7 @@ func init() {
|
||||
|
||||
expectedName := "_deleted_test456." + s.lang
|
||||
if !strings.Contains(files[0].Name(), expectedName) {
|
||||
t.Fatalf("Expected filename to contains %q, got %q", expectedName, files[0].Name())
|
||||
t.Fatalf("[%d] Expected filename to contains %q, got %q", i, expectedName, files[0].Name())
|
||||
}
|
||||
|
||||
fullPath := filepath.Join(migrationsDir, files[0].Name())
|
||||
@@ -681,7 +681,7 @@ func init() {
|
||||
|
||||
expectedName := "_updated_test456." + s.lang
|
||||
if !strings.Contains(files[0].Name(), expectedName) {
|
||||
t.Fatalf("Expected filename to contains %q, got %q", expectedName, files[0].Name())
|
||||
t.Fatalf("[%d] Expected filename to contains %q, got %q", i, expectedName, files[0].Name())
|
||||
}
|
||||
|
||||
fullPath := filepath.Join(migrationsDir, files[0].Name())
|
||||
|
||||
@@ -648,27 +648,29 @@ func (p *plugin) goDiffTemplate(new *models.Collection, old *models.Collection)
|
||||
|
||||
up := strings.Join(upParts, "\n\t\t")
|
||||
down := strings.Join(downParts, "\n\t\t")
|
||||
|
||||
var optImports string
|
||||
|
||||
combined := up + down
|
||||
|
||||
// generate imports
|
||||
// ---
|
||||
var imports string
|
||||
|
||||
if strings.Contains(combined, "json.Unmarshal(") ||
|
||||
strings.Contains(combined, "json.Marshal(") {
|
||||
optImports += "\n\t\"encoding/json\"\n"
|
||||
imports += "\n\t\"encoding/json\"\n"
|
||||
}
|
||||
|
||||
optImports += "\n\t\"github.com/pocketbase/dbx\""
|
||||
optImports += "\n\t\"github.com/pocketbase/pocketbase/daos\""
|
||||
optImports += "\n\tm \"github.com/pocketbase/pocketbase/migrations\""
|
||||
imports += "\n\t\"github.com/pocketbase/dbx\""
|
||||
imports += "\n\t\"github.com/pocketbase/pocketbase/daos\""
|
||||
imports += "\n\tm \"github.com/pocketbase/pocketbase/migrations\""
|
||||
|
||||
if strings.Contains(combined, "schema.SchemaField{") {
|
||||
optImports += "\n\t\"github.com/pocketbase/pocketbase/models/schema\""
|
||||
imports += "\n\t\"github.com/pocketbase/pocketbase/models/schema\""
|
||||
}
|
||||
|
||||
if strings.Contains(combined, "types.Pointer(") {
|
||||
optImports += "\n\t\"github.com/pocketbase/pocketbase/tools/types\""
|
||||
imports += "\n\t\"github.com/pocketbase/pocketbase/tools/types\""
|
||||
}
|
||||
// ---
|
||||
|
||||
const template = `package %s
|
||||
|
||||
@@ -705,7 +707,7 @@ func init() {
|
||||
return fmt.Sprintf(
|
||||
template,
|
||||
filepath.Base(p.options.Dir),
|
||||
optImports,
|
||||
imports,
|
||||
old.Id, strings.TrimSpace(up),
|
||||
new.Id, strings.TrimSpace(down),
|
||||
), nil
|
||||
|
||||
Reference in New Issue
Block a user