Edgewall Software

Opened 8 years ago

Last modified 6 years ago

#12299 closed enhancement

Integrate functionality of TracMigratePlugin — at Version 14

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.3.2
Component: database backend Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Added TracAdmin migrate command, which migrates a database to the same or new environment while changing the database backend.

API Changes:
Internal Changes:

Description

Database is locked is one of the most frequent duplicates. For migrating databases we suggest using TracMigratePlugin. The plugin is stable and I've used it for several migrations. We could move the code into tracopt. I'm seeking feedback on that idea. Jun, are you okay with the code being moved into the Trac core?

We might consider naming the module convert.py rather than migrate.py. The TracMigrate page documents a slightly different scenario.

Change History (14)

comment:1 by Ryan J Ollos, 8 years ago

I did some initial work in log:rjollos.git:t12299_trac_migrate. More work would be needed to move ahead.

in reply to:  description ; comment:2 by Jun Omae, 8 years ago

Jun, are you okay with the code being moved into the Trac core?

Yeah. No problem.

We could move the code into tracopt. …. We might consider naming the module convert.py rather than migrate.py.

It would be good to move the code into trac.admin.convert or trac.db.convert. I think it would be useful to be able to use without changes of [components] section.

in reply to:  2 ; comment:3 by Ryan J Ollos, 8 years ago

Replying to jomae:

It would be good to move the code into trac.admin.convert or trac.db.convert. I think it would be useful to be able to use without changes of [components] section.

Those changes sound good.

I haven't been able to get the TracMigratePlugin tests to pass with PostgreSQL. After the following change they pass:

  • tracmigrate/tests/admin.py

     
    6767        att.insert('filename.txt', StringIO('test'), 4)
    6868        env.shutdown()
    6969
    70     if 'destroying' in inspect.getargspec(EnvironmentStub.__init__)[0]:
    71         def _destroy_db(self):
    72             EnvironmentStub(destroying=True)
    73     else:
    74         def _destroy_db(self):
    75             EnvironmentStub().destroy_db()
     70    # if 'destroying' in inspect.getargspec(EnvironmentStub.__init__)[0]:
     71    #     def _destroy_db(self):
     72    #         EnvironmentStub(destroying=True)
     73    # else:
     74    def _destroy_db(self):
     75        EnvironmentStub(destroying=True).destroy_db()
    7676
    7777    def _get_all_records(self, env):
    7878        def primary(row, columns):

in reply to:  3 comment:4 by Jun Omae, 8 years ago

Replying to Ryan J Ollos:

I haven't been able to get the TracMigratePlugin tests to pass with PostgreSQL. After the following change they pass: […]

Thanks for the investigating! Fixed in th:r15147. I didn't probably test with Trac 1.0+ and PostgreSQL.

comment:5 by Ryan J Ollos, 8 years ago

Milestone: next-major-releases1.2
Owner: set to Ryan J Ollos
Status: newassigned
Summary: Add TracMigratePlugin to tracoptIntegrate functionality of TracMigratePlugin

comment:6 by Ryan J Ollos, 8 years ago

There are some changes we should incorporate in th:#12696, th:#12697 and th:#12691.

comment:7 by Ryan J Ollos, 8 years ago

DONE Document obsolescence of TracMigratePlugin at 1.3/TracUpgrade.

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:8 by Ryan J Ollos, 8 years ago

For inplace migration, TracMigrate creates a temporary environment and for the SQLite case it copies the database file back to the migrated environment after the migration is finished. Would it work just as well if the source and destination environments were the same for an inplace migration?

comment:9 by Ryan J Ollos, 8 years ago

I'm looking at moving the database conversion methods to trac.db.convert.DatabaseConverter, and putting the migrate command in trac.env.EnvironmentAdmin. That would result in two trac-admin commands:

  • convertdb <dburi>: convert database (inplace)
  • migrate <dstenv> [dburi]: migrate environment and optionally convert the database

comment:10 by Emmanuel Blot, 8 years ago

I recently (and repeatedly) bumped into an issue with TracMigratePlugin and inherited trac.ini files:

Missing configuration file appkit/conf/trac.ini
Missing configuration file appkit/conf/site.ini
Missing configuration file appkit/conf/site.ini

I'm not sure what's going on here. Moreover I'm not sure yet if it tied but as the plugins are enabled in one of the inherited files, the DB tables for those plugins are not exported.

in reply to:  10 comment:11 by Jun Omae, 8 years ago

Replying to Emmanuel Blot:

I recently (and repeatedly) bumped into an issue with TracMigratePlugin and inherited trac.ini files:

[…]

I'm not sure what's going on here. Moreover I'm not sure yet if it tied but as the plugins are enabled in one of the inherited files, the DB tables for those plugins are not exported.

That may be caused by non-absolute path in [inherit] file option. Could you please create new ticket with the details on trac-hacks.org?

comment:12 by Ryan J Ollos, 8 years ago

Milestone: 1.21.3.1

comment:13 by Christian Boos, 7 years ago

Milestone: 1.3.1next-dev-1.3.x

Moving to some later 1.3.x version.

comment:14 by Ryan J Ollos, 7 years ago

Milestone: next-dev-1.3.x1.3.2
Release Notes: modified (diff)
Note: See TracTickets for help on using tickets.