class MacType(models.Model): type_id = models.SmallAutoField(primary_key=True) type_name = models.CharField(max_length=60) type_en = models.CharField(max_length=60) type_sort = models.PositiveSmallIntegerField() type_mid = models.PositiveSmallIntegerField() type_pid = models.PositiveSmallIntegerField() type_status = models.PositiveIntegerField() type_tpl = models.CharField(max_length=30) type_tpl_list = models.CharField(max_length=30) type_tpl_detail = models.CharField(max_length=30) type_tpl_play = models.CharField(max_length=30) type_tpl_down = models.CharField(max_length=30) type_key = models.CharField(max_length=255) type_des = models.CharField(max_length=255) type_title = models.CharField(max_length=255) type_union = models.CharField(max_length=255) type_extend = models.TextField(blank=True, null=True) type_logo = models.CharField(max_length=255) type_pic = models.CharField(max_length=255) type_jumpurl = models.CharField(max_length=150) class Meta: managed = False db_table = 'mac_type'
class Department(models.Model): dept_id = models.SmallAutoField(primary_key=True) name = models.CharField(max_length=20) class Meta: managed = True db_table = 'department'
class Store(models.Model, ModelSerializationMixin): """ CREATE TABLE store ( store_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, manager_staff_id TINYINT UNSIGNED NOT NULL, address_id SMALLINT UNSIGNED NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (store_id), UNIQUE KEY idx_unique_manager (manager_staff_id), KEY idx_fk_address_id (address_id), CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT fk_store_address FOREIGN KEY (address_id) REFERENCES address (address_id) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; # Django会自动为所有 models.ForeignKey 列创建索引 """ store_id = models.SmallAutoField(primary_key=True) city = models.CharField(max_length=50) manager_staff = models.OneToOneField( Staff, on_delete=models.RESTRICT, related_name="manager", verbose_name="店长" ) address = models.ForeignKey(Address, on_delete=models.RESTRICT) last_update = models.DateTimeField(auto_now=True) class Meta: verbose_name = "电影店表" verbose_name_plural = verbose_name db_table = "store"
class Actor(models.Model, ModelSerializationMixin): """ CREATE TABLE actor ( actor_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (actor_id), KEY idx_actor_last_name (last_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; # 单独使用KEY, 跟使用INDEX没区别 """ actor_id = models.SmallAutoField(primary_key=True) first_name = models.CharField(max_length=45) last_name = models.CharField(max_length=45) last_update = models.DateTimeField(auto_now=True) class Meta: verbose_name = "演员表" verbose_name_plural = verbose_name db_table = "actor" # https://docs.djangoproject.com/en/3.1/ref/models/options/#django.db.models.Options.indexes # https://blog.csdn.net/qq_37049050/article/details/80749381 indexes = [models.Index(fields=['last_name'], name='idx_actor_last_name')]
class ReportType(models.Model): RTid = models.SmallAutoField(primary_key=True) RTname = models.CharField(max_length=32, unique=True) RTdescription = models.CharField(max_length=256) def __str__(self): return self.RTname + ' : ' + self.RTdescription
class QuestionType(models.Model): QTid = models.SmallAutoField(primary_key=True) QTname = models.CharField(max_length=32) QTdescription = models.CharField(max_length=256) def __str__(self): return self.QTname + ' : ' + self.QTdescription
class Resolutions(models.Model): resolution_id = models.SmallAutoField( primary_key=True, validators=[MinValueValidator(0), MaxValueValidator(8)]) resolution = models.CharField(max_length=32) objects = models.Manager()
class LobbyType(models.Model): LTid = models.SmallAutoField(primary_key=True) LTname = models.CharField(max_length=32) LTdescription = models.CharField(max_length=1000) def __str__(self): return self.LTdescription
class Priorities(models.Model): priority_id = models.SmallAutoField( primary_key=True, validators=[MinValueValidator(0), MaxValueValidator(8)]) priority = models.CharField(max_length=16) objects = models.Manager()
class ReportTypes(models.Model): report_type_id = models.SmallAutoField( primary_key=True, validators=[MinValueValidator(0), MaxValueValidator(8)]) report_type = models.CharField(max_length=32) objects = models.Manager()
class SrcDst(models.Model): id = models.SmallAutoField(primary_key=True) prober = models.ForeignKey(Prober, models.DO_NOTHING) dst = models.GenericIPAddressField(protocol='IPv4') class Meta: db_table = 'src_dst'
class Address(models.Model, ModelSerializationMixin): """ CREATE TABLE address ( address_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, address VARCHAR(50) NOT NULL, address2 VARCHAR(50) DEFAULT NULL, district VARCHAR(20) NOT NULL, city_id SMALLINT UNSIGNED NOT NULL, postal_code VARCHAR(10) DEFAULT NULL, phone VARCHAR(20) NOT NULL, -- Add GEOMETRY column for MySQL 5.7.5 and higher -- Also include SRID attribute for MySQL 8.0.3 and higher /*!50705 location GEOMETRY */ /*!80003 SRID 0 */ /*!50705 NOT NULL,*/ last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (address_id), KEY idx_fk_city_id (city_id), /*!50705 SPATIAL KEY `idx_location` (location),*/ CONSTRAINT `fk_address_city` FOREIGN KEY (city_id) REFERENCES city (city_id) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; # Django会自动为所有 models.ForeignKey 列创建索引 """ address_id = models.SmallAutoField(primary_key=True) address = models.CharField(max_length=50) address2 = models.CharField(max_length=50, null=True, default=None) district = models.CharField(max_length=20) city = models.ForeignKey(City, on_delete=models.RESTRICT) postal_code = models.CharField(max_length=10) phone = models.CharField(max_length=20) last_update = models.DateTimeField(auto_now=True) class Meta: verbose_name = "地址表" verbose_name_plural = verbose_name db_table = "address"
class EnvaseSubtipo(models.Model): cod_envasesub = models.SmallAutoField( db_column='COD_ENVASESUB', primary_key=True) # Field name made lowercase. cod_tipoenv = models.ForeignKey('TipoEnvase', models.DO_NOTHING, db_column='COD_TIPOENV', blank=True, null=True) # Field name made lowercase. nom_envasesub = models.CharField( db_column='NOM_ENVASESUB', max_length=50) # Field name made lowercase. vol_envasesub = models.FloatField( db_column='VOL_ENVASESUB') # Field name made lowercase. uvo_envasesub = models.FloatField( db_column='UVO_ENVASESUB') # Field name made lowercase. cos_envasesub = models.FloatField(db_column='COS_ENVASESUB', blank=True, null=True) # Field name made lowercase. est_envasesub = models.SmallIntegerField( db_column='EST_ENVASESUB', choices=ESTADOS_EN_SISTEMA, blank=False, null=False) # Field name made lowercase. class Meta: managed = True db_table = 'envase_subtipo' def __str__(self): return self.nom_envasesub
class Person(models.Model): f41 = models.SmallAutoField(db_column='F41', primary_key=True) # Field name made lowercase. zlabel = models.CharField(db_column='ZLabel', max_length=100) # Field name made lowercase. f13 = models.CharField(db_column='F13', max_length=20) # Field name made lowercase. f15 = models.ForeignKey( Ort, models.DO_NOTHING, db_column='F15', related_name='birthplace') # Field name made lowercase. f14 = models.CharField(db_column='F14', max_length=20) # Field name made lowercase. f16 = models.CharField(db_column='F16', max_length=120) # Field name made lowercase. f24 = models.CharField(db_column='F24', max_length=1) # Field name made lowercase. kommentar = models.TextField( db_column='Kommentar') # Field name made lowercase. f17 = models.ForeignKey( Ort, models.DO_NOTHING, db_column='F17', blank=True, null=True, related_name='place_of_death') # Field name made lowercase. class Meta: managed = False db_table = 'person' def __str__(self): return str(self.zlabel)
class BanType(models.Model): id = models.SmallAutoField(primary_key=True) ban_type = models.CharField(max_length=20, blank=True, null=True) class Meta: managed = False db_table = 'ban_type'
class Diagnoza(models.Model): iddiagnoza = models.SmallAutoField(db_column='idDiagnoza', primary_key=True) # Field name made lowercase. id_rodzaj_incydentu = models.ForeignKey(RodzajIncydentu, models.DO_NOTHING, db_column='id_rodzaj_incydentu', blank=True, null=True) opis = models.TextField(blank=True, null=True) class Meta: db_table = 'diagnoza'
class Model(models.Model): id = models.SmallAutoField(primary_key=True) model = models.CharField(max_length=100, blank=True, null=True) class Meta: managed = False db_table = 'model'
class UniqueDetails(models.Model): id = models.SmallAutoField(primary_key=True) unique_details = models.CharField(max_length=32, blank=True, null=True) class Meta: managed = False db_table = 'unique_details'
class FuelType(models.Model): id = models.SmallAutoField(primary_key=True) fuel_type = models.CharField(max_length=10, blank=True, null=True) class Meta: managed = False db_table = 'fuel_type'
class Gearbox(models.Model): id = models.SmallAutoField(primary_key=True) gearbox = models.CharField(max_length=20, blank=True, null=True) class Meta: managed = False db_table = 'gearbox'
class Currency(models.Model): id = models.SmallAutoField(primary_key=True) currency = models.CharField(max_length=5, blank=True, null=True) class Meta: managed = False db_table = 'currency'
class Color(models.Model): id = models.SmallAutoField(primary_key=True) color = models.CharField(max_length=15, blank=True, null=True) class Meta: managed = False db_table = 'color'
class SprDetailOptions(models.Model): id = models.SmallAutoField(primary_key=True) name = models.CharField(max_length=255) icon = models.CharField(max_length=255, blank=True, null=True) class Meta: managed = False db_table = 'spr_detail_options'
class Country(models.Model): country_id = models.SmallAutoField(primary_key=True) country = models.CharField(max_length=50) last_update = models.DateTimeField() class Meta: managed = False db_table = 'country'
class Pasien(models.Model): """docstring for Pasien""" kat_pasien = models.SmallAutoField( primary_key=True) umur = models.CharField(max_length=10) jenis_kelamin = models.CharField(max_length=10) def __str__(self): return '%s %s' % (self.umur, self.jenis_kelamin)
class Indeks(models.Model): kode = models.SmallAutoField(primary_key=True) kode_pkm = models.ForeignKey(Puskesmas, on_delete=models.CASCADE) tanggal = models.DateField() deleted = models.SmallIntegerField() def __str__(self): return str(self.tanggal)
class Resource(models.Model): id = models.SmallAutoField(primary_key=True) name = models.CharField(max_length=255) status = models.IntegerField() class Meta: managed = False db_table = 'resource'
class Pasien(SoftDeleteModel): """docstring for Pasien""" kat_pasien = models.SmallAutoField(primary_key=True) umur = models.CharField(max_length=10) jenis_kelamin = models.CharField(max_length=10) def __str__(self): return str(self.kat_pasien)
class EditComponent(models.Model): component_id = models.SmallAutoField(primary_key=True) component_name = models.CharField(max_length=255) confirmation_point_level = models.PositiveIntegerField() class Meta: managed = True db_table = 'edit_component'
class RodzajIncydentu(models.Model): idrodzaj_incydentu = models.SmallAutoField(db_column='idRodzaj_incydentu', primary_key=True) # Field name made lowercase. nazwa = models.CharField(max_length=300, blank=True, null=True) def __str__(self): return self.nazwa class Meta: db_table = 'rodzaj_incydentu'