-------------------------------------------- Registartion --------------------------------------------

select setval('hdb_option_category_id_seq', (select max(id) from hdb_option_category));

INSERT INTO hdb_option_category (id, name, created_at, updated_at, deleted_at, created_by, updated_by) 
VALUES (nextval('hdb_option_category_id_seq'), 'Experiences', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, -2, -2);

    -- add question

select setval('hdb_question_id_seq', (select max(id) from hdb_question));

INSERT INTO hdb_question (id, label, config, stats, typ, created_at, updated_at, deleted_at, created_by, updated_by, form_section_id, answer_location, binding_key) 
VALUES (nextval('hdb_question_id_seq'), 'Which of the following have you experienced?', '{}', 'published', 'multiselect', CURRENT_TIMESTAMP, NULL, NULL, -2, -2, 4, NULL, 'whichOfTheFollowingHaveYouExperienced');

    -- add options

select setval('hdb_option_id_seq', (select max(id) from hdb_option));

INSERT INTO hdb_option (id, typ, category_id, created_at, updated_at, deleted_at, stats, created_by, updated_by, name) 
VALUES
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, '11 Ways 2016'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, '11 Ways 2017'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'Birth of infinitheism'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'EYES 2022'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'Entrainment 23'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'Entrainment 24'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'HDB'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'Holistic course'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'MSD'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'Mahatria''s Public Discourses'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'My Z Axis'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'PAP'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'R-TAT 2018'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'Sr. Citizen HDB'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'TAT 2014'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'TAT 2015'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'TAT 2019'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'TAT 2020 Online'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'TAT 2021 Online'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'TAT 2022 Online'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'TAT 2023'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'TAT 2024'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'aaaha'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'infini'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'infini11'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'infini14'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'infiniAcademy'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'infinidance'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'infinipath'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'infinipower'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'infinithoughts'),
(nextval('hdb_option_id_seq'), 'string', (select max(id) from hdb_option_category), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, 'published', -2, -2, 'infiniwaves');
;

    -- map question and options

select setval('hdb_question_option_map_id_seq', (select max(id) from hdb_question_option_map));

INSERT INTO hdb_question_option_map (id, question_id, option_id, created_at, updated_at, deleted_at, created_by, updated_by)
select 
    nextval('hdb_question_option_map_id_seq'), (select id from hdb_question where label = 'Which of the following have you experienced?'), id, current_timestamp, current_timestamp, NULL, -2, -2
from hdb_option where category_id = (select id from hdb_option_category where name = 'Experiences'); --32
