diff --git a/backend/migrations/20240406031400_create_questions.sql b/backend/migrations/20240406031400_create_questions.sql index f9706333..bb7442bb 100644 --- a/backend/migrations/20240406031400_create_questions.sql +++ b/backend/migrations/20240406031400_create_questions.sql @@ -21,6 +21,7 @@ CREATE TABLE multi_option_question_options ( id BIGINT PRIMARY KEY, text TEXT NOT NULL, question_id BIGINT NOT NULL, + order INTEGER NOT NULL, CONSTRAINT FK_multi_option_question_options_questions FOREIGN KEY(question_id) REFERENCES questions(id) diff --git a/backend/server/src/models/question.rs b/backend/server/src/models/question.rs index 93870a90..f1a5a3cc 100644 --- a/backend/server/src/models/question.rs +++ b/backend/server/src/models/question.rs @@ -66,7 +66,7 @@ pub struct MultiOptionData { #[derive(Deserialize, Serialize)] pub struct MultiOptionQuestionOption { id: i32, - rank: i32, + order: i32, text: String, } @@ -95,11 +95,11 @@ impl QuestionData { | Self::DropDown(data) | Self::Ranking(data) => { let mut query_builder = - QueryBuilder::new("INSERT INTO multi_option_question_options (id, text, question_id, rank)"); + QueryBuilder::new("INSERT INTO multi_option_question_options (id, text, question_id, order)"); query_builder.push_values(data.options, |mut b, option| { let id = snowflake_generator.real_time_generate(); - b.push_bind(id).push_bind(option.text).push_bind(question_id).push_bind(option.rank); + b.push_bind(id).push_bind(option.text).push_bind(question_id).push_bind(option.order); }); let query = query_builder.build();