- Add newsletter database table migration - Create newsletter controller with subscribe/unsubscribe endpoints - Add newsletter routes and validation - Implement newsletter service with email validation - Add setup documentation and migration scripts - Include test page for newsletter functionality 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
27 lines
1013 B
SQL
27 lines
1013 B
SQL
-- ============================================
|
|
-- MIGRATION: Add Newsletter Table
|
|
-- ============================================
|
|
|
|
-- Create newsletters table
|
|
CREATE TABLE IF NOT EXISTS newsletters (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
email VARCHAR(255) UNIQUE NOT NULL,
|
|
is_active BOOLEAN DEFAULT TRUE,
|
|
subscribed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
unsubscribed_at TIMESTAMP,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Create indexes for better performance
|
|
CREATE INDEX idx_newsletters_email ON newsletters(email);
|
|
CREATE INDEX idx_newsletters_is_active ON newsletters(is_active);
|
|
|
|
-- Add trigger for updated_at
|
|
CREATE TRIGGER update_newsletters_updated_at BEFORE UPDATE ON newsletters
|
|
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
|
|
|
-- Add comment
|
|
COMMENT ON TABLE newsletters IS 'Table des abonnements à la newsletter';
|
|
COMMENT ON COLUMN newsletters.is_active IS 'TRUE si abonné, FALSE si désabonné';
|