On Wed, Oct 16, 2013 at 12:34 AM, Olemis Lang <[email protected]> wrote:
> On 10/15/13, Saint Germain <[email protected]> wrote: > > Sorry to have been unclear. I do not wish to migrate from SQLite to > > PostgreSQL, I just want to wipe the SQLite database and create a > > PostgreSQL database while keeping all the configuration. > > I do not know , but maybe you'll achieve this by running trac-admin > ... upgrade after binding the env to a pristine DB ? > I've had to do this before; there's no clean trac-admin way to do it, but it's not too difficult. IIRC running trac-admin upgrade doesn't work in this situation, because `upgrade` expects the database to already exist, with its schema created, and at least some data present in the system table. You can do this with some python code. First, edit your conf/trac.ini database setting to point to the desired new database (and create it if it's a postgres database). Then open up a python shell and run the following code: {{{ from trac.env import Environment env = Environment("/path/to/my/environment") from trac.db import DatabaseManager DatabaseManager(env).init_db() ## After the above, your database schema will be created, but the default content is not yet in place. ## At minimum, the system table must be populated with initial content so that trac knows what version is set up. from trac import db_default with env.db_transaction as db: for table, cols, vals in db_default.get_data(db): db.executemany("INSERT INTO %s (%s) VALUES (%s)" % (table, ','.join(cols), ','.join(['%s' for c in cols])), vals) ## Now your database is populated with the necessary content and you can run Trac against it. ## This also includes the default components, versions, etc that Trac likes to set up. ## The default wiki content has NOT yet been created though. We'll do that next. import pkg_resources from trac.wiki.admin import WikiAdmin pages_dir = pkg_resources.resource_filename('trac.wiki', 'default-pages') WikiAdmin(env).load_pages(pages_dir) }}} That should get you a fully set up database including Trac's default content (wiki docs, component1/component2, version1/version2, etc). I've thought about packaging it into a plugin's trac-admin command or submitting a core patch, but I had assumed nobody else would ever need it. :-) Hope this helps, Ethan -- You received this message because you are subscribed to the Google Groups "Trac Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/trac-dev. For more options, visit https://groups.google.com/groups/opt_out.
