Drop and replace SQL Table automatically when Model is migrated

2015-12-06 Thread Alexander Whatley
This question may just be due to my inexperience with Django, but whenever 
I modify one of my Model elements and change its parameters, I have to 
close my IDE and manually use the command prompt to drop the SQL Table 
corresponding to the Model, and then migrate the new model, which is very 
annoying. Is there a built in feature in Django that allows me to get 
around having to do this, and if not, is there one in development? Thanks.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/06d9f15a-eaff-43e3-90d6-56a0b03c4e97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Drop and replace SQL Table automatically when Model is migrated

2015-12-06 Thread Mike Dewhirst

On 7/12/2015 7:21 AM, Alexander Whatley wrote:

This question may just be due to my inexperience with Django, but
whenever I modify one of my Model elements and change its parameters, I
have to close my IDE and manually use the command prompt to drop the SQL
Table corresponding to the Model, and then migrate the new model, which
is very annoying.


It sounds like this is a feature your IDE should provide. Django has the 
necessary functionality but won't do it unbidden.



Is there a built in feature in Django that allows me

to get around having to do this, and if not, is there one in
development? Thanks.

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/06d9f15a-eaff-43e3-90d6-56a0b03c4e97%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5664D756.1090909%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Drop and replace SQL Table automatically when Model is migrated

2015-12-06 Thread James Schneider
On Dec 6, 2015 4:48 PM, "Mike Dewhirst"  wrote:
>
> On 7/12/2015 7:21 AM, Alexander Whatley wrote:
>>
>> This question may just be due to my inexperience with Django, but
>> whenever I modify one of my Model elements and change its parameters, I
>> have to close my IDE and manually use the command prompt to drop the SQL
>> Table corresponding to the Model, and then migrate the new model, which
>> is very annoying.
>

Are you creating a new migration after each set of changes and then
applying that new migration? Why is it that you are expecting a table to
drop when all you are doing is modifying an existing table/model? If that's
the case, the existing table would be altered, not dropped and recreated
with the new attributes (which would cause a loss of data and likely other
issues with related data).

If the standard migration process is not working, you should post up the
errors that you are getting. Your IDE should have little to do with this
process, aside from maybe triggering the migration scripts to run if it
supports such an operation.

>
> It sounds like this is a feature your IDE should provide. Django has the
necessary functionality but won't do it unbidden.
>
>
>
> Is there a built in feature in Django that allows me
>>
>> to get around having to do this, and if not, is there one in
>> development? Thanks.
>>

If you are expecting (well, desiring) this behavior, you'll likely need to
write your own management command to perform this task, which is pretty
simple. I wrote one that does something similar to what you are expecting,
except that it drops the entire database, creates a new one, applies all
existing migrations, and then populates the DB with dummy data that I've
generated (since I'm working on models that expect that data to be present
already and its a pain to manually create it via the web browser every
time). Think of an online demo of an application that resets itself every
hour.

https://docs.djangoproject.com/en/1.9/howto/custom-management-commands/

I do think a built-in admin command to "reset" the entire database would be
handy, but I've been too lazy to put in the feature request.

-James

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXohddFptGwZxy%2B24AmYJqA2Ej6_3mv_pn%3Dmx%3DwbZ4m3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Drop and replace SQL Table automatically when Model is migrated

2015-12-06 Thread Alexander Whatley
I will check with the people who made the IDE. Thanks for the input.

On Sunday, December 6, 2015 at 3:22:50 PM UTC-5, Alexander Whatley wrote:
>
> This question may just be due to my inexperience with Django, but whenever 
> I modify one of my Model elements and change its parameters, I have to 
> close my IDE and manually use the command prompt to drop the SQL Table 
> corresponding to the Model, and then migrate the new model, which is very 
> annoying. Is there a built in feature in Django that allows me to get 
> around having to do this, and if not, is there one in development? Thanks.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b39603db-175d-42ac-a607-229a961788c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Drop and replace SQL Table automatically when Model is migrated

2015-12-07 Thread Jani Tiainen
Django has built-in support for database migrations since version 1.7. 
In normal conditions you should be using at least version 1.8 (LTS, and 
lowest version supported now).


On 07.12.2015 03:48, Alexander Whatley wrote:

I will check with the people who made the IDE. Thanks for the input.

On Sunday, December 6, 2015 at 3:22:50 PM UTC-5, Alexander Whatley wrote:

This question may just be due to my inexperience with Django, but
whenever I modify one of my Model elements and change its
parameters, I have to close my IDE and manually use the command
prompt to drop the SQL Table corresponding to the Model, and then
migrate the new model, which is very annoying. Is there a built in
feature in Django that allows me to get around having to do this,
and if not, is there one in development? Thanks.

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b39603db-175d-42ac-a607-229a961788c9%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56656733.4050101%40gmail.com.
For more options, visit https://groups.google.com/d/optout.