- Posts: 25
- Thank you received: 2
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Manual method for moving survey to another database
- Mike1985_2
- Topic Author
- Offline
- Junior Member
Less
More
10 years 5 months ago #101610
by Mike1985_2
Manual method for moving survey to another database was created by Mike1985_2
I have LimeSurvey 1.90 installed on two servers and I want to be able to copy a survey from one to the other without using the admin system to import or export.
How risky is it and what table do I need to consider??
Obviously I will need to copy `survey_xxxxx`, `tokens_xxxxx`, a row from `surveys` and a row from `surveys_languagesettings`. I suppose I will have to copy over the `conditions`, `questions` and `answers` as well. (Sorry I'm basically answering my on question here).
Will indexing and id's become an issue?
How risky is it and what table do I need to consider??
Obviously I will need to copy `survey_xxxxx`, `tokens_xxxxx`, a row from `surveys` and a row from `surveys_languagesettings`. I suppose I will have to copy over the `conditions`, `questions` and `answers` as well. (Sorry I'm basically answering my on question here).
Will indexing and id's become an issue?
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
10 years 5 months ago - 10 years 5 months ago #101612
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Manual method for moving survey to another database
Is your 2nd installation (for import) new?
Pure curiosity: Why not?...without using the admin system to import or export.
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last edit: 10 years 5 months ago by Ben_V.
The topic has been locked.
- Mike1985_2
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 25
- Thank you received: 2
10 years 5 months ago #101615
by Mike1985_2
Replied by Mike1985_2 on topic Manual method for moving survey to another database
Nothing more than inter-office politics! It's as sad as that.
They're both at 1.90 and are both already installed. It's looking like every single table needs partially copying here.
How about this.. Can I export the survey (using the admin system or whatever) as SQL? Just one time so I can unpick it and understand and consider everything that is needed? At the moment, the export is an XML file which I don't really understand..
They're both at 1.90 and are both already installed. It's looking like every single table needs partially copying here.
How about this.. Can I export the survey (using the admin system or whatever) as SQL? Just one time so I can unpick it and understand and consider everything that is needed? At the moment, the export is an XML file which I don't really understand..
The following user(s) said Thank You: ciphr
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
10 years 5 months ago #101616
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Manual method for moving survey to another database
Theoretically you can update a database using PhpMyAdmin or similar interface...
In your case it sounds that you will get lots of trouble with groups & question IDs...
Note that you can change (everywhere) without problem the survey ID directly in your (xml) export/import file.
I hope another LS user may give you some good advices, because I can't personnaly encourage you to apply this process
In your case it sounds that you will get lots of trouble with groups & question IDs...
Note that you can change (everywhere) without problem the survey ID directly in your (xml) export/import file.
I hope another LS user may give you some good advices, because I can't personnaly encourage you to apply this process
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
- c_schmitz
- Offline
- LimeSurvey GmbH Employee
Less
More
- Posts: 301
- Thank you received: 84
10 years 5 months ago #101621
by c_schmitz
Best regards
Carsten Schmitz
LimeSurvey project leader
Replied by c_schmitz on topic Manual method for moving survey to another database
TBH I don't see a viable solution here.
Best regards
Carsten Schmitz
LimeSurvey project leader
The topic has been locked.
- Mike1985_2
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 25
- Thank you received: 2
9 years 10 months ago - 8 years 10 months ago #109649
by Mike1985_2
Replied by Mike1985_2 on topic Manual method for moving survey to another database
Update...
In case anyone is interested. I have been working with this for a while now. I am essentailly sending the following SQL commands to a .sql file;
I also ran this string replace to stop "TABLE ALREADY EXISTS" error
And these SQL lines to prevent ID clashing
This is probably of no interest to anyone but you never know...
In case anyone is interested. I have been working with this for a while now. I am essentailly sending the following SQL commands to a .sql file;
Code:
CREATE TABLE temp.`surveys` AS (SELECT * FROM limeSurvey.`surveys` WHERE `sid` = '$sid'); CREATE TABLE temp.`surveys_languagesettings` AS (SELECT * FROM limeSurvey.`surveys_languagesettings` WHERE `surveyls_survey_id` = '$sid'); CREATE TABLE temp.`surveys_rights` AS (SELECT * FROM limeSurvey.`surveys_rights` WHERE `sid` = '$sid'); CREATE TABLE temp.`groups` AS (SELECT * FROM limeSurvey.`groups` WHERE `sid` = '$sid'); CREATE TABLE temp.`questions` AS (SELECT * FROM limeSurvey.`questions` WHERE `sid` = '$sid'); CREATE TABLE temp.`assessments` AS (SELECT * FROM limeSurvey.`assessments` WHERE `sid` = '$sid'); CREATE TABLE temp.`answers` AS (SELECT t2.* FROM limeSurvey.`questions` as t1 LEFT JOIN limeSurvey.`answers` as t2 ON t1.`qid` = t2.`qid` WHERE t1.`sid` = '$sid' AND t2.`qid` IS NOT NULL); CREATE TABLE temp.`conditions` AS (SELECT t2.* FROM limeSurvey.`questions` as t1 LEFT JOIN limeSurvey.`conditions` as t2 ON t1.`qid` = t2.`qid` WHERE t1.`sid` = '$sid' AND t2.`qid` IS NOT NULL); CREATE TABLE temp.`question_attributes` AS (SELECT t2.* FROM limeSurvey.`questions` as t1 LEFT JOIN limeSurvey.`question_attributes` as t2 ON t1.`qid` = t2.`qid` WHERE t1.`sid` = '$sid' AND t2.`qid` IS NOT NULL); CREATE TABLE temp.`tokens_$sid` AS (SELECT * FROM limeSurvey.`tokens_$sid`); CREATE TABLE temp.`survey_$sid` LIKE limeSurvey.`survey_$sid`
I also ran this string replace to stop "TABLE ALREADY EXISTS" error
Code:
$file_contents = str_replace("CREATE TABLE","CREATE TABLE IF NOT EXISTS",$file_contents);
And these SQL lines to prevent ID clashing
Code:
ALTER TABLE `tokens_'.$sid.'` ADD PRIMARY KEY ( `tid` ); ALTER TABLE `tokens_'.$sid.'` ADD INDEX `tokens_'.$sid.'_idx` ( `token` ); ALTER TABLE `tokens_'.$sid.'` CHANGE `tid` `tid` INT( 11 ) NOT NULL AUTO_INCREMENT; ALTER TABLE `survey_'.$sid.'` CHANGE `id` `id` INT( 11 ) NOT NULL AUTO_INCREMENT;
This is probably of no interest to anyone but you never know...
Last edit: 8 years 10 months ago by c_schmitz.
The following user(s) said Thank You: ciphr
The topic has been locked.