当前位置: 首页 > 软件库 > 数据库相关 > >

django-migration-linter

授权协议 Apache-2.0 License
开发语言 C/C++
所属分类 数据库相关
软件类型 开源软件
地区 不详
投 递 者 丁阳羽
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Django migration linter

Detect backward incompatible migrations for your Django project.It will save you time by making sure migrations will not break with a older codebase.

Quick installation

pip install django-migration-linter

And add the migration linter your INSTALLED_APPS:

    INSTALLED_APPS = [
        ...,
        "django_migration_linter",
        ...,
    ]

Usage example

$ python manage.py lintmigrations

(app_add_not_null_column, 0001_create_table)... OK
(app_add_not_null_column, 0002_add_new_not_null_field)... ERR
        NOT NULL constraint on columns
(app_drop_table, 0001_initial)... OK
(app_drop_table, 0002_delete_a)... ERR
        DROPPING table
(app_ignore_migration, 0001_initial)... OK
(app_ignore_migration, 0002_ignore_migration)... IGNORE
(app_rename_table, 0001_initial)... OK
(app_rename_table, 0002_auto_20190414_1500)... ERR
        RENAMING tables

*** Summary ***
Valid migrations: 4/8
Erroneous migrations: 3/8
Migrations with warnings: 0/8
Ignored migrations: 1/8

The linter analysed all migrations from the Django project.It found 3 migrations that are doing backward incompatible operations and 1 that is explicitly ignored.The list of incompatibilities that the linter analyses can be found at docs/incompatibilities.md.

More advanced usages of the linter and options can be found at docs/usage.md.

Integration

One can either integrate the linter in the CI and the lintmigrations command, or detect incompatibilities during generation with

$ python manage.py makemigrations --lint

Migrations for 'app_correct':
  tests/test_project/app_correct/migrations/0003_a_column.py
    - Add field column to a
Linting for 'app_correct':
(app_correct, 0003_a_column)... ERR
        NOT NULL constraint on columns

The migration linter detected that this migration is not be backward compatible.
- If you keep the migration, you will want to fix the issue or ignore the migration.
- By default, the newly created migration file will be deleted.
Do you want to keep the migration? [y/N]
[...]
Deleted tests/test_project/app_correct/migrations/0003_a_column.py

The linter found that the newly created migration is not backward compatible and deletes the files.This behaviour can be the default of the makemigrations command through the MIGRATION_LINTER_OVERRIDE_MAKEMIGRATIONS Django settings.Find out more about the makemigrations command at docs/makemigrations.md.

More information

Please find more documentation generally in the docs/ folder.

Some implementation details can found in the ./docs/internals/ folder.

Blog post

They talk about the linter

Related

  • django-test-migrations - Test django schema and data migrations, including migrations' order and best practices.

License

django-migration-linter is released under the Apache 2.0 License.

Maintained by David Wobrock
  • Django开发—如何重置migration @(Django)[migration] 情景一:不需要原有的数据库数据 删除数据库所有的表 删除项目的migration模块中的所有 文件,除了__init__.py 文件 执行脚本 python manage.py makemigrations python manage.py migrate 情景2:不想要删除现有的数据库,只是想重新建立 mig

  • Django框架下使用model来操作数据对象。刚接触过程中,对makemigration 和 migrate有些不解,在此总结下。 makemigration生成ddl语句,migrate执行ddl语句。 详见如下例子。 (virtual) E:\virtual\myapp>python manage.py makemigrations Did you rename person.firtst_

  • 初步完成一个django application的开发后,由于需求更改,需要修改models.py。models.py里面原本只有一个model,叫做Query。这个application叫interface。手贱直接在mysql里面删除了Query这张表。接下去,增改了Query的一些属性,运行python manage.py makemigrations与python manage.py mi

  •       django 1.8之后推出的migrations机制使django的数据模式管理更方便容易,现在简单谈谈他的机制和一些问题的解决方法: 1、谈谈机制:migrations机制有两个指令,第一个是makemigrations,第二个是migrate,生成migrations代码的makemigrations指令是用models里面的model和当前的migrations代码里面的mod

  • Django在使用migrete命令时由于自己的误操作报了以下错误, django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default'

  • 继承ModelForm 覆盖 clean_field_name(self)方法 class YourModelForm(ModelForm): def clean_field_name(self): data = self.cleaned_data['field_name'] if not data: # 如果data不满足满足条件

  • #!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "firstsite.settings") try: from django.core.management import exe

  • from:http://www.withfan.com/blog/django-17-%E6%96%B0%E7%9A%84migration%E6%A1%86%E6%9E%B6%E5%8F%96%E4%BB%A3south/ https://docs.djangoproject.com/en/dev/topics/migrations/ 迁移 Django 1.7i 新特性 Migrations是

  • 看django文档看到关于models.manager时候,前面custom manager都还好懂,但这个use_for_related_fields一时没看懂,搜了下,下面这个在stackoverflow上的回答很好,记一下 http://stackoverflow.com/questions/6067195/how-does-use-for-related-fields-work-in-dj

  • 字段选项 通用参数 下面的参数是通用的,适合所有的字段类型。 blank 如果设置为 True ,该字段允许为空。默认为 False 。 需要注意的是它和null的区别,null是数据库层的参数,然而blank是校验层的参数,如果一个字段设置了blank=True 类型属性检查时候允许为空值,如果一个字段设置blank=False,那么字段必须有值。 null 如果设置为 True , 当该字段为

  • 1.makemigrations 会在app下建立 migrations目录 python manage.py makemigrations # 或 指定应用名称 app_name python manage.py makemigrations app1 2.migrate 同步数据库 # 默认使用配置项中的defult数据库 python manage.py migrate # 也可以指

  • Django在执行python manage.py makemigrations的时候提示异常: django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency user.0001_initial on databa

 相关资料
  • migration 负责将原先的ovs或linux bridge的数据库迁移到ml2支持的数据库格式。 包括cli.py,migrate_to_ml2.py等。

  • In line with our stability promise, the Prometheus 2.0 release contains a number of backwards incompatible changes. This document offers guidance on migrating from Prometheus 1.8 to Prometheus 2.0 and

  • Migrating from 7 to 8 The purpose of the following guide is to facilitate a smoother update to the 8.0.0 version of Handsontable. We strongly recommend an upgrade to make use of all beneficial changes

  • 命名 gitcvs-migration - Git for CVS users 概要 git cvsimport * 描述 Git 与 CVS 的不同之处在于,每个工作树都包含一个具有项目历史记录完整副本的存储库,并且任何存储库本身都比其他任何存储库都重要。但是,您可以通过指定人员可以同步的单个共享存储库来模拟 CVS 模型; 本文档解释了如何做到这一点。 对 Git 有一些基本的了解是必需的。通

  • ::: tip Attention MetaMask Users If you are a MetaMask user attempting to use a legacy Ethereum website that hasn't migrated to the new API, please see the section on the MetaMask Legacy Web3 Extensio

  • DM (Data Migration) 是一体化的数据同步任务管理平台,支持从 MySQL 或 MariaDB 到 TiDB 的全量数据迁移和增量数据同步。使用 DM 工具有利于简化错误处理流程,降低运维成本。 DM 架构 DM 主要包括三个组件:DM-master,DM-worker 和 dmctl。 DM 数据同步功能的核心特性。 Table routing Table routing 是指将