Re: Add a permission to a production db

2007-10-02 Thread Todd O'Bryan

On Wed, 2007-10-03 at 07:58 +0800, Russell Keith-Magee wrote:
> On 10/3/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
> >
> > How should I add a permission to an app/model that already exists in a
> > production db? The docs say to use syncdb, but that doesn't work (I
> > don't think) when the db tables already exist. Also, sqlall doesn't show
> > the SQL that's used to create the permissions.
> >
> > I'm just really worried that I'll accidentally hose my db.
> 
> My reading of this code is that it should add the permissions for your
> pre-existing table. create_permissions() calls get_or_create for all
> permissions on all models in a given app, and the handler will be
> called for all installed apps. If you have a pre-existing table, it
> won't have a permissions, so they should be created without any drama.
> 
Thanks! I feel much better, now.

Todd


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Add a permission to a production db

2007-10-02 Thread Russell Keith-Magee

On 10/3/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
>
> How should I add a permission to an app/model that already exists in a
> production db? The docs say to use syncdb, but that doesn't work (I
> don't think) when the db tables already exist. Also, sqlall doesn't show
> the SQL that's used to create the permissions.
>
> I'm just really worried that I'll accidentally hose my db.

The permissions are installed using a post-syncdb handler, registered
by django.contrib.auth.management. The handler is
create_permissions(). This is the reason that the SQL isn't included
in sqlall - sqlall only shows you the create table/index calls.

My reading of this code is that it should add the permissions for your
pre-existing table. create_permissions() calls get_or_create for all
permissions on all models in a given app, and the handler will be
called for all installed apps. If you have a pre-existing table, it
won't have a permissions, so they should be created without any drama.

I don't think there's any risk that it would hose your db. However,
Murphy being the man he is, I'd still take a backup before I did
anything :-)

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Add a permission to a production db

2007-10-02 Thread Todd O'Bryan

How should I add a permission to an app/model that already exists in a
production db? The docs say to use syncdb, but that doesn't work (I
don't think) when the db tables already exist. Also, sqlall doesn't show
the SQL that's used to create the permissions.

I'm just really worried that I'll accidentally hose my db.

Thanks,
Todd

P.S. We just deployed a Django site entirely written by me and my high
school students that we're hoping will evolve into a cool way for the
school to exchange information. We just added over 2000 users and
parents and teachers are using the system to schedule conferences.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---