2017-09-18 21:42:29 +08:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
2020-01-21 17:29:54 +08:00
|
|
|
class Classification(models.Model):
|
|
|
|
code = models.CharField(max_length=10)
|
|
|
|
|
|
|
|
|
2017-09-18 21:42:29 +08:00
|
|
|
class Employee(models.Model):
|
|
|
|
name = models.CharField(max_length=40, blank=False, null=False)
|
|
|
|
salary = models.PositiveIntegerField()
|
|
|
|
department = models.CharField(max_length=40, blank=False, null=False)
|
|
|
|
hire_date = models.DateField(blank=False, null=False)
|
2018-07-26 07:45:32 +08:00
|
|
|
age = models.IntegerField(blank=False, null=False)
|
2020-01-21 17:29:54 +08:00
|
|
|
classification = models.ForeignKey(
|
|
|
|
"Classification", on_delete=models.CASCADE, null=True
|
|
|
|
)
|
2020-09-22 21:01:52 +08:00
|
|
|
bonus = models.DecimalField(decimal_places=2, max_digits=15, null=True)
|
2020-10-14 18:21:25 +08:00
|
|
|
|
|
|
|
|
2022-08-10 20:22:01 +08:00
|
|
|
class PastEmployeeDepartment(models.Model):
|
|
|
|
employee = models.ForeignKey(
|
|
|
|
Employee, related_name="past_departments", on_delete=models.CASCADE
|
|
|
|
)
|
|
|
|
department = models.CharField(max_length=40, blank=False, null=False)
|
|
|
|
|
|
|
|
|
2020-10-14 18:21:25 +08:00
|
|
|
class Detail(models.Model):
|
|
|
|
value = models.JSONField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
required_db_features = {"supports_json_field"}
|