Modify

Opened 3 years ago

Last modified 4 weeks ago

#10054 new defect

Upgrade database error 0.5 to 1.0

Reported by: paul.jendrowski@… Owned by: martin_s
Priority: normal Component: WatchlistPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description (last modified by rjollos)

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)

t10054-watchlistplugin-r14337.diff (1.5 KB) - added by jun66j5 6 weeks ago.

Download all attachments as: .zip

Change History (18)

comment:1 Changed 16 months ago by rjollos

  • Description modified (diff)

#11332 may be a duplicate.

comment:2 Changed 6 months ago by paul.jendrowski@…

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:3 Changed 6 weeks ago by rjollos

#11332 closed as a duplicate.

comment:4 Changed 6 weeks ago by paresh138@…

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 6 weeks ago by rjollos

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.

Last edited 6 weeks ago by rjollos (previous) (diff)

comment:6 Changed 6 weeks ago by rjollos

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 6 weeks ago by roger.oberholtzer@…

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 6 weeks ago by rjollos

Nothing has been done yet to address the upgade issue reported in this ticket. However the plugin should work fine for new installations.

Last edited 6 weeks ago by rjollos (previous) (diff)

comment:9 follow-up: Changed 6 weeks ago by paresh138@…

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:10 Changed 6 weeks ago by rjollos

What version of babel are you using?

comment:11 Changed 6 weeks ago by paresh138@…

Babel v1.3

comment:12 Changed 6 weeks ago by rjollos

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 6 weeks ago by roger.oberholtzer@…

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 6 weeks ago by jun66j5

comment:14 in reply to: ↑ 9 ; follow-up: Changed 6 weeks ago by jun66j5

...
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 6 weeks ago by anonymous

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 in reply to: ↑ 14 Changed 5 weeks ago by rjollos

Replying to jun66j5:

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.

Please feel free to go ahead and apply the patch.

comment:17 Changed 4 weeks ago by jun66j5

In 14353:

1.0.1: fixed an AttributeError when Trac has unavailable translations and Babel is installed (refs #10054)

Add Comment

Modify Ticket

Action
as new The owner will remain martin_s.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.