Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add columns if QDjangoModel changes #15

Open
fjfeijoo opened this issue Mar 11, 2014 · 2 comments
Open

Add columns if QDjangoModel changes #15

fjfeijoo opened this issue Mar 11, 2014 · 2 comments

Comments

@fjfeijoo
Copy link

Hi,

Right now if you modify a field on your model, you need to delete the table to make it work. The select statements use column names that doesn't exist and fails.

I would like to discuss if you are interested on adding a new feature to regenerate the tables (adding columns) if the model changes.

Basically, in createTable(), if the table exists then check the columns of the table and the fields of the model, if any of the fields is not in the table, alter the table accordingly.

Does it have sense? Otherwise, is there any other method instead of removing the table?

Thanks.

@jlaine
Copy link
Owner

jlaine commented Mar 11, 2014

On 03/11/2014 09:18 AM, Franciso Javier Feijoo Cano wrote:

Hi,

Right now if you modify a field on your model, you need to delete the table to make it work. The select statements use column names that doesn't exist and fails.

I would like to discuss if you are interested on adding a new feature to regenerate the tables (adding columns) if the model changes.

Basically, in createTable(), if the table exists then check the columns of the table and the fields of the model, if any of the fields is not in the table, alter the table accordingly.

Does it have sense? Otherwise, is there any other method instead of removing the table?

Having fully fledged support for migrations is a complex task (adding
columns is only one of the operations that need to be supported) which
is why I have held off implementing it so far.

If you really want to tackle it I suggest looking at south [1] for
inspiration.

[1] https://south.aeracode.org/

@fjfeijoo
Copy link
Author

Hi Jeremy,

I'll have a look. I understand that supporting migrations can be really complex. But right now, if you install your app in a customer, and for some reason modify your model, then you don't have any choice (apart from running a script on the db which I would like to avoid). I'm testing QDjango, not in any production app, and this is something a bit worrying.

I'm willing to help (as long as I'm capable to), could you think about a minimum set of features regarding migrations that would make you happy?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants