Confused with deleted migrations

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Confused with deleted migrations

Mohammad Etemaddar
Hey folks
After uploading the app to the server, I got problems by local migrations in development. So deleted the migrations and local sqlite db (Server uses MySQL).
After more development, uploaded the whole project to the server and overwrite the files. And typed migrate on server. I don't know what happened to the database. Some new tables seems to be created (or not). I got really confused with this situation. It is much confusing to get backup from server's data and then restore them back.
What is your opinion?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d050785c-3924-40cb-8c9c-2b878dda4ad5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Confused with deleted migrations

Andréas Kühne
Hi Mohammed,

You need to make sure that all migrations that you do in development also can be run on the production machine - the migrations should be version controlled and checked in. Then you can run migrate when deploying new code and all migrations should just work. This is how I do it at least.

It seems as though you have different migrations on the server and development machine? I think that adds complexity that you really don't want.

And it doesn't matter if you have mysql on the production server and sqlite locally. The database settings should differ but the migrations are (more or less) database agnostic, so you should be able to run the same migrations (as long as you don't use specific database fields).

Regards,

Andréas


Den ons 12 juni 2019 kl 20:27 skrev Mohammad Etemaddar <[hidden email]>:
Hey folks
After uploading the app to the server, I got problems by local migrations in development. So deleted the migrations and local sqlite db (Server uses MySQL).
After more development, uploaded the whole project to the server and overwrite the files. And typed migrate on server. I don't know what happened to the database. Some new tables seems to be created (or not). I got really confused with this situation. It is much confusing to get backup from server's data and then restore them back.
What is your opinion?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d050785c-3924-40cb-8c9c-2b878dda4ad5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCcHqiW%2BScQ3TBJ3-OCaESu9MXj01J%3D3GFeWKfjZrnaFCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Confused with deleted migrations

Mohammad Etemaddar
In reply to this post by Mohammad Etemaddar
I got really confused. I don't know how to use version control. I think this might happen again.
I need to understand what you did with version control. It would be appreciated if you could post an instructions on here or any blog.
Thank you.

On Wednesday, June 12, 2019 at 10:57:56 PM UTC+4:30, Mohammad Etemaddar wrote:
Hey folks
After uploading the app to the server, I got problems by local migrations in development. So deleted the migrations and local sqlite db (Server uses MySQL).
After more development, uploaded the whole project to the server and overwrite the files. And typed migrate on server. I don't know what happened to the database. Some new tables seems to be created (or not). I got really confused with this situation. It is much confusing to get backup from server's data and then restore them back.
What is your opinion?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b904f72-e321-41b8-b8a4-44480560544c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Confused with deleted migrations

Andréas Kühne
Hi,

If you look here:

You will see Djangos official take on migrations - you don't need to use version control for handling them (see here for examples of version control: https://en.wikipedia.org/wiki/Version_control). 

The main thing however is that you need to make sure that the migration files (in each apps migrations directory) should always be added to, and you should never delete files there. So if you are working on a project and developing it locally - you do the changes on the models and then run "python manage.py makemigrations". Django will then create migration files for you that have the changes you just have done. These you need to keep all the time (you can also squash migrations, but that's rather advanced). These migration files can be run both on you development server and on your production server - they will do the changes required.

It SHOULDN'T matter which database you use on production and development, however - I usually use the same locally and on production, just to make sure that we don't get any strange issues because of differences. But that's just me :-)

Regards,

Andréas


Den sön 16 juni 2019 kl 09:05 skrev Mohammad Etemaddar <[hidden email]>:
I got really confused. I don't know how to use version control. I think this might happen again.
I need to understand what you did with version control. It would be appreciated if you could post an instructions on here or any blog.
Thank you.

On Wednesday, June 12, 2019 at 10:57:56 PM UTC+4:30, Mohammad Etemaddar wrote:
Hey folks
After uploading the app to the server, I got problems by local migrations in development. So deleted the migrations and local sqlite db (Server uses MySQL).
After more development, uploaded the whole project to the server and overwrite the files. And typed migrate on server. I don't know what happened to the database. Some new tables seems to be created (or not). I got really confused with this situation. It is much confusing to get backup from server's data and then restore them back.
What is your opinion?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b904f72-e321-41b8-b8a4-44480560544c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCf%3DsNSL0RS1eWq_Cd20nN8LdArv45F2rovjtOdvx4quFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.