![]() 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/public_html/ |
<?php
require_once 'config/database.php';
echo "<h1>Creating Missing Social Feature Tables</h1>";
try {
$pdo = getDBConnection();
// Track likes table
$pdo->exec("
CREATE TABLE IF NOT EXISTS track_likes (
id INT AUTO_INCREMENT PRIMARY KEY,
track_id INT NOT NULL,
user_id INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY unique_like (track_id, user_id),
FOREIGN KEY (track_id) REFERENCES music_tracks(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
)
");
echo "<p>✅ Created track_likes table</p>";
// Track comments table
$pdo->exec("
CREATE TABLE IF NOT EXISTS track_comments (
id INT AUTO_INCREMENT PRIMARY KEY,
track_id INT NOT NULL,
user_id INT NOT NULL,
comment TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (track_id) REFERENCES music_tracks(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
)
");
echo "<p>✅ Created track_comments table</p>";
// Track shares table
$pdo->exec("
CREATE TABLE IF NOT EXISTS track_shares (
id INT AUTO_INCREMENT PRIMARY KEY,
track_id INT NOT NULL,
user_id INT NOT NULL,
platform VARCHAR(50) DEFAULT 'direct',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (track_id) REFERENCES music_tracks(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
)
");
echo "<p>✅ Created track_shares table</p>";
// Track plays table
$pdo->exec("
CREATE TABLE IF NOT EXISTS track_plays (
id INT AUTO_INCREMENT PRIMARY KEY,
track_id INT NOT NULL,
user_id INT NULL,
ip_address VARCHAR(45),
user_agent TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (track_id) REFERENCES music_tracks(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL
)
");
echo "<p>✅ Created track_plays table</p>";
// Track views table
$pdo->exec("
CREATE TABLE IF NOT EXISTS track_views (
id INT AUTO_INCREMENT PRIMARY KEY,
track_id INT NOT NULL,
user_id INT NULL,
ip_address VARCHAR(45),
user_agent TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (track_id) REFERENCES music_tracks(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL
)
");
echo "<p>✅ Created track_views table</p>";
// Track votes table (for upvote/downvote functionality)
$pdo->exec("
CREATE TABLE IF NOT EXISTS track_votes (
id INT AUTO_INCREMENT PRIMARY KEY,
track_id INT NOT NULL,
user_id INT NOT NULL,
vote_type ENUM('up', 'down') NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY unique_vote (track_id, user_id),
FOREIGN KEY (track_id) REFERENCES music_tracks(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_track_votes_track (track_id),
INDEX idx_track_votes_user (user_id)
)
");
echo "<p>✅ Created track_votes table</p>";
// User follows table
$pdo->exec("
CREATE TABLE IF NOT EXISTS user_follows (
id INT AUTO_INCREMENT PRIMARY KEY,
follower_id INT NOT NULL,
following_id INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY unique_follow (follower_id, following_id),
FOREIGN KEY (follower_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (following_id) REFERENCES users(id) ON DELETE CASCADE
)
");
echo "<p>✅ Created user_follows table</p>";
echo "<h2>✅ ALL SOCIAL FEATURE TABLES CREATED SUCCESSFULLY!</h2>";
echo "<p>Now test community.php again - it should work!</p>";
} catch (Exception $e) {
echo "<p>❌ ERROR: " . $e->getMessage() . "</p>";
}
?>