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("7her4515qsmrxe8") if err != nil { return err } json.Unmarshal([]byte(`[]`), &collection.Indexes) // remove collection.Schema.RemoveField("7vsr9h6p") // remove collection.Schema.RemoveField("wwpokofe") // add new_start := &schema.SchemaField{} json.Unmarshal([]byte(`{ "system": false, "id": "6hkjwgb4", "name": "start", "type": "date", "required": false, "presentable": false, "unique": false, "options": { "min": "", "max": "" } }`), new_start) collection.Schema.AddField(new_start) // add new_end := &schema.SchemaField{} json.Unmarshal([]byte(`{ "system": false, "id": "szbefpjf", "name": "end", "type": "date", "required": false, "presentable": false, "unique": false, "options": { "min": "", "max": "" } }`), new_end) collection.Schema.AddField(new_end) // add new_Compulsory := &schema.SchemaField{} json.Unmarshal([]byte(`{ "system": false, "id": "nlnnxu7x", "name": "Compulsory", "type": "text", "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": null, "pattern": "" } }`), new_Compulsory) collection.Schema.AddField(new_Compulsory) return dao.SaveCollection(collection) }, func(db dbx.Builder) error { dao := daos.New(db) collection, err := dao.FindCollectionByNameOrId("7her4515qsmrxe8") if err != nil { return err } json.Unmarshal([]byte(`[ "CREATE UNIQUE INDEX `+"`"+`idx_orp1NWL`+"`"+` ON `+"`"+`events`+"`"+` (\n `+"`"+`Day`+"`"+`,\n `+"`"+`Week`+"`"+`,\n `+"`"+`Start`+"`"+`,\n `+"`"+`End`+"`"+`,\n `+"`"+`Name`+"`"+`,\n `+"`"+`course`+"`"+`,\n `+"`"+`Prof`+"`"+`,\n `+"`"+`Rooms`+"`"+`,\n `+"`"+`EventType`+"`"+`\n)" ]`), &collection.Indexes) // add del_Start := &schema.SchemaField{} json.Unmarshal([]byte(`{ "system": false, "id": "7vsr9h6p", "name": "Start", "type": "text", "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": null, "pattern": "" } }`), del_Start) collection.Schema.AddField(del_Start) // add del_End := &schema.SchemaField{} json.Unmarshal([]byte(`{ "system": false, "id": "wwpokofe", "name": "End", "type": "text", "required": false, "presentable": false, "unique": false, "options": { "min": null, "max": null, "pattern": "" } }`), del_End) collection.Schema.AddField(del_End) // remove collection.Schema.RemoveField("6hkjwgb4") // remove collection.Schema.RemoveField("szbefpjf") // remove collection.Schema.RemoveField("nlnnxu7x") return dao.SaveCollection(collection) }) }