Database Reference

TagStack uses MySQL 8.0+ as its backend store for the media library, playlists, broadcast logs, server configurations, clock templates, and schema version tracking. The database is named mcaster1_tagstack and is created automatically if it does not exist.

Requirements

Schema Initialization

TagStack applies the database schema automatically. No manual SQL execution is required.

  1. Launch TagStack and navigate to Settings → Database.
  2. Click Initialize Schema. TagStack creates the mcaster1_tagstack database if it does not exist and runs all pending migration files in order.
  3. The status label shows the current schema version (e.g. v6 for a fully up-to-date installation).
  4. Each migration file is tracked in the migration_history table. Files already applied are skipped — running Initialize Schema again is safe.

Upgrading: Use Settings → Database → Migration Wizard to see which migration files are pending. The wizard shows each file name, its applied status, and lets you apply them selectively or all at once.

Migration Files

The schema is built by six cumulative SQL migration files stored in the sql/ folder:

FileVersionWhat It Creates
001_init.sqlv1schema_version, media_items (core), playlists (core), playlist_entries (core), migration_history
002_servers.sqlv2servers table (server configs, credentials, poll interval)
003_media_weight.sqlv3Adds weight column to media_items for rotation scheduling
004_media_extended.sqlv4Adds BPM, key, MBID, ISRC, label, mood, MusicBrainz rating to media_items
005_composer_tables.sqlv5categories, broadcast_logs, log_items, clock_templates, clock_slots, cart_mappings
006_playlist_extended.sqlv6Adds broadcast automation rules to playlists; adds extended metadata + TV channel fields to playlist_entries

Table Reference

media_items

The core music library. One row per unique audio file path.

ColumnTypeDescription
idBIGINT PK AIAuto-increment primary key
file_pathVARCHAR(1024) UNIQUEFull absolute path to the audio file
titleVARCHAR(512)Track title from ID3/tag
artistVARCHAR(512)Artist name
albumVARCHAR(512)Album name
genreVARCHAR(256)Genre tag
formatVARCHAR(16)File extension (mp3, flac, wav, etc.)
yearINTRelease year (0 = unknown)
duration_secINTTrack duration in seconds
file_sizeBIGINTFile size in bytes
is_streamTINYINT1 if this is an ICY stream URL, 0 for local file
track_numberSMALLINTTrack number on the album
bpmSMALLINTBeats per minute (0 = unknown)
track_keyVARCHAR(12)Musical key (e.g. "8A", "C#m")
weightFLOATRotation scheduling weight (default 1.0)
mbidVARCHAR(36)MusicBrainz Recording ID (UUID)
isrcVARCHAR(12)International Standard Recording Code
labelVARCHAR(120)Record label from MusicBrainz
moodVARCHAR(60)Mood tag from MusicBrainz folksonomy
mb_ratingSMALLINTMusicBrainz community rating (0–100)
mb_lookup_doneTINYINT(1)1 if MusicBrainz lookup has been completed for this track
added_atDATETIMETimestamp when the record was first inserted

playlists

Named playlists with optional broadcast automation rules.

ColumnTypeDescription
idBIGINT PK AIAuto-increment primary key
nameVARCHAR(512) NOT NULLPlaylist name
descriptionTEXTOptional long description or notes
rule_artist_sepINT DEFAULT 0Min seconds before same artist repeats (0 = off)
rule_title_sepINT DEFAULT 0Min seconds before same title repeats (0 = off)
rule_genre_mixVARCHAR(1024)JSON: target genre percentages, e.g. {"Rock":60,"Pop":40}
rule_bpm_minINT DEFAULT 0Minimum BPM filter (0 = no minimum)
rule_bpm_maxINT DEFAULT 0Maximum BPM filter (0 = no maximum)
rule_energy_modeTINYINT DEFAULT 00 = flat, 1 = ramp up, 2 = ramp down
created_atDATETIMECreation timestamp
modified_atDATETIMELast modification timestamp (auto-updated)

playlist_entries

Individual tracks within a playlist, ordered by sort_order. Supports audio files, audio streams, internet TV, terrestrial TV, jingles, and break markers via the item_type field.

ColumnTypeDescription
idBIGINT PK AIAuto-increment primary key
playlist_idBIGINT NOT NULLParent playlist ID (references playlists.id in app code)
media_idBIGINTmedia_items.id if this is a library track (NULL for streams/TV)
sort_orderINT NOT NULLPosition within the playlist (1-based)
item_typeVARCHAR(32)music | audio_stream | tv_internet | tv_terrestrial | jingle | break
file_pathVARCHAR(1024)Full path for local files
titleVARCHAR(512)Track or segment title (cached)
artistVARCHAR(512)Artist name (cached)
albumVARCHAR(512)Album name (cached)
genreVARCHAR(256)Genre (cached)
formatVARCHAR(32)File extension (mp3, flac, etc.)
yearINTRelease year
bpmINTBeats per minute
track_keyVARCHAR(32)Musical key
weightFLOATRotation weight (copied from media_items)
duration_secINT DEFAULT -1Duration in seconds (-1 = unknown)
channel_urlVARCHAR(2048)Stream or IPTV URL (for internet TV and audio streams)
channel_numberVARCHAR(16)RF or cable channel number (for terrestrial TV)
channel_nameVARCHAR(256)Display name for TV channels and internet streams

servers

Streaming server configurations.

ColumnTypeDescription
idINT PK AIAuto-increment primary key
nameVARCHAR(255) UNIQUEFriendly server name
server_typeVARCHAR(64)mcaster1dnas or icecast2
urlVARCHAR(512)Server URL (e.g. https://dnas.example.com:9443)
admin_userVARCHAR(128)Admin username for ICY 1.x metadata push and mount listing
admin_passwordVARCHAR(512)Admin password
source_passwordVARCHAR(512)Source password for ICY 2.2 PUT and live stream push
stream_idVARCHAR(64)Optional stream identifier
verify_sslTINYINT(1)1 = verify SSL certificate; 0 = skip (for self-signed certs)
poll_intervalINTStats polling interval in seconds (default 5)
created_atTIMESTAMPRow creation timestamp
updated_atTIMESTAMPLast update timestamp (auto-updated)

categories

Rotation categories for ComposerPro. Each category is a named bucket with a color badge.

ColumnTypeDescription
idINT PK AIAuto-increment primary key
nameVARCHAR(60) UNIQUECategory name (e.g. "Top 40 Hot", "Gold", "Spots")
color_hexVARCHAR(7)CSS hex color for the badge (default #0ea5e9)

broadcast_logs

Broadcast log headers created in ComposerPro.

ColumnTypeDescription
idINT PK AIAuto-increment primary key
nameVARCHAR(120) NOT NULLLog name (e.g. "Morning Drive 2026-03-01")
log_dateDATEScheduled broadcast date
notesTEXTFree-text notes for the operator
created_atDATETIMECreation timestamp
updated_atDATETIMELast save timestamp (auto-updated)

log_items

Individual items within a broadcast log, ordered by position.

ColumnTypeDescription
idINT PK AIAuto-increment primary key
log_idINT NOT NULLParent broadcast_logs.id
positionSMALLINT NOT NULLOrder within the log (1-based)
media_idINTmedia_items.id (NULL for spots, jingles without library entries)
cart_numberVARCHAR(20)Cart number for SAM Broadcaster / Rivendell export
item_typeTINYINT0=Music, 1=Spot, 2=Jingle, 3=News, 4=Filler, 5=Voice
start_timeTIMEScheduled start time (HH:MM:SS)
duration_secSMALLINTDuration in seconds
notesVARCHAR(200)Operator notes for this item

clock_templates and clock_slots

Clock templates define repeating hour structures for auto-populating broadcast logs.

TableColumnDescription
clock_templatesid, name, notesTemplate header with unique name
clock_slotstemplate_idParent template ID
clock_slotsslot_indexOrder of this slot within the template (0-based)
clock_slotsitem_typeSame type codes as log_items (0–5)
clock_slotscategory_idWhich rotation category to pull from (categories.id)
clock_slotsduration_secTarget slot duration in seconds (default 210 = 3:30)

cart_mappings

Lookup table mapping cart numbers to media library items.

ColumnTypeDescription
cart_numberVARCHAR(20) PKCart number string (e.g. "C001", "SPOT-042")
media_idINTmedia_items.id this cart maps to

schema_version and migration_history

TablePurpose
schema_versionStores the highest applied schema version number with a description. TagStack checks this to determine the current state.
migration_historyTracks each migration SQL file by filename. Used to skip already-applied files on subsequent Initialize Schema calls. Prevents duplicate execution.

Backup and Restore

Database Backup

  1. Navigate to Settings → Database.
  2. Click Backup Database. The Database Backup dialog opens.
  3. Choose a destination folder and filename for the backup file (.sql).
  4. Click Start Backup. TagStack runs mysqldump as a child process, capturing its output to the selected file.
  5. The backup includes all tables in mcaster1_tagstack: media library, playlists, servers, logs, templates, and mappings.

Restore

To restore from a backup, use the MySQL command line or MySQL Workbench to import the .sql file into your mcaster1_tagstack database:

mysql -u root -p mcaster1_tagstack < backup_2026-03-01.sql

After restore, run Initialize Schema in TagStack to ensure any pending migrations are applied (this is safe — already-applied migrations are skipped).

Performance Notes