from django.db import models

# Create your models here.

class Notificationtype(models.Model):
    type = models.CharField(max_length = 50)


    def __str__(self):
        return self.type


    class Meta:
        db_table = 'notificationtype'


class notifications(models.Model):
    notification_type = models.ForeignKey('Notificationtype',on_delete=models.CASCADE)
    sender_id = models.BigIntegerField()
    read_at = models.DateTimeField(null = True,blank = True)
    data = models.JSONField(null = True,blank = True)


    def __str__(self):
        return self.type

    class Meta:
        db_table = 'notifications'


class NotificationReceiver(models.Model):
    notification = models.ForeignKey(notifications, on_delete=models.CASCADE)
    user_id = models.BigIntegerField()

    def __str__(self):
        return f"Notification to user {self.user_id}"

    class Meta:
        db_table = 'notificationreceiver'

   
