List Info

Thread: Changing Field names...




Changing Field names...
user name
2006-12-29 00:24:36
Alright, I have a simple Work Order entry system. I want to
add a
boolean field to the system. How is this done if there is
already data
in the system? Can I just add it to the model, then run
syncdb? Should
I add it to the model, then manually add it to the database?
Is there a
documented approach for this?

Any help?


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Changing Field names...
user name
2006-12-29 02:22:48

On 29-Dec-06, at 5:54 AM, mediumgrade wrote:

> Alright, I have a simple Work Order entry system. I
want to add a
> boolean field to the system. How is this done if there
is already data
> in the system? Can I just add it to the model, then run
syncdb? Should
> I add it to the model, then manually add it to the
database? Is  
> there a
> documented approach for this?

1. change your model
2. run python manage.py sqlall yourapp > somefile.sql
3. open somefile.sql and check what syntax django uses to
create your  
boolean column. You need to be careful to see how it deals
with the  
column name, default value and not null.

assume it creates a column like: 'myboolfield boolean not
null  
default=False', then you need to run the following sql
statements;

alter table foo add column myboolfield boolean;
update table foo set myboolfield = False;
alter table foo alter column myboolfield set not null;
alter table foo alter column myboolfield set default=False;

you can put these statements in a script and distribute the
script to  
your customers

-- 

regards
kg
http://lawgon.livejourn
al.com
http://nrcfosshelpline
.in/web/



--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )