On Wednesday, December 31, 2014 12:29:11 PM UTC-8, Greg Earle wrote: > > On Dec 31, 2014, at 10:14 AM, Ryan Ollos wrote: > > > > The 4 "59b" attachments were from the old "Design" wiki attachment > directory > > > the "f09" PNG file is from the "WikiStart" wiki attachment directory. > (The > > > ones that no longer exist in the 'new' Project after "trac-admin > upgrade" > > > was run.) > > > > The only reason it should skip those files is if they aren't referenced > in the attachments table. Could you print out the contents of the table? > If using SQLite and you have the sqlite3 command line tool installed, it's > simply: > > > > $ sqlite3 tracdev/db/trac.db > > sqlite> SELECT type,id,filename FROM attachment; > > > > Also useful would be: > > sqlite> SELECT value FROM system WHERE name='database_version'; > > Thanks Ryan. Here is the 'sqlite3' output. > > Old database: > > [root@newtracserver projects.stride]# sqlite3 test_project/db/trac.db > SQLite version 3.6.20 > Enter ".help" for instructions > Enter SQL statements terminated with a ";" > sqlite> SELECT type,id,filename FROM attachment; > wiki|Design|test_project.graffle > wiki|Design|test_project Data Rates 2013-09-16.xlsx > wiki|Design|test_project telem.xls > wiki|Design|test_project-design-datamgmt.graffle > wiki|WikiStart|Screen Shot 2014-12-18 at 10.15.49 AM.png > > sqlite> SELECT value FROM system WHERE name='database_version'; > 26 > sqlite> ^D > > New database: > > [root@newtracserver projects.stride]# cd ../projects > [root@newtracserver projects]# sqlite3 test_project/db/trac.db > SQLite version 3.6.20 > Enter ".help" for instructions > Enter SQL statements terminated with a ";" > sqlite> SELECT type,id,filename FROM attachment; > wiki|Design|test_project.graffle > wiki|Design|test_project Data Rates 2013-09-16.xlsx > wiki|Design|test_project telem.xls > wiki|Design|test_project-design-datamgmt.graffle > wiki|WikiStart|Screen Shot 2014-12-18 at 10.15.49 AM.png > > sqlite> SELECT value FROM system WHERE name='database_version'; > 29 > > So, this would bear out what you said about them not being referenced. > > But then I noticed this: > > [root@newtracserver projects]# strings - test_project/db/trac.db | egrep > RFAForm\|RFA_ > [[Image(RFA_doc.png)]] > [[Image(RFA_ticket.png)]] > Use [attachment:RFAForm.doc] or [wiki:PeerReviews/PeerReviewsHelp#rfas > Create Trac RFA Tickets] > > Clearly there are references to these files (which only exist in the > attachments/wiki tree) inside the database; even if they are not "in > the database" if you know what I mean. > > So I went to the "PeerReviews" page and I see two "paper clip" images. > > Hovering over them with the mouse shows links to the "missing PNG files > down at the bottom of the browser; but it also causes pop-ups saying > > No image "RFA_doc.png" attached to > PeerReviews/PeerReviewsHelp > > No image "RFA_ticket.png" attached to > PeerReviews/PeerReviewsHelp > > So obviously that explains the behavior I'm seeing. > > But now we have a problem; clearly in this Template page there is a > 'placeholder' for the attached image, but because it's not attached, > "trac-admin upgrade" won't drag it along for the ride. >
Do you know how the attachments were added to the environment in the first place? Did the user manually add them to the environment's attachments directory? If they were added through the web interface or using TracAdmin, then there should be an entry in the database. > So unless the user (who is on vacation right now, unfortunately) goes > back and attaches all of these images/docs (on 16 sets of Projects!), > they won't be available in the new 1.0.2 server environment to re-attach > them later. > You could script the operations so that the user doesn't have to manually insert the attachments to every environment. Before upgrading, you could write a short script to inspect the attachments directory and insert the attachment in the case that there is not a reference to the attachment in the database. From the directory structure prior to upgrading you know the parent realm, parent resource and resource id of each attachment. You can use that to construct a query to determine if there is an entry in the attachments table, then insert a row if the entry doesn't exist. You probably don't even need to write the queries yourself, you could just use the methods of the Attachment class: http://trac.edgewall.org/browser/tags/trac-1.0.2/trac/attachment.py#L121 Another way to script this is to move the existing file out of the attachments directory, and use the TracAdmin command line tool to attach it to the appropriate resource. This will create the entry in the attachments table and then put the attachment back into the directory. Maybe "trac-admin upgrade" could be given an option to migrate any > attachments that are not directly attached in the database? Kind > of a "Trust me, I know what I'm doing here" switch? > You could probably modify db28.py to do that, but I suspect it would be easier and better to fix the attachments table. -- You received this message because you are subscribed to the Google Groups "Trac Users" 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-users. For more options, visit https://groups.google.com/d/optout.
