Open fr1t2 opened 1 day ago
Add user_emails table
CREATE TABLE user_emails (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
email VARCHAR(255) NOT NULL,
is_primary BOOLEAN DEFAULT FALSE,
is_valid BOOLEAN DEFAULT TRUE,
is_subscribed BOOLEAN DEFAULT FALSE, -- Opt-in for mailing lists
validation_token VARCHAR(255), -- Token for email validation process
validated_at DATETIME, -- Timestamp when the email was validated
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
UNIQUE KEY (user_id, email) -- Ensures each user cannot have duplicate email addresses
);
Remove from users tab
le
email VARCHAR(255),
Develop the final database layout to include all functions that we need to track.
Initial layout