import json

from django.contrib.contenttypes.fields import GenericRelation
from django.db import models, connection


class TtJourney(models.Model):
    travel_table = models.ForeignKey("api.TtTravelTable", on_delete=models.CASCADE, null=True,related_name='journey')
    from_location = models.ForeignKey("api.TtLocation", on_delete=models.SET_NULL, null=True,related_name='from_location')
    to_location = models.ForeignKey("api.TtLocation", on_delete=models.SET_NULL, null=True,related_name='to_location')
    from_zone = models.ForeignKey("api.TtZone", on_delete=models.SET_NULL, null=True,related_name='from_zone')
    to_zone = models.ForeignKey("api.TtZone", on_delete=models.SET_NULL, null=True,related_name='to_zone')
    slot_required = models.IntegerField(default=0)
    created_by = models.BigIntegerField(null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_by = models.BigIntegerField(null=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = "tt_journey"