# pxy_de/pipelines/models.py
import uuid
from django.db import models

class PipelineStep(models.Model):
    name = models.CharField(max_length=100)
    description = models.TextField(blank=True, null=True)

    def __str__(self):
        return self.name

class PipelineRun(models.Model):
    run_identifier = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
    overall_status = models.CharField(max_length=20, blank=True, null=True)
    date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return str(self.run_identifier)

class PipelineProductRun(models.Model):
    pipeline_run = models.ForeignKey(PipelineRun, on_delete=models.CASCADE, related_name='product_runs')
    step = models.ForeignKey(PipelineStep, on_delete=models.CASCADE)
    status = models.CharField(max_length=10)
    date = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.pipeline_run.run_identifier} - {self.step.name}"



