Framework: Django like migrations?

Created on 6 Jan 2015  路  10Comments  路  Source: laravel/framework

As much as i love the workflow in Laravel, i feel that the whole schema/migrations part is a bit quirky.

My proposal is to look into either South for Django 1.6- or the migrations in Django 1.7.

Instead of creating schemas, you add/remove/change properties to the model directly and then sync the changes using a cli command. Pretty neat imo.

Most helpful comment

I think adding this would really be a nice feature. Not just in terms of migrations but also so we can easily access schema for nice admin/api features (at least for prototyping) like auto form creation, and auto api creation (see Django REST Framework).

All 10 comments

You define your model attributes in Django models so django can map them to the correct SQL schema. In Eloquent , Model attributes are not declared explicitly.

That's entirely true and something i'm fully aware of :) I've built a couple of projects using Eloquent, but this is also why i'm raising the question.

Why is it bad to declare the attributes in the model and then syncing the changes to a migration file?

It is kind of and opinion-based problem. Also I thinks Eloquent is no designed to be treated like this.

@pariz Have you tried Doctrine?

Agreed, Eloquent isn't designed for this. But it abstracts away the direct need for schemas. One less file to manage per model.

It has clear gains in terms of ease of development too. Instead of referring to the schema files or the database when needing to see the properties of a model, you just open the model file and there you have it.

@ibrasho doctrine 1 a bunch of years ago, haven't even given it a thought that doctrine 2 may deliver such functionality. I'll look into it :) Thanks man

Missing Django.

maybe move this over to internals because I think it warrants some discussion. i fully agree migrations are great, but there may be room for improvement.

I think adding this would really be a nice feature. Not just in terms of migrations but also so we can easily access schema for nice admin/api features (at least for prototyping) like auto form creation, and auto api creation (see Django REST Framework).

Having attributes declared in model will be a good thing while using noSQL DBs as well because this is no more just SQL based world. Also in case of noSQL you have to defined attributes in model to avoid no set variable error. Also having django like make migrations makes it more declared than telling each and every thing to do in migrations everytime you change a small thing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

felixsanz picture felixsanz  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments

klimentLambevski picture klimentLambevski  路  3Comments

ghost picture ghost  路  3Comments

PhiloNL picture PhiloNL  路  3Comments