Re: restore migration files

2018-06-06 Thread C. Kirby
Glad to hear!

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/1b76a1f3-ed7c-4a58-a397-d3c19fd72cdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: restore migration files

2018-06-06 Thread Leif
thank you, Mike

On Wednesday, June 6, 2018 at 9:24:24 AM UTC-4, Mike Dewhirst wrote:
>
> Maybe you can find an old backup of your models and create a new database 
> from them. Then overwrite the old models with your latest ones and make 
> migrations again. Those should suffice to replace the deleted migrations.
>
> *Connected by Motorola*
>
>
> Leif > wrote:
>
> Dear Django Experts:
>
> Somehow I deleted the files under migrations directory. Now I am no longer 
> able to migrate new changes. I got 'No change detected' message when I 
> apply python manage.py migrate. Anway I can restore files under migrations 
> directory?
>
> Best,
>
> Leif
>
> -- 
> 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 django-users...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com 
> .
> 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/7c972a46-5e24-44cb-bb27-b0b006197d8e%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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/a2036314-2e4b-4437-9027-4e2546e0cc6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: restore migration files

2018-06-06 Thread Leif
Hi Kirby,
Thank you very much. That is very helpful. It is working now. Now the 
migrations directory is tracked in code repository to prevent from 
happening again.
Best,
Leif  

On Wednesday, June 6, 2018 at 10:23:01 AM UTC-4, C. Kirby wrote:
>
> If you don't need the history of the app migrations then it is pretty 
> straightforward, you will basically end up with a squashed migration. If 
> you do need the migration history (there is another system that is not up 
> to sync with yours, etc) you are stuck, and I would suggest you start using 
> a version control system (git, hg, etc)
> Assuming it is ok to end up with one squashed migration:
>
> 1) Remove any changes you have made in your code that inform the database 
> schema for the app(s) in question(so model changes)
> 2) Access the database directly (assuming postgres - psql, other databases 
> have different interfaces)
> 3) There is a table django_migrations with the fields id, app, name, 
> applied. Run a 
> delete from django_migrations where app = '';
> for whatever app you deleted the migrations from (run it a few times if 
> you deleted multiple app migrations)
> 4) For all the apps you need to rebuild migrations for
> ./manage makemigrations [app-names]
> 5)For  each app that you needed to rebuild the migrations
> ./mange migrate [app-name] --fake
> This tells the database to write to the dajngo_migrations table that the 
> migration was run, but doesn't actually change the schema. This is why your 
> code and db need to be in sync. Otherwise you will have changes in the 
> migration that are not reflected in the db, but the migtration is marked as 
> having been run
>
> You are now back in shape. Now set up git. I  am happy to help or point 
> you to references for it
>
> Kirby
>
> On Wednesday, June 6, 2018 at 8:54:48 AM UTC-4, Leif wrote:
>>
>> Dear Django Experts:
>>
>> Somehow I deleted the files under migrations directory. Now I am no 
>> longer able to migrate new changes. I got 'No change detected' message when 
>> I apply python manage.py migrate. Anway I can restore files under 
>> migrations directory?
>>
>> Best,
>>
>> Leif
>>
>>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/2afc9851-776a-487c-bf83-d038bc5c769e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: restore migration files

2018-06-06 Thread C. Kirby
If you don't need the history of the app migrations then it is pretty 
straightforward, you will basically end up with a squashed migration. If 
you do need the migration history (there is another system that is not up 
to sync with yours, etc) you are stuck, and I would suggest you start using 
a version control system (git, hg, etc)
Assuming it is ok to end up with one squashed migration:

1) Remove any changes you have made in your code that inform the database 
schema for the app(s) in question(so model changes)
2) Access the database directly (assuming postgres - psql, other databases 
have different interfaces)
3) There is a table django_migrations with the fields id, app, name, 
applied. Run a 
delete from django_migrations where app = '';
for whatever app you deleted the migrations from (run it a few times if you 
deleted multiple app migrations)
4) For all the apps you need to rebuild migrations for
./manage makemigrations [app-names]
5)For  each app that you needed to rebuild the migrations
./mange migrate [app-name] --fake
This tells the database to write to the dajngo_migrations table that the 
migration was run, but doesn't actually change the schema. This is why your 
code and db need to be in sync. Otherwise you will have changes in the 
migration that are not reflected in the db, but the migtration is marked as 
having been run

You are now back in shape. Now set up git. I  am happy to help or point you 
to references for it

Kirby

On Wednesday, June 6, 2018 at 8:54:48 AM UTC-4, Leif wrote:
>
> Dear Django Experts:
>
> Somehow I deleted the files under migrations directory. Now I am no longer 
> able to migrate new changes. I got 'No change detected' message when I 
> apply python manage.py migrate. Anway I can restore files under migrations 
> directory?
>
> Best,
>
> Leif
>
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/3709a8fc-5666-4ae8-9a9c-4b9b85bd89c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: restore migration files

2018-06-06 Thread Mike Dewhirst
Maybe you can find an old backup of your models and create a new database from 
them. Then overwrite the old models with your latest ones and make migrations 
again. Those should suffice to replace the deleted migrations.

Connected by Motorola

Leif  wrote:

>Dear Django Experts:
>
>
>Somehow I deleted the files under migrations directory. Now I am no longer 
>able to migrate new changes. I got 'No change detected' message when I apply 
>python manage.py migrate. Anway I can restore files under migrations directory?
>
>
>Best,
>
>
>Leif
>
>
>-- 
>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 django-users+unsubscr...@googlegroups.com.
>To post to this group, send email to django-users@googlegroups.com.
>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/7c972a46-5e24-44cb-bb27-b0b006197d8e%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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/6kmkbwffbyqpigyotgnp9qiy.1528291298555%40email.android.com.
For more options, visit https://groups.google.com/d/optout.


Re: restore migration files

2018-06-06 Thread Leif
there is a suggestion here but not clear:
https://stackoverflow.com/questions/34919650/deleted-migration-files-how-to-makemigrations-without-losing-data


On Wednesday, June 6, 2018 at 8:54:48 AM UTC-4, Leif wrote:
>
> Dear Django Experts:
>
> Somehow I deleted the files under migrations directory. Now I am no longer 
> able to migrate new changes. I got 'No change detected' message when I 
> apply python manage.py migrate. Anway I can restore files under migrations 
> directory?
>
> Best,
>
> Leif
>
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/cd9ff30c-c02a-4e75-b8d7-2c4dfd26e5bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.