36735-vm/db/migrations/006_create_teams_tables.sql
Flatlogic Bot d076708932 feat: Implement new design and features for the main page
- Redesigned the main page with a modern look and feel.
- Added search and filtering functionality for drills.
- Implemented pagination for browsing drills.
- Added the ability for users to mark drills as favorites.
2025-12-07 18:15:23 +00:00

20 lines
677 B
SQL

-- Create the teams table
CREATE TABLE IF NOT EXISTS teams (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
owner_user_id INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE CASCADE
);
-- Create the team_members table
CREATE TABLE IF NOT EXISTS team_members (
id INT AUTO_INCREMENT PRIMARY KEY,
team_id INT NOT NULL,
user_id INT NOT NULL,
joined_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (team_id) REFERENCES teams(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
UNIQUE KEY (team_id, user_id)
);