Adds indexes for the queries that scanned a whole table. The feeds page dumps by created_at, and a user's dumps and upvotes by (user_id, created_at), which replace the indexes on user_id alone. Dumps and playlists are looked up by slug. Each foreign key with ON DELETE gets an index on its child column, which SQLite otherwise scans on every delete of a parent row, and the followers of a user or playlist are read on every new dump. Mentions look usernames up by lower(username).

Functions

f
up(db: DatabaseSync): void

Run once by runMigrations. A database made from schema.sql already has these indexes.

Usage

import * as mod from "api/db/migrations/0016_performance_indexes.ts";