CREATE INDEX IF NOT EXISTS idx_crowdin ON "integration_credentials" ("crowdin_id");

CREATE INDEX IF NOT EXISTS idx_integration_provider ON "sync_settings" ("integration_id","provider");
CREATE INDEX IF NOT EXISTS idx_crowdin ON "sync_settings" ("crowdin_id");
CREATE INDEX IF NOT EXISTS idx_type ON "sync_settings" ("type");

CREATE INDEX IF NOT EXISTS idx_integration ON "files_snapshot" ("integration_id");
CREATE INDEX IF NOT EXISTS idx_crowdin ON "files_snapshot" ("crowdin_id");

CREATE INDEX IF NOT EXISTS idx_integration_crowdin ON "webhooks" ("integration_id","crowdin_id");
CREATE INDEX IF NOT EXISTS idx_file_provider ON "webhooks" ("file_id","provider");

CREATE INDEX IF NOT EXISTS idx_integration_crowdin ON "user_errors" ("integration_id","crowdin_id");
CREATE INDEX IF NOT EXISTS idx_crowdin ON "user_errors" ("crowdin_id");
CREATE INDEX IF NOT EXISTS idx_created_at ON "user_errors" ("created_at");

CREATE INDEX IF NOT EXISTS idx_integration ON "integration_settings" ("integration_id");
CREATE INDEX IF NOT EXISTS idx_crowdin ON "integration_settings" ("crowdin_id");

CREATE INDEX IF NOT EXISTS idx_integration_crowdin ON "job" ("integration_id","crowdin_id") WHERE "finished_at" IS NULL;
CREATE INDEX IF NOT EXISTS idx_finished_at ON "job" ("finished_at") WHERE "finished_at" IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_status ON "job" ("status") WHERE "finished_at" IS NULL;

CREATE INDEX IF NOT EXISTS idx_integration_crowdin_file_language ON "translation_file_cache" ("integration_id","crowdin_id","file_id","language_id");
CREATE INDEX IF NOT EXISTS idx_crowdin ON "translation_file_cache" ("crowdin_id");

CREATE INDEX IF NOT EXISTS idx_integration_crowdin ON "unsynced_files" ("integration_id","crowdin_id");
CREATE INDEX IF NOT EXISTS idx_crowdin ON "unsynced_files" ("crowdin_id");