36318-vm/db/migrations/004_create_post_votes_table.sql
Flatlogic Bot 5274c73966 Base app
2025-11-26 13:53:30 +00:00

11 lines
415 B
SQL

CREATE TABLE IF NOT EXISTS post_votes (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
post_id INT NOT NULL,
vote_type ENUM('like', 'dislike') NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY user_post_vote (user_id, post_id),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (post_id) REFERENCES posts(id) ON DELETE CASCADE
);