from django.db import models

from domini.models import *

class SqlServer(models.Model):
  id = models.IntegerField(db_column='id',primary_key=True)
  nome = models.CharField(db_column='nome',max_length=32)
  server = models.CharField(db_column='server',max_length=32)
  adminuser =  models.CharField(db_column='adminuser',max_length=32)
  adminpass =  models.CharField(db_column='adminpass',max_length=32)
  enabled = models.BooleanField(db_column='enabled',default=1)
  nota = models.TextField(db_column='nota',default='')
  class Meta:
    ordering = ['id']
    db_table = 'sql_server'
    managed  = False
    
class SqlDatabase(models.Model):
  id = models.IntegerField(db_column='id',primary_key=True)
  nome = models.CharField(db_column='nome',max_length=64)
  dominio = models.ForeignKey('domini.Domini',db_column='dominio',on_delete=models.PROTECT)
  server = models.ForeignKey('SqlServer',db_column='server',on_delete=models.PROTECT)
  username = models.CharField(db_column='username',max_length=32)
  password = models.CharField(db_column='password',max_length=32)
  password_last_update = models.DateTimeField(db_column='password_last_update')
  enabled = models.BooleanField(db_column='enabled',default=1)
  locked = models.BooleanField(db_column='locked',default=0)
  tobedeleted= models.BooleanField(db_column='tobedeleted',default=0)
  quota = models.IntegerField(db_column='quota',default=0)
  aggiornamento = models.DateTimeField(db_column='aggiornamento',max_length=20)
  creazione = models.DateTimeField(db_column='creazione')
  nota = models.TextField(db_column='nota',default='')
  mail = models.TextField(db_column='mail',max_length=128)
  inbackup = models.BooleanField(db_column='inbackup',default=False)
  datebackup = models.DateTimeField(db_column='datebackup')
  allowexternal = models.BooleanField(db_column='AllowExternal',default=False)
  class Meta:
    ordering = ['id']
    db_table = 'sql_database'
    managed  = False
