Skip to main content

Django数据库迁移优化(目前只完善MySQL)

Project description

Django数据库迁移优化(目前只完善MySQL)

主要功能

  • 支持写入表注释及字段注释

  • 支持写入字段默认值

  • 常用字段数据模型基类 django_kelove_db.abstract_models

使用示例

  • 修改django配置文件 ENGINE 为 django_kelove_db.backends.mysql

  • 配置 INCLUDE_DEFAULT (可选),示例如下

DATABASES = {
    'default': {
        'ENGINE': 'django_kelove_db.backends.mysql',
        'NAME': 'django_kelove',
        'USER': 'django_kelove',
        'PASSWORD': 'django_kelove',
        'HOST': '127.0.0.1',
        'PORT': 3306,
        'INCLUDE_DEFAULT': lambda model, field, include_default, connection: False if field.db_parameters(
            connection=connection
        )['type'] in ['longtext', 'longblob'] else True
    }
}

KELOVE_DATABASES = {
    'FOREIGN_DELETE_TYPE': 'django.db.models.deletion.PROTECT',
    'DB_CONSTRAINT': False,
    'DB_CONSTRAINT_USER': False,
    'STATUS_CHOICES': [(-1, '草稿'), (0, '待审'), (1, '通过'), (2, '驳回')],
    'DOC_TITLE': '数据库设计文档'
}

  • 使用数据库文档功能时,需要将应用添加到 INSTALLED_APPS ,并添加路由
INSTALLED_APPS = [
    ...
    'django_kelove_db.apps.DjangoKeloveDbConfig',
    ...
]

from django.conf.urls import url
from django.urls import include

urlpatterns = [
    ...
    url(r'doc/', include('django_kelove_db.urls')),
    ...
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-kelove-db-3.0.0.tar.gz (540.8 kB view details)

Uploaded Source

File details

Details for the file django-kelove-db-3.0.0.tar.gz.

File metadata

  • Download URL: django-kelove-db-3.0.0.tar.gz
  • Upload date:
  • Size: 540.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.5.2

File hashes

Hashes for django-kelove-db-3.0.0.tar.gz
Algorithm Hash digest
SHA256 dd7cce431b08941702379d53cf60757100160a14b58aaf7dc21c8ea3cf631ec9
MD5 028f69234fd80b21af2d06a7aae197b1
BLAKE2b-256 a0abd3946bc5669ae5cae65b0b9524b9c14b327bcc3c88224dbfc8a70f272242

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page