Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Import from deactivated survey table shows old but not latest table

More
3 weeks 1 day ago #273381 by marce1
Your LimeSurvey version: LimeSurvey Community Edition Version 6.16.1+251125 
Own server or LimeSurvey hosting: own server
==================
I deactivated a survey to update its structure. My standard procedure is: Deactivate, make changes, reactivate, import from old survey table. That's what I did this time, too. I added 3 sub-questions (answer options), something that did work in the past without issues and should not change the table structure in a unrecoverable way.
But this time, when I reactivate the survey, and want to import the just deactivated old table responses, it does not show them. Strangely, it shows even older table responses for me to import. 

What can I do to restore my latest responses?
The MySQL files (including timestamps) exist for the latest deactivated table with the correct timestamp, and the filesize indicates the answers are there. 
Can I somehow directly in SQL copy from the latest deactivated table to the current one? Or would it be better to take an in-between step of CSV format?

Please Log in to join the conversation.

More
3 weeks 14 hours ago - 3 weeks 14 hours ago #273384 by marce1
I found a solution on database level:

1) Get the columns from the old table to build the query: 
Code:
SELECT GROUP_CONCAT(COLUMN_NAME ORDER BY ORDINAL_POSITION SEPARATOR ', ')
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = 'limesurvey'
      AND TABLE_NAME = 'old_survey_$ID_$TIMESTAMP';

2) Use these columns for the import statement:
Code:
INSERT INTO survey_$ID ($col_list) SELECT $col_list FROM old_survey_$ID_$TIMESTAMP; 
Last edit: 3 weeks 14 hours ago by marce1. Reason: ; missing

Please Log in to join the conversation.

More
3 weeks 13 hours ago - 3 weeks 13 hours ago #273385 by marce1
I just did the following test: (after successfully importing the old answers with the mysql command above), I deactived the survey again, reactivated it (without any changes to the survey structure) – and again the last and second to last deactivated survey table responses are not being shown to import. So there seems to be a bug in the import function?
Last edit: 3 weeks 13 hours ago by marce1. Reason: clarification

Please Log in to join the conversation.

More
2 weeks 6 days ago #273391 by holch
If you think it is a bug, please make a bug report at bugs.limesurvey.org

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose