From d8a04f8f5f825c3dd98bd99ea2d7764cb9039696 Mon Sep 17 00:00:00 2001 From: Piotr Rogowski Date: Mon, 20 Nov 2023 12:22:55 +0100 Subject: [PATCH] Fix auto migrations --- migrations/1700477408_created_iniFiles.go | 9 +++++++++ migrations/1700477408_created_stargazers.go | 9 +++++++++ migrations/1700477408_created_tunes.go | 9 +++++++++ migrations/1700477408_updated_users.go | 2 +- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/migrations/1700477408_created_iniFiles.go b/migrations/1700477408_created_iniFiles.go index a115a92..09d2fd5 100644 --- a/migrations/1700477408_created_iniFiles.go +++ b/migrations/1700477408_created_iniFiles.go @@ -2,6 +2,7 @@ package migrations import ( "encoding/json" + "fmt" "github.com/pocketbase/dbx" "github.com/pocketbase/pocketbase/daos" @@ -11,6 +12,14 @@ import ( func init() { m.Register(func(db dbx.Builder) error { + dao := daos.New(db); + _, err := dao.FindCollectionByNameOrId("9eif9v40b0uw9l8") + + if err == nil { + fmt.Println("collection iniFiles already exists") + return nil + } + jsonData := `{ "id": "9eif9v40b0uw9l8", "created": "2023-11-20 10:50:08.919Z", diff --git a/migrations/1700477408_created_stargazers.go b/migrations/1700477408_created_stargazers.go index 734c117..adbe870 100644 --- a/migrations/1700477408_created_stargazers.go +++ b/migrations/1700477408_created_stargazers.go @@ -2,6 +2,7 @@ package migrations import ( "encoding/json" + "fmt" "github.com/pocketbase/dbx" "github.com/pocketbase/pocketbase/daos" @@ -11,6 +12,14 @@ import ( func init() { m.Register(func(db dbx.Builder) error { + dao := daos.New(db); + _, err := dao.FindCollectionByNameOrId("9eif9v40b0uw9l8") + + if err == nil { + fmt.Println("collection stargazers already exists") + return nil + } + jsonData := `{ "id": "z8cojwcvlyxxyll", "created": "2023-11-20 10:50:08.921Z", diff --git a/migrations/1700477408_created_tunes.go b/migrations/1700477408_created_tunes.go index 3671420..932740d 100644 --- a/migrations/1700477408_created_tunes.go +++ b/migrations/1700477408_created_tunes.go @@ -2,6 +2,7 @@ package migrations import ( "encoding/json" + "fmt" "github.com/pocketbase/dbx" "github.com/pocketbase/pocketbase/daos" @@ -11,6 +12,14 @@ import ( func init() { m.Register(func(db dbx.Builder) error { + dao := daos.New(db); + _, err := dao.FindCollectionByNameOrId("9eif9v40b0uw9l8") + + if err == nil { + fmt.Println("collection tunes already exists") + return nil + } + jsonData := `{ "id": "5djmpehuiigg06b", "created": "2023-11-20 10:50:08.921Z", diff --git a/migrations/1700477408_updated_users.go b/migrations/1700477408_updated_users.go index 0bb890d..dd6a1c2 100644 --- a/migrations/1700477408_updated_users.go +++ b/migrations/1700477408_updated_users.go @@ -14,7 +14,7 @@ func init() { m.Register(func(db dbx.Builder) error { dao := daos.New(db); - collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_") + collection, err := dao.FindCollectionByNameOrId("users") if err != nil { return err }