-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bf4ac2
commit f83f6bc
Showing
5 changed files
with
137 additions
and
120 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
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" | ||
) | ||
|
||
func init() { | ||
m.Register(func(db dbx.Builder) error { | ||
jsonData := `{ | ||
"id": "n1io46jj22k6dfx", | ||
"created": "2024-11-01 12:50:34.056Z", | ||
"updated": "2024-11-01 12:50:34.056Z", | ||
"name": "notes", | ||
"type": "base", | ||
"system": false, | ||
"schema": [ | ||
{ | ||
"system": false, | ||
"id": "svp5iioh", | ||
"name": "title", | ||
"type": "text", | ||
"required": false, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"min": null, | ||
"max": null, | ||
"pattern": "" | ||
} | ||
}, | ||
{ | ||
"system": false, | ||
"id": "ndrlbmqo", | ||
"name": "content", | ||
"type": "text", | ||
"required": false, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"min": null, | ||
"max": null, | ||
"pattern": "" | ||
} | ||
} | ||
], | ||
"indexes": [], | ||
"listRule": null, | ||
"viewRule": null, | ||
"createRule": null, | ||
"updateRule": null, | ||
"deleteRule": null, | ||
"options": {} | ||
}` | ||
|
||
collection := &models.Collection{} | ||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil { | ||
return err | ||
} | ||
|
||
return daos.New(db).SaveCollection(collection) | ||
}, func(db dbx.Builder) error { | ||
dao := daos.New(db); | ||
|
||
collection, err := dao.FindCollectionByNameOrId("n1io46jj22k6dfx") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return dao.DeleteCollection(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,50 @@ | ||
package migrations | ||
|
||
import ( | ||
"github.com/pocketbase/dbx" | ||
"github.com/pocketbase/pocketbase/daos" | ||
m "github.com/pocketbase/pocketbase/migrations" | ||
"github.com/pocketbase/pocketbase/tools/types" | ||
) | ||
|
||
func init() { | ||
m.Register(func(db dbx.Builder) error { | ||
dao := daos.New(db); | ||
|
||
collection, err := dao.FindCollectionByNameOrId("n1io46jj22k6dfx") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
collection.ListRule = types.Pointer("") | ||
|
||
collection.ViewRule = types.Pointer("") | ||
|
||
collection.CreateRule = types.Pointer("") | ||
|
||
collection.UpdateRule = types.Pointer("") | ||
|
||
collection.DeleteRule = types.Pointer("") | ||
|
||
return dao.SaveCollection(collection) | ||
}, func(db dbx.Builder) error { | ||
dao := daos.New(db); | ||
|
||
collection, err := dao.FindCollectionByNameOrId("n1io46jj22k6dfx") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
collection.ListRule = nil | ||
|
||
collection.ViewRule = nil | ||
|
||
collection.CreateRule = nil | ||
|
||
collection.UpdateRule = nil | ||
|
||
collection.DeleteRule = nil | ||
|
||
return dao.SaveCollection(collection) | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.