from datetime import datetime
from sqlalchemy.dialects.postgresql import UUID
import uuid

import Models
from app import db


class ClickModel(Models.Base):
    __tablename__ = 'clicks'

    id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    location = db.Column(db.String, nullable=False, default="app")
    ref = db.Column(db.String, nullable=False, default="None")
    time = db.Column(db.DateTime, nullable=False, default=datetime.utcnow())

    def __init__(self, **kwargs):
        self.time = datetime.utcnow()
        super().__init__(**kwargs)
