-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cascade delete summit logs & waypoints
- Loading branch information
Christian Beutel
committed
Feb 16, 2025
1 parent
b1f1ae6
commit c2f848d
Showing
2 changed files
with
152 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package migrations | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/pocketbase/dbx" | ||
"github.com/pocketbase/pocketbase/daos" | ||
m "github.com/pocketbase/pocketbase/migrations" | ||
"github.com/pocketbase/pocketbase/models/schema" | ||
) | ||
|
||
func init() { | ||
m.Register(func(db dbx.Builder) error { | ||
dao := daos.New(db); | ||
|
||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// update | ||
edit_author := &schema.SchemaField{} | ||
if err := json.Unmarshal([]byte(`{ | ||
"system": false, | ||
"id": "r0mj3tkr", | ||
"name": "author", | ||
"type": "relation", | ||
"required": true, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"collectionId": "_pb_users_auth_", | ||
"cascadeDelete": true, | ||
"minSelect": null, | ||
"maxSelect": 1, | ||
"displayFields": null | ||
} | ||
}`), edit_author); err != nil { | ||
return err | ||
} | ||
collection.Schema.AddField(edit_author) | ||
|
||
return dao.SaveCollection(collection) | ||
}, func(db dbx.Builder) error { | ||
dao := daos.New(db); | ||
|
||
collection, err := dao.FindCollectionByNameOrId("dd2l9a4vxpy2ni8") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// update | ||
edit_author := &schema.SchemaField{} | ||
if err := json.Unmarshal([]byte(`{ | ||
"system": false, | ||
"id": "r0mj3tkr", | ||
"name": "author", | ||
"type": "relation", | ||
"required": true, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"collectionId": "_pb_users_auth_", | ||
"cascadeDelete": false, | ||
"minSelect": null, | ||
"maxSelect": 1, | ||
"displayFields": null | ||
} | ||
}`), edit_author); err != nil { | ||
return err | ||
} | ||
collection.Schema.AddField(edit_author) | ||
|
||
return dao.SaveCollection(collection) | ||
}) | ||
} |
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,76 @@ | ||
package migrations | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/pocketbase/dbx" | ||
"github.com/pocketbase/pocketbase/daos" | ||
m "github.com/pocketbase/pocketbase/migrations" | ||
"github.com/pocketbase/pocketbase/models/schema" | ||
) | ||
|
||
func init() { | ||
m.Register(func(db dbx.Builder) error { | ||
dao := daos.New(db); | ||
|
||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// update | ||
edit_author := &schema.SchemaField{} | ||
if err := json.Unmarshal([]byte(`{ | ||
"system": false, | ||
"id": "8qbxrsd8", | ||
"name": "author", | ||
"type": "relation", | ||
"required": true, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"collectionId": "_pb_users_auth_", | ||
"cascadeDelete": true, | ||
"minSelect": null, | ||
"maxSelect": 1, | ||
"displayFields": null | ||
} | ||
}`), edit_author); err != nil { | ||
return err | ||
} | ||
collection.Schema.AddField(edit_author) | ||
|
||
return dao.SaveCollection(collection) | ||
}, func(db dbx.Builder) error { | ||
dao := daos.New(db); | ||
|
||
collection, err := dao.FindCollectionByNameOrId("goeo2ubp103rzp9") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// update | ||
edit_author := &schema.SchemaField{} | ||
if err := json.Unmarshal([]byte(`{ | ||
"system": false, | ||
"id": "8qbxrsd8", | ||
"name": "author", | ||
"type": "relation", | ||
"required": true, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"collectionId": "_pb_users_auth_", | ||
"cascadeDelete": false, | ||
"minSelect": null, | ||
"maxSelect": 1, | ||
"displayFields": null | ||
} | ||
}`), edit_author); err != nil { | ||
return err | ||
} | ||
collection.Schema.AddField(edit_author) | ||
|
||
return dao.SaveCollection(collection) | ||
}) | ||
} |