gighiveThis document describes the two database (re)load mechanisms used by GigHive and how they differ.
GigHive currently supports two practical ways to wipe and repopulate the MySQL database with media data:
import_database.php, import_normalized.php)/docker-entrypoint-initdb.d/) (advanced)Both approaches ultimately load per-table CSVs into MySQL, but they differ in when they run, where data lives during load, and how much infrastructure is involved.
import_database.phpimport_normalized.phpadmin.php) provides a CSV upload control and triggers the import.database.csv).mysqlPrep_full.pysessions.csv, songs.csv, etc.) in a job directory.import_database.phpdatabase_csvThe uploaded source CSV must include a header row. The admin UI performs a preflight check before starting an import.
Minimum required headers:
t_title (sessions title)d_date (session date)d_merged_song_lists (songs source)f_singles (files source)import_normalized.phpsessions_csvsession_files_csvsessions.csvsession_keyt_titled_datesession_files.csvsession_keysource_relpathEach admin-triggered import creates a unique job directory under:
/var/www/private/import_jobs/<jobId>/This includes Section 3B imports, which stage the uploaded sessions.csv and session_files.csv into the same job directory before loading.
The uploaded CSV is saved as:
/var/www/private/import_jobs/<jobId>/database.csvThe preprocessing script writes generated per-table CSVs to:
/var/www/private/import_jobs/<jobId>/prepped_csvs/These paths are under /var/www/private/ and are not served publicly by Apache.
Example directory structure:
root@0f034bf13860:/var/www/private/import_jobs# ll
total 12
drwxr-xr-x 3 www-data www-data 4096 Dec 24 19:19 ./
drwxrwxr-x 1 www-data www-data 4096 Dec 24 19:19 ../
drwxr-xr-x 3 www-data www-data 4096 Dec 24 19:20 20251224-191954-377d73b02838/
root@0f034bf13860:/var/www/private/import_jobs# ll 20251224-191954-377d73b02838/
total 156
drwxr-xr-x 3 www-data www-data 4096 Dec 24 19:20 ./
drwxr-xr-x 3 www-data www-data 4096 Dec 24 19:19 ../
-rw-r--r-- 1 www-data www-data 4158 Dec 24 19:20 import_local.sql
drwxr-xr-x 2 www-data www-data 4096 Dec 24 19:19 prepped_csvs/
-rw-r--r-- 1 www-data www-data 92908 Dec 24 19:19 session_files.csv
-rw-r--r-- 1 www-data www-data 41127 Dec 24 19:19 sessions.csv
root@0f034bf13860:/var/www/private/import_jobs# ll 20251224-191954-377d73b02838/prepped_csvs/
total 212
drwxr-xr-x 2 www-data www-data 4096 Dec 24 19:19 ./
drwxr-xr-x 3 www-data www-data 4096 Dec 24 19:20 ../
-rw-r--r-- 1 www-data www-data 122888 Dec 24 19:19 files.csv
-rw-r--r-- 1 www-data www-data 437 Dec 24 19:19 musicians.csv
-rw-r--r-- 1 www-data www-data 4801 Dec 24 19:19 session_musicians.csv
-rw-r--r-- 1 www-data www-data 6170 Dec 24 19:19 session_songs.csv
-rw-r--r-- 1 www-data www-data 24818 Dec 24 19:19 sessions.csv
-rw-r--r-- 1 www-data www-data 5692 Dec 24 19:19 song_files.csv
-rw-r--r-- 1 www-data www-data 20756 Dec 24 19:19 songs.csv
files.source_relpath population behaviorGigHive stores an optional files.source_relpath value for traceability back to the original folder structure.
f_singles (e.g. set1/20021024_3.mp3), those relative paths are persisted to files.source_relpath.files.source_relpath will effectively match the basename.webkitRelativePath) relative to the selected folder. These are written into f_singles and persisted to files.source_relpath.UploadService.php):
files.checksum_sha256 and stores the file on disk as {sha256}.{ext} under /audio/ or /video/.files.source_relpath for provenance (e.g. stormpigs20251222_00001_fountain.mp4).{sha256}.{ext} while the UI can still display the canonical name.LOAD DATA LOCAL INFILE ...This relies on two independent settings:
local_infile=ON--local-infile=1 (client defaults often show local-infile FALSE)With LOCAL INFILE, the CSV files do not need to be mounted into the MySQL container. The mysql client streams the file contents over the connection.
The runtime import will:
clear_media.php).genres and styles (matching the seed behavior in 01-load_and_transform.sql).python3 + pandas (for preprocessing)mysql client (recommended for predictable LOAD DATA LOCAL INFILE execution)| Aspect | MySQL initialization load (advanced) | Admin-triggered runtime import (Option A) |
|---|---|---|
| Trigger | MySQL entrypoint on fresh datadir | Admin action in web UI |
| Best for | First install / provisioning | Ongoing admin reloads |
| Data file location | Must be readable by MySQL server (/var/lib/mysql-files/) |
Can remain on Apache container; streamed via LOCAL |
| Load statement | LOAD DATA INFILE |
LOAD DATA LOCAL INFILE |
| Requires shared mount into MySQL | Typically yes | No |
Requires local_infile |
No | Yes (server ON + client --local-infile=1) |
LOAD DATA INFILE working does not imply local_infile is enabled. local_infile is only relevant to LOAD DATA LOCAL INFILE.mysql:8.0 image, mysqld reads includes from:
/etc/my.cnf and !includedir /etc/mysql/conf.d/
Mount custom config files into /etc/mysql/conf.d/ to ensure settings like local-infile=1 are applied.admin.php now includes a folder scan/import section titled:
Choose a Folder to Scan & Update the Database
This section includes:
<input type="file" webkitdirectory ...>)import_database.phpd_date.t_titled_dated_merged_song_listsf_singlesimport_database.php as database.csv (same upload field name database_csv).webkitdirectory) and the FileList it provides.
mp3, wav, aac, flac, m4a, mp4, mov, mkv, webm, avid_date.d_date are grouped into a single session.d_date derivation order:
YYYY-MM-DDYYYYMMDD19xx or 20xx) mapped to YYYY-01-01lastModified timestamp1970-01-01import_database.php using the database_csv form field (same endpoint/field as Section 3A).webkitdirectory support (Chrome / Chromium / Edge).mp3, wav, aac, flac, m4a, mp4, mov, mkv, webm, aviusers table is preserved./admin.phpFiles selected: XSupported media files: YSessions detected: ZsupportedCount > 0 and sessions.length > 0./db/database.phpimport_database.phpYYYY-MM-DD or YYYYMMDD, verify that date shows up as a session).Section 5 is intended for building a long-term media library without wiping existing data.
import_manifest_add.phporg_nameevent_typeitems (array)Each item includes:
file_namesource_relpathfile_typeevent_datesize_byteschecksum_sha256/docker-entrypoint-initdb.d/00-create_music_db.sql/docker-entrypoint-initdb.d/01-load_and_transform.sql/var/lib/mysqlIf the MySQL container is restarted with an already-initialized datadir, the /docker-entrypoint-initdb.d/ scripts are typically not re-run.
LOAD DATA INFILE '/var/lib/mysql-files/<table>.csv' ...secure_file_priv permitting /var/lib/mysql-files/