-
-
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.
- Loading branch information
Christian Beutel
committed
Feb 4, 2025
1 parent
3ab5911
commit a0b6480
Showing
32 changed files
with
1,737 additions
and
57 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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": "iz4sezoehde64wp", | ||
"created": "2025-02-02 12:12:48.256Z", | ||
"updated": "2025-02-02 12:12:48.256Z", | ||
"name": "integrations", | ||
"type": "base", | ||
"system": false, | ||
"schema": [ | ||
{ | ||
"system": false, | ||
"id": "yhqqdtrf", | ||
"name": "strava", | ||
"type": "json", | ||
"required": false, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"maxSize": 2000000 | ||
} | ||
}, | ||
{ | ||
"system": false, | ||
"id": "bmktyzqz", | ||
"name": "user", | ||
"type": "relation", | ||
"required": true, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"collectionId": "_pb_users_auth_", | ||
"cascadeDelete": true, | ||
"minSelect": null, | ||
"maxSelect": 1, | ||
"displayFields": null | ||
} | ||
} | ||
], | ||
"indexes": [], | ||
"listRule": "@request.auth.id = user.id", | ||
"viewRule": "@request.auth.id = user.id", | ||
"createRule": "@request.auth.id = user.id", | ||
"updateRule": "@request.auth.id = user.id", | ||
"deleteRule": "@request.auth.id = user.id", | ||
"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("iz4sezoehde64wp") | ||
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,41 @@ | ||
package migrations | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/pocketbase/dbx" | ||
"github.com/pocketbase/pocketbase/daos" | ||
m "github.com/pocketbase/pocketbase/migrations" | ||
) | ||
|
||
func init() { | ||
m.Register(func(db dbx.Builder) error { | ||
dao := daos.New(db); | ||
|
||
collection, err := dao.FindCollectionByNameOrId("iz4sezoehde64wp") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := json.Unmarshal([]byte(`[ | ||
"CREATE UNIQUE INDEX ` + "`" + `idx_qMhw0Em` + "`" + ` ON ` + "`" + `integrations` + "`" + ` (` + "`" + `user` + "`" + `)" | ||
]`), &collection.Indexes); err != nil { | ||
return err | ||
} | ||
|
||
return dao.SaveCollection(collection) | ||
}, func(db dbx.Builder) error { | ||
dao := daos.New(db); | ||
|
||
collection, err := dao.FindCollectionByNameOrId("iz4sezoehde64wp") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := json.Unmarshal([]byte(`[]`), &collection.Indexes); err != nil { | ||
return err | ||
} | ||
|
||
return dao.SaveCollection(collection) | ||
}) | ||
} |
Oops, something went wrong.