mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-10 16:00:36 -07:00
chore: initial public commit
This commit is contained in:
commit
fc9054b78c
250 changed files with 32809 additions and 0 deletions
26
internal/repository/etc.sql.go
Normal file
26
internal/repository/etc.sql.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue