change attachment repository from FS to DB

Ask community to help.

Moderators: Amaradana, TurboPT, TL Developers

change attachment repository from FS to DB

Postby hlipp » Wed Jun 23, 2010 8:27 am

Hi!

We have been using Testlink 1.8 for a while and have already a nice list of Testcase, Plans,... created.

Now I found out that all attachments were stored in Filesystem instead of the Database.
I would prefer to store them in the DB to have everything within one db-backup.

I know I have to change config "$g_repositoryType = TL_REPOSITORY_TYPE_FS;" to "$g_repositoryType = TL_REPOSITORY_TYPE_DB;"
but what I have to do with the already existing files? is there a way to migrate them?
hlipp
TestLink user
 
Posts: 3
Joined: Thu Jun 17, 2010 12:07 pm

Re: change attachment repository from FS to DB

Postby fman » Wed Jun 23, 2010 9:58 am

there is no migration code provided by dev team.
You have to develop your own solution
fman
Member of TestLink Community
 
Posts: 3088
Joined: Tue Nov 15, 2005 7:19 am

Found the solution

Postby hlipp » Thu Jun 24, 2010 2:12 pm

Hi!

I am new in mySQL so it took me a while to get it working but now I'm finished.
If anyone have the same problem - here's is my step-by-step solution:

Step zero: backup your attachments Table and the Attachments Folder on your TL Server

Step one: change Testlink config File to save future attachments in DB
$g_repositoryType = TL_REPOSITORY_TYPE_DB;

Step two: DB user need rights for file access
GRANT FILE ON *.* TO $TestlinkDBUser@'localhost';

Following Test have to return the filecontent of a testfile:
select LOAD_FILE($Testfile);
If it's not working, check if your db user is allowed to read the file in the filesystem.

Step three: load files into attachments.content and remove path to filesystem
:arrow: Dont forget to concat the absolut path of the testlink installation to the relative filepath!
update attachments set content = LOAD_FILE(concat('/var/www/testlink/upload_area/',file_path)), file_path = null where content is null;

Step four: check in the same db session the attachment table if the files are there.
if everything seems OK => commit;

Step five: (re)move $TestlinkPath/upload_area/nodes_hierarchy

Step six: try in TestlinkGUI to download some migrated attachments

Step seven: create a new attachment: => check if it is created in DB and not on Filesystem

Finished. :D
hlipp
TestLink user
 
Posts: 3
Joined: Thu Jun 17, 2010 12:07 pm


Return to Installation and configuration



Who is online

Users browsing this forum: Google [Bot] and 4 guests