-- Migration: Create newsletter_subscribers table for megido72-portal.com
-- Description: Manage newsletter subscriptions (5 fields, 2 indexes)

CREATE TABLE IF NOT EXISTS newsletter_subscribers (
  id SERIAL PRIMARY KEY,
  email VARCHAR(255) NOT NULL UNIQUE,
  subscribed_at TIMESTAMP DEFAULT NOW(),
  is_active BOOLEAN DEFAULT true,
  unsubscribed_at TIMESTAMP
);

-- Create indexes for faster lookups
CREATE INDEX idx_newsletter_email ON newsletter_subscribers(email);
CREATE INDEX idx_newsletter_active ON newsletter_subscribers(is_active) WHERE is_active = true;

-- Comment for documentation
COMMENT ON TABLE newsletter_subscribers IS 'Newsletter subscribers table for megido72-portal.com';
