from django.db import models

# Create your models here.
class Customer(models.Model):
    firstname = models.CharField(max_length=100)
    lastname = models.CharField(max_length=100)
    email = models.EmailField(max_length=100)
    telephone = models.CharField(max_length=13)
    address = models.TextField()
    classes = models.ForeignKey(
        'Class',
        on_delete=models.CASCADE
    )
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    def __str__(self):
        return self.firstname + " " + self.lastname

class Class(models.Model):
    name = models.CharField(max_length=100)
    price = models.IntegerField()
    description = models.TextField()
    def __str__(self):
        return self.name

from django.conf import settings
from django.db import models
from django.contrib.auth.models import AbstractUser

# custom user that extend from django auth user
class User(AbstractUser):
    """customer information v1"""
    firstname = models.CharField(max_length=100)
    lastname = models.CharField(max_length=100)
    telephone = models.CharField(max_length=13)
    address = models.TextField()
    date_of_birth = models.DateField()
    updated_at = models.DateTimeField(auto_now=True)
    def __str__(self):
        return self.firstname + " " + self.lastname

# merge django auth user to customer
class Customer(models.Model):
    """customer information v1"""
    user = models.OneToOneField(
        settings.AUTH_USER_MODEL,
        on_delete=models.CASCADE
    )
    classes = models.ForeignKey(
        'Class',
        on_delete=models.CASCADE
    )
    def __str__(self):
        return self.firstname + " " + self.lastname

class Class(models.Model):
    """membership class v1"""
    name = models.CharField(max_length=100)
    price = models.IntegerField()
    description = models.TextField()
    def __str__(self):
        return self.name

migrate user and customer