drag and drop enhancements, fixed playlist creation using old db entries, added icons-only sidebar when small width

This commit is contained in:
2026-02-21 14:16:37 -05:00
parent 8ad952e750
commit 9d84a11543
4 changed files with 392 additions and 69 deletions
+29
View File
@@ -52,6 +52,17 @@ func NewDB(logger *slog.Logger) (*DB, error) {
db.SetMaxOpenConns(1) // SQLite only supports one writer at a time
// Enable foreign key enforcement — SQLite disables it by
// default, which means ON DELETE CASCADE will not work without
// this pragma.
if _, err := db.ExecContext(
dbCtx, "PRAGMA foreign_keys = ON",
); err != nil {
return nil, fmt.Errorf(
"could not enable foreign keys: %w", err,
)
}
// Execute SQL files from the embedded schemas directory
logger.Debug("reading sql schema files from embedded directory")
@@ -86,6 +97,24 @@ func NewDB(logger *slog.Logger) (*DB, error) {
}
}
// Remove orphaned playlist_tracks left behind by past deletes
// that ran without foreign key enforcement.
orphanResult, err := db.ExecContext(
dbCtx,
"DELETE FROM playlist_tracks WHERE playlist_id NOT IN (SELECT id FROM playlists)",
)
if err != nil {
logger.Warn(
"could not clean orphaned playlist tracks",
"err", err,
)
} else if n, _ := orphanResult.RowsAffected(); n > 0 {
logger.Info(
"Cleaned orphaned playlist tracks",
"deleted", n,
)
}
// Get generated queries
queries := sqlcgen.New(db)