#10054 closed defect (fixed)
Upgrade database error 0.5 to 1.0
Reported by: | Owned by: | Martin Scharrer | |
---|---|---|---|
Priority: | normal | Component: | WatchlistPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description (last modified by )
Trying to upgrade from 0.5 to 1.0, get the following when running trac-admin upgrade:
OperationalError: table watchlist_new has 4 columns but 3 values were supplied
Running on trac 12.1, python 2.4.3 on RHEL5. To build egg file for 2.4, had to change: except Exception as e
in several places. Using sqlite3 db.
Attachments (1)
Change History (19)
comment:1 Changed 11 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 10 years ago by
Database version 4 now has columns: wluser, realm, resid, lastvisit. Database version 3 only has 3 columns so 'lastvisit' is new. In db.py, upgrade_watchlist_table_from_v3_to_v4 needs to have
self.upgrade_watchlist_table_to_v4('wluser,realm,resid', db)
Then, upgrade_watchlist_table_to_v4 needs to have this where it copies the old table to the new
cursor.execute(""" INSERT INTO watchlist_new (%s) SELECT DISTINCT %s FROM watchlist """ % (selection,selection))
There will need to be an if check for whether selection contains "*", or a list of fields and construct the INSERT sql appropriately. Not sure what fields were in version 1 and 0 of the database so upgrade_watchlist_table_from_v0_to_v4 and upgrade_watchlist_table_from_v1_to_v4 might also need to supply fields in the call to upgrade_watchlist_table_to_v4.
Also, since column lastvisit is new, it needs to be determined whether this needs to be populated with a default value when the old table is copied. There probably is a way to set up the table schema to use a default value for the column if a null value for lastvisit will cause problems. Or a simple new sql command could be added to upgrade_watchlist_table_to_v4:
UPDATE watchlist SET lastvisit=0 WHERE lastvisit IS NULL
I hope this information helps.
comment:4 Changed 10 years ago by
I used the easy_install command in the official release and on the about page, I get this info:
TracWatchlistPlugin 1.0 /usr/local/lib/python2.7/dist-packages/TracWatchlistPlugin-1.0-py2.7.egg
However, the 0.12 branch has more recent commits, so I should uninstall & try the 0.12.
Should the install instructions be made clearer, or is easy_install referencing the wrong version?
Anyway, I will attempt this and report back soon.
comment:5 Changed 10 years ago by
The situation is confusing because of the similar version numbering between Trac and WatchlistPlugin, but it looks like you've done everything correctly. The only branch on which development is done is labeled 0.12. The version of the plugin in that branch is now 1.0.1: watchlistplugin/0.12/setup.py@14329:57#L55. It was bumped from 1.0 to 1.0.1 just yesterday in [14329]. easy_install -U http://trac-hacks.org/svn/watchlistplugin/0.12
should get you the latest version.
comment:6 Changed 10 years ago by
I'm seeing this a bit more clearly now. By running easy_install
you've probably grabbed the 1.0 version from PyPI. If instead you point easy_install
at the SVN repository as shown in comment:5 you'll get the latest version from the 0.12 branch. Eventually we'll need to update the versions on PyPI, but I'll wait to see if we can fix a few more issues before doing that.
martin_s: would you be willing to give me elevated permissions to the PyPI page so that I can update the package? My PyPI username is rjollos.
comment:7 Changed 10 years ago by
I have run the easy_install command suggested in 5:
# easy_install -U http://trac-hacks.org/svn/watchlistplugin/0.12 Downloading http://trac-hacks.org/svn/watchlistplugin/0.12 Doing subversion checkout from http://trac-hacks.org/svn/watchlistplugin/0.12 to /tmp/easy_install-v0CxNh/0.12 Processing 0.12 Writing /tmp/easy_install-v0CxNh/0.12/setup.cfg Running setup.py -q bdist_egg --dist-dir /tmp/easy_install-v0CxNh/0.12/egg-dist-tmp-MCkhPO TracWatchlistPlugin 1.0.1 is already the active version in easy-install.pth Installed /usr/lib/python2.7/site-packages/TracWatchlistPlugin-1.0.1-py2.7.egg Processing dependencies for TracWatchlistPlugin==1.0.1 Finished processing dependencies for TracWatchlistPlugin==1.0.1
but I still get the error when I try to update:
# trac-admin /vol1/trac/systems upgrade The upgrade failed. Please fix the issue and try again. OperationalError: table watchlist_new has 4 columns but 3 values were supplied
Running Trac 1.0.1 on openSUSE with Python 2.7.
comment:8 Changed 10 years ago by
Nothing has been done yet to address the upgade issue reported in this ticket. However the plugin should work fine for new installations.
comment:9 follow-up: 14 Changed 10 years ago by
ok, I'm using Trac 1.0 on Ubuntu 14.10 and MySQL backend.
I removed all traces of TracWatchglist plugin including the database tables and then i ran this command:
easy_install -U http://trac-hacks.org/svn/watchlistplugin/0.12
After restarting apache, the about pagre reports
TracWatchlistPlugin 1.0.1 /usr/local/lib/python2.7/dist-packages/TracWatchlistPlugin-1.0.1-py2.7.egg
I then enabled the plugin in. and upgraded the environment without any errors.
So far, all looks good (at least I have gone further than my previous attempt)
When I try to add a page to the watchlist, I get this error now:
Trac detected an internal error: AttributeError: 'NoneType' object has no attribute 'time_formats'
The python traceback shows:
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.py", line 497, in _dispatch_request dispatcher.dispatch(req) File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.py", line 214, in dispatch resp = chosen_handler.process_request(req) File "/usr/local/lib/python2.7/dist-packages/TracWatchlistPlugin-1.0.1-py2.7.egg/tracwatchlist/plugin.py", line 612, in process_request wldict['datetime_format'] = datetime_format(locale=locale) File "/usr/local/lib/python2.7/dist-packages/TracWatchlistPlugin-1.0.1-py2.7.egg/tracwatchlist/util.py", line 201, in datetime_format time_format = unicode(get_time_format(format, locale)) File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 273, in get_time_format return Locale.parse(locale).time_formats[format]
comment:12 Changed 10 years ago by
Thanks I'll investigate. In the meantime, downgrading to babel 0.9.6 might help, but I can't say for certain.
comment:13 Changed 10 years ago by
Re 7: I uninstalled the plugin databases via the uninstall script. Then when I did the update all was okay. The plugin is running. Users will let me know if it is working.
Changed 10 years ago by
Attachment: | t10054-watchlistplugin-r14337.diff added |
---|
comment:14 follow-up: 16 Changed 10 years ago by
... File "/usr/local/lib/python2.7/dist-packages/TracWatchlistPlugin-1.0.1-py2.7.egg/tracwatchlist/util.py", line 201, in datetime_format time_format = unicode(get_time_format(format, locale)) File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 273, in get_time_format return Locale.parse(locale).time_formats[format]
That issue occurs if Trac 1.0 is installed before Babel. In the case, (translations unavailable) is shown for Babel in About page. Work around is to reinstall Trac 1.0 or upgrade to 1.0.1+. The issue doesn't occurs with Trac 1.0.1+.
Created patch: t10054-watchlistplugin-r14337.diff. If Trac is 1.0 and translations unavailable (Babel is installed), req.locale
returns None
. After the patch, LC_TIME
would be used if req.locale
is None
.
comment:15 Changed 10 years ago by
Well, I can't upgrade to 1.0.1 right now, maybe in the new year, but the patch worked for me so I'm happy to close this ticket.
Thanks
comment:16 Changed 10 years ago by
Replying to jun66j5:
Created patch: t10054-watchlistplugin-r14337.diff. If Trac is 1.0 and translations unavailable (Babel is installed),
req.locale
returnsNone
. After the patch,LC_TIME
would be used ifreq.locale
isNone
.
Please feel free to go ahead and apply the patch.
comment:18 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
The original issue remains (comment:2), that there isn't an upgrade path from earlier versions of the plugin. However, the plugin is unmaintained so I don't foresee anyone fixing that. PatchWelcome. It now works with 1.0 at least.
#11332 may be a duplicate.