MCPcopy
hub / github.com/pocketbase/pocketbase / dropCollectionIndexes

Function dropCollectionIndexes

core/collection_record_table_sync.go:300–323  ·  view source on GitHub ↗
(app App, collection *Collection)

Source from the content-addressed store, hash-verified

298}
299
300func 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
325func createCollectionIndexes(app App, collection *Collection) error {
326 if collection.IsView() {

Callers 1

SyncRecordTableSchemaMethod · 0.85

Calls 6

ParseIndexFunction · 0.92
IsViewMethod · 0.80
ExecuteMethod · 0.80
NewQueryMethod · 0.80
RunInTransactionMethod · 0.65
DBMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…