![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/private_html/migrations/ |
<?php
/**
* Migration: Add copyright protection features
*
* Adds:
* - audio_hash column for fingerprinting
* - copyright_hash column for combined proof
* - Creates dmca_reports table
*
* Run this migration once to add the columns.
*/
require_once __DIR__ . '/../config/database.php';
echo "Starting migration: add_copyright_protection\n";
echo "============================================\n\n";
try {
$pdo = getDBConnection();
if (!$pdo) {
throw new Exception("Failed to connect to database");
}
// Add audio_hash column
try {
$stmt = $pdo->query("SHOW COLUMNS FROM music_tracks LIKE 'audio_hash'");
$exists = $stmt->fetch();
if ($exists) {
echo "✓ Column 'audio_hash' already exists. Skipping.\n";
} else {
$pdo->exec("
ALTER TABLE music_tracks
ADD COLUMN audio_hash VARCHAR(64) NULL DEFAULT NULL
AFTER audio_url
");
echo "✓ Added 'audio_hash' column to music_tracks table.\n";
}
} catch (Exception $e) {
if (strpos($e->getMessage(), 'Duplicate column name') === false) {
throw $e;
}
echo "✓ Column 'audio_hash' already exists.\n";
}
// Add copyright_hash column (combined hash for certificate)
try {
$stmt = $pdo->query("SHOW COLUMNS FROM music_tracks LIKE 'copyright_hash'");
$exists = $stmt->fetch();
if ($exists) {
echo "✓ Column 'copyright_hash' already exists. Skipping.\n";
} else {
$pdo->exec("
ALTER TABLE music_tracks
ADD COLUMN copyright_hash VARCHAR(64) NULL DEFAULT NULL
AFTER audio_hash
");
echo "✓ Added 'copyright_hash' column to music_tracks table.\n";
}
} catch (Exception $e) {
if (strpos($e->getMessage(), 'Duplicate column name') === false) {
throw $e;
}
echo "✓ Column 'copyright_hash' already exists.\n";
}
// Create DMCA reports table
try {
$pdo->exec("
CREATE TABLE IF NOT EXISTS dmca_reports (
id INT AUTO_INCREMENT PRIMARY KEY,
track_id INT NOT NULL,
reporter_name VARCHAR(255) NOT NULL,
reporter_email VARCHAR(255) NOT NULL,
reporter_relationship ENUM('owner', 'authorized_agent', 'other') NOT NULL,
infringing_url TEXT NOT NULL,
description TEXT,
status ENUM('pending', 'reviewing', 'resolved', 'rejected') DEFAULT 'pending',
admin_notes TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (track_id) REFERENCES music_tracks(id) ON DELETE CASCADE,
INDEX idx_status (status),
INDEX idx_track_id (track_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
");
echo "✓ Created 'dmca_reports' table.\n";
} catch (Exception $e) {
if (strpos($e->getMessage(), 'already exists') !== false) {
echo "✓ Table 'dmca_reports' already exists.\n";
} else {
throw $e;
}
}
echo "\n✅ Migration completed successfully!\n";
} catch (Exception $e) {
echo "\n❌ Migration failed: " . $e->getMessage() . "\n";
exit(1);
}
?>