// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.30.0
// source: etc.sql

package repository

import (
	"context"
)

const cleanOrphanedEntries = `-- name: CleanOrphanedEntries :exec
DO $$
BEGIN
  DELETE FROM tracks WHERE id NOT IN (SELECT l.track_id FROM listens l);
  DELETE FROM releases WHERE id NOT IN (SELECT t.release_id FROM tracks t);
  DELETE FROM artists WHERE id NOT IN (SELECT at.artist_id FROM artist_tracks at);
END $$
`

// DELETE FROM releases WHERE release_group_id NOT IN (SELECT t.release_group_id FROM tracks t);
// DELETE FROM releases WHERE release_group_id NOT IN (SELECT rg.id FROM release_groups rg);
func (q *Queries) CleanOrphanedEntries(ctx context.Context) error {
	_, err := q.db.Exec(ctx, cleanOrphanedEntries)
	return err
}
