![]() 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/.cursor-server/data/User/History/503f27a2/ |
<?php
require_once 'config/database.php';
$pdo = getDBConnection();
// Tables to check and create
$tables = [
'track_likes' => "
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
)
",
'track_comments' => "
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
)
",
'track_shares' => "
CREATE TABLE IF NOT EXISTS track_shares (
id INT AUTO_INCREMENT PRIMARY KEY,
track_id INT NOT NULL,
user_id INT NULL,
share_type VARCHAR(50) DEFAULT 'social',
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
)
",
'track_views' => "
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),
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
)
",
'track_plays' => "
CREATE TABLE IF NOT EXISTS track_plays (
id INT AUTO_INCREMENT PRIMARY KEY,
track_id INT NOT NULL,
user_id INT 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 SET NULL
)
",
'user_follows' => "
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 "Checking and creating social tables...\n";
foreach ($tables as $table_name => $sql) {
try {
$pdo->exec($sql);
echo "✅ Table '$table_name' is ready\n";
} catch (Exception $e) {
echo "❌ Error creating table '$table_name': " . $e->getMessage() . "\n";
}
}
echo "\nSocial tables setup complete!\n";
?>