Giter VIP home page Giter VIP logo

django-evolution's Introduction

Django Evolution

Django Evolution is an add-on to the Django web framework that helps manage changes to the database schema.

"But wait, why would I want this? Doesn't Django have migrations built-in? Isn't this the same thing?"

Yes, yes it does, and it mostly is. In fact, Django Evolution works comfortably alongside Django's migrations, helping you get the best out of both.

There are cases where you might want an alternative to migrations:

  1. You're still stuck on Django 1.6 or earlier and need to make changes to your database.

    Django 1.6 is the last version without built-in support for migrations, and there are still codebases out there using it. Django Evolution can help keep upgrades manageable, and make it easier to transition all or part of your codebase to migrations when you finally upgrade.

  2. You're distributing a self-installable web application, possibly used in large enterprises, where you have no control over when people are going to upgrade.

    Django's migrations assume some level of planning around when changes are made to the schema and when they're applied to a database. The more changes you make, and the more versions in-between what the user is running and what they upgrade to, the longer the upgrade time.

    If a customer is in control of when they upgrade, they might end up with years of migrations that need to be applied.

    Migrations apply one-by-one, possibly triggering the rebuild of a table many times during an upgrade. Django Evolution, on the other hand, can apply years worth of evolutions at once, optimized to perform as few table changes as possible. This can take days, hours or even seconds off the upgrade time.

What versions of Django are supported?

Django Evolution 2.x supports Django 1.6 through 4.2, and Python 2.7 through 3.12.

For older versions of Django, see Django Evolution 0.7.

There's built-in support for evolving SQLite, Postgres, MySQL, and MariaDB databases.

I can't imagine anything better... How do I start?

We have a bunch of documentation just for you!

There, you'll find out how to install it, configure it for your project, generate evolutions, and apply them.

Plus, answers to all^W some of your burning questions, like "how do these work with migrations?" and "why is my syncdb/migrate command weird now?"

Who's using Django Evolution today?

There's dozens of us! Dozens!

At Beanbag we're using it in Review Board, our open source code review product, used by thousands of companies world-wide. So we know it works. Review Board predated Django's migrations by a whole lot of years, and continues to benefit from the optimized upgrade times of evolutions today.

django-evolution's People

Contributors

chipx86 avatar davidt avatar freakboy3742 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

django-evolution's Issues

Adding or modifying columns makes assumptions on SQL syntax

When using django-evolution with a SAP SQL Anywhere database, adding columns to or modifying columns in existing tables will not work. This is because AlterTableSQLResult._preprocess_alter_table_ops assumes that the syntax for adding or modifying columns uses the "ADD COLUMN" or "MODIFY COLUMN" syntax. With SQL Anywhere, the syntax is ALTER TABLE <table> ADD <column> and ALTER TABLE <table> ALTER <column> but if I use "ADD" or "ALTER" as the operation, the db_type field is not included, which results in invalid SQL.

KeyError: Swapped

When trying to mutate the database with the following:

#----- Evolution for dashboard
from django_evolution.mutations import AddField
from django.db import models


MUTATIONS = [
    AddField('MyUser', 'is_manager', models.BooleanField, initial=False),
    AddField('MyUser', 'manager', models.ForeignKey, null=True, related_model=u'dashboard.MyUser')
]
#----------------------
#----- Evolution for project
from django_evolution.mutations import AddField, DeleteField
from django.db import models


MUTATIONS = [
    AddField('LandingPage', 'name', models.CharField, initial=u'My Page', max_length=64),
    AddField('LandingPage', 'owner', models.ManyToManyField, related_model=u'dashboard.MyUser'),
    AddField('AccessPoint', 'lp', models.ForeignKey, null=True, related_model=u'project.LandingPage'),
    DeleteField('LandingPage', 'ap')
]

i get the following error:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django_evolution/management/commands/evolve.py", line 60, in handle
    self.evolve(*app_labels, **options)
  File "/usr/local/lib/python2.7/dist-packages/django_evolution/management/commands/evolve.py", line 140, in evolve
    database))
  File "/usr/local/lib/python2.7/dist-packages/django_evolution/mutations.py", line 424, in mutate
    return self.add_m2m_table(app_label, proj_sig, database)
  File "/usr/local/lib/python2.7/dist-packages/django_evolution/mutations.py", line 473, in add_m2m_table
    sql_statements = evolver.add_m2m_table(model, field)
  File "/usr/local/lib/python2.7/dist-packages/django_evolution/db/common.py", line 86, in add_m2m_table
    sql, references = creation.sql_create_model(f.rel.through, style)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/creation.py", line 46, in sql_create_model
    if not opts.managed or opts.proxy or opts.swapped:
  File "/usr/local/lib/python2.7/dist-packages/django_evolution/mutations.py", line 164, in __getattr__
    return self.meta[name]
KeyError: 'swapped'

django-evolution version 1.6.2

Please publish release with django 1.7+ support

Hi,

As far as I see, git repo already supports recent versions of django. Could you please release it as something like 0.6.8?

It'll simplify things for distributions. Otherwise I'll need to fix debian package by upload something like 0.6.7+git20160728

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.