gitea-migrator/migrator/models.py

36 lines
883 B
Python
Raw Normal View History

2020-08-03 22:05:16 +02:00
from django.db import models
from enum import IntEnum
import uuid
class Migration(models.Model):
id = models.UUIDField(
primary_key = True,
default = uuid.uuid4,
editable = False
)
username = models.CharField(max_length=200)
gitlab_token = models.CharField(max_length=200)
gitea_token = models.CharField(max_length=200)
class Status(IntEnum):
PENDING = 1
IN_PROGRESS = 5
SUCCESS = 2
EXISTS = 3
ERROR = 4
class Repository(models.Model):
migration = models.ForeignKey(
Migration,
on_delete = models.CASCADE,
related_name = "repositories",
)
path_with_namespace = models.CharField(max_length=200)
result = models.PositiveIntegerField(
choices=[(tag, tag.value) for tag in Status],
default = Status.PENDING
)
error_message = models.TextField(default="")