models.py 1.63 KB
from django.db import models

# Create your models here.
class Item(models.Model):
    item_id = models.AutoField(primary_key = True)
    is_folder = models.BooleanField(default = False)
    name = models.CharField(max_length = 50)
    file_type = models.CharField(max_length=100, null=True) # signed_url 생성을 위해 file type 세팅
    path = models.TextField()
    #parent = models.ForeignKey('Item', on_delete=models.CASCADE, null=True) #related_name
    parent = models.IntegerField(null=True) # root 폴더의 경우 null임
    user_id = models.IntegerField()
    size = models.IntegerField()
    is_deleted = models.BooleanField(default = False)
    created_time = models.DateTimeField(auto_now=True)
    updated_time = models.DateTimeField(null=True)
    status = models.BooleanField()

    #file = models.FileField(upload_to = \path)
    
    class Meta:
        ordering = ['item_id']


class SharedItem(models.Model):
    item_id = models.IntegerField()
    #file_id?
    expires = models.DateTimeField()
    password = models.CharField(max_length = 20)
    created_time = models.DateTimeField(auto_now=True)
    class Meta:
        ordering = ['item_id']


class User(models.Model):
    int_id = models.AutoField(primary_key = True)
    user_id = models.CharField(max_length = 50)
    name = models.CharField(max_length = 50)
    password = models.CharField(max_length = 20)
    root_folder = models.IntegerField(null=True)
    total_size = models.IntegerField()
    current_size = models.IntegerField()
    created_time = models.DateTimeField(auto_now=True)
    class Meta:
        ordering = ['int_id']