Noah Kantrowitz | 9 Feb 09:07
Gravatar

Re: [Trac] regarding new database tables and safety


On Feb 8, 2010, at 9:43 PM, Vishal wrote:

> Hi,
>
> I would like to add some extra data to the trac installation I have,
> and for this I may need to add extra tables to the database being
> used. Since the database schema will change from the default one, i
> would like to know under what situations will a trac database update
> be required (as done by using the upgrade command from trad-admin)?
> Also, if there is no way to avoid the upgrade, is there a way to do
> this seamlessly, so a user does not know about it.
>

My snippet for doing this is http://trac-hacks.org/browser/tracforgeplugin/0.11/tracforge/admin/api.py#L69

http://trac-hacks.org/browser/tracforgeplugin/0.11/tracforge/admin/db_default.py 
  shows how I setup my schema.

As for making it transparent, no, Trac doesn't work that way. This is  
primarily for safety reasons. DDL changes (like changing tables)  
generally can't be rolled back as part of a transaction if the upgrade  
fails, so you could end up with a bad DB. This is why trac-admin  
upgrade makes a backup for you if possible (or requires you to state  
that you are okay without one since you took a DB backup yourself).

> An example for this situation is the client plugin. Whenever I try to
> add a new client or change anything in the client custom filed, the
> trac project asks me to do an upgrade. This would be sort of very
> difficult for the end user, particularly since they wont have admin
> permissions, but would need to to add a client nonetheless.
>

I don't know what the client plugin is doing, but changing custom  
fields doesn't require a DB change, it doesn't even require a server  
restart.

--Noah

--

-- 
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users@...
To unsubscribe from this group, send email to trac-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


Gmane