(app App, collection *Collection)
| 298 | } |
| 299 | |
| 300 | func dropCollectionIndexes(app App, collection *Collection) error { |
| 301 | if collection.IsView() { |
| 302 | return nil // views don't have indexes |
| 303 | } |
| 304 | |
| 305 | return app.RunInTransaction(func(txApp App) error { |
| 306 | for _, raw := range collection.Indexes { |
| 307 | parsed := dbutils.ParseIndex(raw) |
| 308 | |
| 309 | // note: don't check IsValid because the index table name may not be populated |
| 310 | // (https://github.com/pocketbase/pocketbase/issues/7689) |
| 311 | if parsed.IndexName == "" { |
| 312 | return fmt.Errorf("failed to dop index - missing index name: %s", raw) |
| 313 | } |
| 314 | |
| 315 | _, err := txApp.DB().NewQuery(fmt.Sprintf("DROP INDEX IF EXISTS [[%s]]", parsed.IndexName)).Execute() |
| 316 | if err != nil { |
| 317 | return err |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | return nil |
| 322 | }) |
| 323 | } |
| 324 | |
| 325 | func createCollectionIndexes(app App, collection *Collection) error { |
| 326 | if collection.IsView() { |
no test coverage detected
searching dependent graphs…