from app.extensions import db 
from datetime import datetime, timezone

# Create a model for managing NGO campaigns and fundraising events
class Campaign(db.Model):
    # Set the actual table name in the database
    __tablename__='campaigns'
    
    # Primary Key: Unique ID for every campaign
    id = db.Column(db.Integer, primary_key = True)

    # Campaign title and detailed description
    title = db.Column(db.String(150), nullable= False)
    description = db.Column(db.Text, nullable=False)


    # Financial goals for the campaign
    target_amount = db.Column(db.Float, nullable = False)
    raised_amount = db.Column(db.Float, default=0.0)


    # Campaign status (e.g., 'Active', 'Completed', 'Upcoming')
    status = db.Column(db.String(50), default='Active')


    # Automatically log when the campaign was created
    created_at = db.Column(db.DateTime, default=lambda: datetime.now(timezone.utc))