vlab-research / fly

The Fly Survey platform
Other
2 stars 3 forks source link

Print DB schema #82

Closed calufa closed 2 years ago

calufa commented 2 years ago

TODO:

netlify[bot] commented 2 years ago

✔️ Deploy Preview for vlab-research canceled.

🔨 Explore the source changes: fe50a8c24d78afa6d74e383fcf71220f5567e75f

🔍 Inspect the deploy log: https://app.netlify.com/sites/vlab-research/deploys/62044e3d0bdd590008fd0e6e

calufa commented 2 years ago

Executing ./dbschema.sh prints:

$ ./dbschema.sh            
Table: adopt_reports
+-------------+-------------+------------+---------------+----------------------+--------------------------------------------------------+----------+
|    NAME     |  DATATYPE   | ISNULLABLE | COLUMNDEFAULT | GENERATIONEXPRESSION |                        INDICES                         | ISHIDDEN |
+-------------+-------------+------------+---------------+----------------------+--------------------------------------------------------+----------+
| campaignid  | UUID        | false      | <nil>         |                      | [adopt_reports_auto_index_fk_campaignid_ref_campaigns] | false    |
+-------------+-------------+------------+---------------+----------------------+--------------------------------------------------------+----------+
| created     | TIMESTAMPTZ | false      | 0x40000201b0  |                      | []                                                     | false    |
+-------------+-------------+------------+---------------+----------------------+--------------------------------------------------------+----------+
| report_type | VARCHAR     | false      | <nil>         |                      | []                                                     | false    |
+-------------+-------------+------------+---------------+----------------------+--------------------------------------------------------+----------+
| details     | JSONB       | false      | <nil>         |                      | []                                                     | false    |
+-------------+-------------+------------+---------------+----------------------+--------------------------------------------------------+----------+
| rowid       | INT8        | false      | 0x40000201c0  |                      | [primary                                               | true     |
|             |             |            |               |                      | adopt_reports_auto_index_fk_campaignid_ref_campaigns]  |          |
+-------------+-------------+------------+---------------+----------------------+--------------------------------------------------------+----------+

Table: campaign_confs
+-------------+-------------+------------+---------------+----------------------+---------------------------------------------------+----------+
|    NAME     |  DATATYPE   | ISNULLABLE | COLUMNDEFAULT | GENERATIONEXPRESSION |                      INDICES                      | ISHIDDEN |
+-------------+-------------+------------+---------------+----------------------+---------------------------------------------------+----------+
| campaignid  | UUID        | false      | <nil>         |                      | [campaign_confs_campaignid_conf_type_created_idx] | false    |
+-------------+-------------+------------+---------------+----------------------+---------------------------------------------------+----------+
| created     | TIMESTAMPTZ | false      | 0x4000020200  |                      | [campaign_confs_campaignid_conf_type_created_idx] | false    |
+-------------+-------------+------------+---------------+----------------------+---------------------------------------------------+----------+
| conf_type   | VARCHAR     | false      | <nil>         |                      | [campaign_confs_campaignid_conf_type_created_idx] | false    |
+-------------+-------------+------------+---------------+----------------------+---------------------------------------------------+----------+
| entity_name | VARCHAR     | true       | <nil>         |                      | [campaign_confs_campaignid_conf_type_created_idx] | false    |
+-------------+-------------+------------+---------------+----------------------+---------------------------------------------------+----------+
| conf        | JSONB       | false      | <nil>         |                      | [campaign_confs_campaignid_conf_type_created_idx] | false    |
+-------------+-------------+------------+---------------+----------------------+---------------------------------------------------+----------+
| rowid       | INT8        | false      | 0x4000020250  |                      | [primary                                          | true     |
|             |             |            |               |                      | campaign_confs_campaignid_conf_type_created_idx]  |          |
+-------------+-------------+------------+---------------+----------------------+---------------------------------------------------+----------+

Table: campaigns
+---------+-------------+------------+---------------+----------------------+--------------------------------+----------+
|  NAME   |  DATATYPE   | ISNULLABLE | COLUMNDEFAULT | GENERATIONEXPRESSION |            INDICES             | ISHIDDEN |
+---------+-------------+------------+---------------+----------------------+--------------------------------+----------+
| id      | UUID        | false      | 0x4000020280  |                      | [primary                       | false    |
|         |             |            |               |                      | campaigns_userid_name_key]     |          |
+---------+-------------+------------+---------------+----------------------+--------------------------------+----------+
| userid  | UUID        | false      | <nil>         |                      | [campaigns_userid_name_key]    | false    |
+---------+-------------+------------+---------------+----------------------+--------------------------------+----------+
| created | TIMESTAMPTZ | false      | 0x40000202a0  |                      | []                             | false    |
+---------+-------------+------------+---------------+----------------------+--------------------------------+----------+
| name    | VARCHAR     | false      | <nil>         |                      | [campaigns_userid_name_key]    | false    |
+---------+-------------+------------+---------------+----------------------+--------------------------------+----------+
| active  | BOOL        | false      | 0x40000202c0  |                      | []                             | false    |
+---------+-------------+------------+---------------+----------------------+--------------------------------+----------+

Table: credentials
+------------------+-------------+------------+---------------+--------------------------------+---------------------------------------------+----------+
|       NAME       |  DATATYPE   | ISNULLABLE | COLUMNDEFAULT |      GENERATIONEXPRESSION      |                   INDICES                   | ISHIDDEN |
+------------------+-------------+------------+---------------+--------------------------------+---------------------------------------------+----------+
| userid           | UUID        | false      | <nil>         |                                | [credentials_facebook_page_id_idx           | false    |
|                  |             |            |               |                                | credentials_userid_entity_key_created_idx]  |          |
+------------------+-------------+------------+---------------+--------------------------------+---------------------------------------------+----------+
| entity           | VARCHAR     | false      | <nil>         |                                | [credentials_userid_entity_key_created_idx  | false    |
|                  |             |            |               |                                | credentials_entity_key_key]                 |          |
+------------------+-------------+------------+---------------+--------------------------------+---------------------------------------------+----------+
| key              | VARCHAR     | false      | <nil>         |                                | [credentials_facebook_page_id_idx           | false    |
|                  |             |            |               |                                | credentials_entity_key_key                  |          |
|                  |             |            |               |                                | credentials_userid_entity_key_created_idx]  |          |
+------------------+-------------+------------+---------------+--------------------------------+---------------------------------------------+----------+
| created          | TIMESTAMPTZ | false      | 0x40000202f0  |                                | [credentials_userid_entity_key_created_idx] | false    |
+------------------+-------------+------------+---------------+--------------------------------+---------------------------------------------+----------+
| details          | JSONB       | false      | <nil>         |                                | [credentials_facebook_page_id_idx           | false    |
|                  |             |            |               |                                | credentials_userid_entity_key_created_idx]  |          |
+------------------+-------------+------------+---------------+--------------------------------+---------------------------------------------+----------+
| rowid            | INT8        | false      | 0x4000020310  |                                | [primary credentials_entity_key_key         | true     |
|                  |             |            |               |                                | credentials_userid_entity_key_created_idx   |          |
|                  |             |            |               |                                | unique_facebook_page                        |          |
|                  |             |            |               |                                | credentials_facebook_page_id_idx]           |          |
+------------------+-------------+------------+---------------+--------------------------------+---------------------------------------------+----------+
| facebook_page_id | VARCHAR     | true       | <nil>         | CASE WHEN entity =             | [unique_facebook_page                       | false    |
|                  |             |            |               | 'facebook_page' THEN           | credentials_facebook_page_id_idx]           |          |
|                  |             |            |               | details->>'id' ELSE NULL END   |                                             |          |
+------------------+-------------+------------+---------------+--------------------------------+---------------------------------------------+----------+

Table: messages
+-----------+-------------+------------+---------------+----------------------+--------------------------------+----------+
|   NAME    |  DATATYPE   | ISNULLABLE | COLUMNDEFAULT | GENERATIONEXPRESSION |            INDICES             | ISHIDDEN |
+-----------+-------------+------------+---------------+----------------------+--------------------------------+----------+
| id        | INT8        | true       | <nil>         |                      | []                             | false    |
+-----------+-------------+------------+---------------+----------------------+--------------------------------+----------+
| content   | VARCHAR     | false      | <nil>         |                      | [messages_userid_idx           | false    |
|           |             |            |               |                      | messages_userid_timestamp_idx  |          |
|           |             |            |               |                      | messages_timestamp_idx]        |          |
+-----------+-------------+------------+---------------+----------------------+--------------------------------+----------+
| userid    | VARCHAR     | false      | <nil>         |                      | [primary messages_userid_idx   | false    |
|           |             |            |               |                      | messages_userid_timestamp_idx  |          |
|           |             |            |               |                      | messages_timestamp_idx]        |          |
+-----------+-------------+------------+---------------+----------------------+--------------------------------+----------+
| timestamp | TIMESTAMPTZ | false      | <nil>         |                      | [messages_userid_idx           | false    |
|           |             |            |               |                      | messages_userid_timestamp_idx  |          |
|           |             |            |               |                      | messages_timestamp_idx]        |          |
+-----------+-------------+------------+---------------+----------------------+--------------------------------+----------+
| hsh       | INT8        | false      | <nil>         | fnv64a(content)      | [primary messages_userid_idx   | false    |
|           |             |            |               |                      | messages_userid_timestamp_idx  |          |
|           |             |            |               |                      | messages_timestamp_idx]        |          |
+-----------+-------------+------------+---------------+----------------------+--------------------------------+----------+

Table: responses
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
|        NAME         |  DATATYPE   | ISNULLABLE | COLUMNDEFAULT |  GENERATIONEXPRESSION  |                              INDICES                               | ISHIDDEN |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| parent_surveyid     | UUID        | true       | <nil>         |                        | [responses_auto_index_fk_parent_surveyid_ref_surveys               | false    |
|                     |             |            |               |                        | responses_surveyid_userid_timestamp_question_ref_idx]              |          |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| parent_shortcode    | VARCHAR     | false      | <nil>         |                        | [responses_surveyid_userid_timestamp_question_ref_idx]             | false    |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| surveyid            | UUID        | false      | <nil>         |                        | [responses_auto_index_fk_surveyid_ref_surveys                      | false    |
|                     |             |            |               |                        | responses_surveyid_userid_timestamp_question_ref_idx]              |          |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| shortcode           | VARCHAR     | false      | <nil>         |                        | [responses_shortcode_question_ref_response_clusterid_timestamp_idx | false    |
|                     |             |            |               |                        | responses_surveyid_userid_timestamp_question_ref_idx]              |          |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| flowid              | INT8        | false      | <nil>         |                        | [responses_surveyid_userid_timestamp_question_ref_idx]             | false    |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| userid              | VARCHAR     | false      | <nil>         |                        | [responses_surveyid_userid_timestamp_question_ref_idx              | false    |
|                     |             |            |               |                        | primary responses_auto_index_fk_surveyid_ref_surveys               |          |
|                     |             |            |               |                        | responses_metadata_idx                                             |          |
|                     |             |            |               |                        | responses_shortcode_question_ref_response_clusterid_timestamp_idx  |          |
|                     |             |            |               |                        | responses_auto_index_fk_parent_surveyid_ref_surveys]               |          |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| question_ref        | VARCHAR     | false      | <nil>         |                        | [primary responses_auto_index_fk_parent_surveyid_ref_surveys       | false    |
|                     |             |            |               |                        | responses_auto_index_fk_surveyid_ref_surveys                       |          |
|                     |             |            |               |                        | responses_metadata_idx                                             |          |
|                     |             |            |               |                        | responses_surveyid_userid_timestamp_question_ref_idx               |          |
|                     |             |            |               |                        | responses_shortcode_question_ref_response_clusterid_timestamp_idx] |          |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| question_idx        | INT8        | false      | <nil>         |                        | [responses_surveyid_userid_timestamp_question_ref_idx]             | false    |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| question_text       | VARCHAR     | false      | <nil>         |                        | [responses_surveyid_userid_timestamp_question_ref_idx]             | false    |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| response            | VARCHAR     | false      | <nil>         |                        | [responses_surveyid_userid_timestamp_question_ref_idx              | false    |
|                     |             |            |               |                        | responses_shortcode_question_ref_response_clusterid_timestamp_idx] |          |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| seed                | INT8        | false      | <nil>         |                        | [responses_surveyid_userid_timestamp_question_ref_idx]             | false    |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| timestamp           | TIMESTAMPTZ | false      | <nil>         |                        | [responses_surveyid_userid_timestamp_question_ref_idx              | false    |
|                     |             |            |               |                        | primary responses_auto_index_fk_parent_surveyid_ref_surveys        |          |
|                     |             |            |               |                        | responses_auto_index_fk_surveyid_ref_surveys                       |          |
|                     |             |            |               |                        | responses_shortcode_question_ref_response_clusterid_timestamp_idx  |          |
|                     |             |            |               |                        | responses_metadata_idx]                                            |          |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| metadata            | JSONB       | true       | <nil>         |                        | [responses_metadata_idx                                            | false    |
|                     |             |            |               |                        | responses_surveyid_userid_timestamp_question_ref_idx]              |          |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| pageid              | VARCHAR     | true       | <nil>         |                        | [responses_surveyid_userid_timestamp_question_ref_idx]             | false    |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| clusterid           | VARCHAR     | true       | <nil>         | metadata->>'clusterid' | [responses_shortcode_question_ref_response_clusterid_timestamp_idx | false    |
|                     |             |            |               |                        | responses_surveyid_userid_timestamp_question_ref_idx]              |          |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+
| translated_response | VARCHAR     | true       | <nil>         |                        | [responses_surveyid_userid_timestamp_question_ref_idx]             | false    |
+---------------------+-------------+------------+---------------+------------------------+--------------------------------------------------------------------+----------+

Table: states
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
|         NAME         |  DATATYPE   | ISNULLABLE | COLUMNDEFAULT |                    GENERATIONEXPRESSION                    |                                           INDICES                                           | ISHIDDEN |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| userid               | VARCHAR     | false      | <nil>         |                                                            | [primary states_current_state_updated_idx states_auto_index_fk_pageid_ref_facebook_pages    | false    |
|                      |             |            |               |                                                            | states_current_state_fb_error_code_idx states_state_json_idx                                |          |
|                      |             |            |               |                                                            | states_current_state_current_form_updated_idx                                               |          |
|                      |             |            |               |                                                            | states_previous_with_token_previous_is_followup_form_start_time_current_state_updated_idx   |          |
|                      |             |            |               |                                                            | states_error_tag_current_state_current_form_updated_idx                                     |          |
|                      |             |            |               |                                                            | states_stuck_on_question_current_state_current_form_updated_idx                             |          |
|                      |             |            |               |                                                            | states_current_state_timeout_date_idx                                                       |          |
|                      |             |            |               |                                                            | states_current_state_error_tag_updated_next_retry_idx                                       |          |
|                      |             |            |               |                                                            | states_current_state_fb_error_code_updated_next_retry_idx]                                  |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| pageid               | VARCHAR     | false      | <nil>         |                                                            | [states_current_state_error_tag_updated_next_retry_idx                                      | false    |
|                      |             |            |               |                                                            | states_current_state_updated_idx states_auto_index_fk_pageid_ref_facebook_pages             |          |
|                      |             |            |               |                                                            | primary states_state_json_idx states_current_state_current_form_updated_idx                 |          |
|                      |             |            |               |                                                            | states_previous_with_token_previous_is_followup_form_start_time_current_state_updated_idx   |          |
|                      |             |            |               |                                                            | states_error_tag_current_state_current_form_updated_idx                                     |          |
|                      |             |            |               |                                                            | states_stuck_on_question_current_state_current_form_updated_idx                             |          |
|                      |             |            |               |                                                            | states_current_state_timeout_date_idx states_current_state_fb_error_code_idx                |          |
|                      |             |            |               |                                                            | states_current_state_fb_error_code_updated_next_retry_idx]                                  |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| updated              | TIMESTAMPTZ | false      | <nil>         |                                                            | [states_current_state_updated_idx states_current_state_current_form_updated_idx             | false    |
|                      |             |            |               |                                                            | states_previous_with_token_previous_is_followup_form_start_time_current_state_updated_idx   |          |
|                      |             |            |               |                                                            | states_error_tag_current_state_current_form_updated_idx                                     |          |
|                      |             |            |               |                                                            | states_stuck_on_question_current_state_current_form_updated_idx                             |          |
|                      |             |            |               |                                                            | states_current_state_fb_error_code_updated_next_retry_idx                                   |          |
|                      |             |            |               |                                                            | states_current_state_error_tag_updated_next_retry_idx]                                      |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| current_state        | VARCHAR     | false      | <nil>         |                                                            | [states_current_state_fb_error_code_updated_next_retry_idx                                  | false    |
|                      |             |            |               |                                                            | states_current_state_fb_error_code_idx states_current_state_current_form_updated_idx        |          |
|                      |             |            |               |                                                            | states_previous_with_token_previous_is_followup_form_start_time_current_state_updated_idx   |          |
|                      |             |            |               |                                                            | states_error_tag_current_state_current_form_updated_idx                                     |          |
|                      |             |            |               |                                                            | states_stuck_on_question_current_state_current_form_updated_idx                             |          |
|                      |             |            |               |                                                            | states_current_state_timeout_date_idx                                                       |          |
|                      |             |            |               |                                                            | states_current_state_error_tag_updated_next_retry_idx states_current_state_updated_idx]     |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| state_json           | JSONB       | false      | <nil>         |                                                            | [states_current_state_fb_error_code_idx states_state_json_idx                               | false    |
|                      |             |            |               |                                                            | states_previous_with_token_previous_is_followup_form_start_time_current_state_updated_idx   |          |
|                      |             |            |               |                                                            | states_current_state_timeout_date_idx]                                                      |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| fb_error_code        | VARCHAR     | true       | <nil>         | (state_json->'error')->>'code'                             | [states_current_state_fb_error_code_updated_next_retry_idx                                  | false    |
|                      |             |            |               |                                                            | states_current_state_fb_error_code_idx]                                                     |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| current_form         | VARCHAR     | true       | <nil>         | (state_json->'forms')->>-1                                 | [states_current_state_current_form_updated_idx                                              | false    |
|                      |             |            |               |                                                            | states_error_tag_current_state_current_form_updated_idx                                     |          |
|                      |             |            |               |                                                            | states_stuck_on_question_current_state_current_form_updated_idx]                            |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| previous_is_followup | BOOL        | true       | <nil>         | ((state_json->'previousOutput')->>'followUp')              | [states_previous_with_token_previous_is_followup_form_start_time_current_state_updated_idx] | false    |
|                      |             |            |               | IS NOT NULL                                                |                                                                                             |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| previous_with_token  | BOOL        | true       | <nil>         | ((state_json->'previousOutput')->>'token')                 | [states_previous_with_token_previous_is_followup_form_start_time_current_state_updated_idx] | false    |
|                      |             |            |               | IS NOT NULL                                                |                                                                                             |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| form_start_time      | TIMESTAMPTZ | true       | <nil>         | ceiling(((state_json->'md')->>'startTime')::INT8           | [states_previous_with_token_previous_is_followup_form_start_time_current_state_updated_idx] | false    |
|                      |             |            |               | / 1000)::INT8::TIMESTAMPTZ                                 |                                                                                             |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| error_tag            | VARCHAR     | true       | <nil>         | (state_json->'error')->>'tag'                              | [states_error_tag_current_state_current_form_updated_idx                                    | false    |
|                      |             |            |               |                                                            | states_current_state_error_tag_updated_next_retry_idx]                                      |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| stuck_on_question    | VARCHAR     | true       | <nil>         | CASE WHEN                                                  | [states_stuck_on_question_current_state_current_form_updated_idx]                           | false    |
|                      |             |            |               | ((((state_json->'qa')->-1)->>0)                            |                                                                                             |          |
|                      |             |            |               | =                                                          |                                                                                             |          |
|                      |             |            |               | (((state_json->'qa')->-2)->>0))                            |                                                                                             |          |
|                      |             |            |               | AND                                                        |                                                                                             |          |
|                      |             |            |               | ((((state_json->'qa')->-2)->>0)                            |                                                                                             |          |
|                      |             |            |               | =                                                          |                                                                                             |          |
|                      |             |            |               | (((state_json->'qa')->-3)->>0))                            |                                                                                             |          |
|                      |             |            |               | THEN                                                       |                                                                                             |          |
|                      |             |            |               | ((state_json->'qa')->-1)->>0                               |                                                                                             |          |
|                      |             |            |               | ELSE NULL END                                              |                                                                                             |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| timeout_date         | TIMESTAMPTZ | true       | <nil>         | CASE WHEN (((state_json->'wait')->>'type') = 'timeout')    | [states_current_state_timeout_date_idx]                                                     | false    |
|                      |             |            |               | AND ((((state_json->'wait')->'value')->>'type')            |                                                                                             |          |
|                      |             |            |               | = 'absolute') THEN                                         |                                                                                             |          |
|                      |             |            |               | (((state_json->'wait')->'value')->>'timeout')::TIMESTAMPTZ |                                                                                             |          |
|                      |             |            |               | WHEN (((state_json->'wait')->>'type') = 'timeout')         |                                                                                             |          |
|                      |             |            |               | AND ((((state_json->'wait')->'value')->>'type') =          |                                                                                             |          |
|                      |             |            |               | 'relative') THEN (ceiling((state_json->>'waitStart')::INT8 |                                                                                             |          |
|                      |             |            |               | / 1000)::INT8::TIMESTAMPTZ +                               |                                                                                             |          |
|                      |             |            |               | (((state_json->'wait')->'value')->>'timeout')::INTERVAL)   |                                                                                             |          |
|                      |             |            |               | WHEN ((state_json->'wait')->>'type') = 'timeout'           |                                                                                             |          |
|                      |             |            |               | THEN (ceiling((state_json->>'waitStart')::INT8             |                                                                                             |          |
|                      |             |            |               | / 1000)::INT8::TIMESTAMPTZ +                               |                                                                                             |          |
|                      |             |            |               | ((state_json->'wait')->>'value')::INTERVAL) ELSE NULL END  |                                                                                             |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+
| next_retry           | TIMESTAMP   | true       | <nil>         | (floor(((power(2, (CASE WHEN                               | [states_current_state_fb_error_code_updated_next_retry_idx                                  | false    |
|                      |             |            |               | json_array_length(state_json->'retries')                   | states_current_state_error_tag_updated_next_retry_idx]                                      |          |
|                      |             |            |               | <= 16 THEN                                                 |                                                                                             |          |
|                      |             |            |               | json_array_length(state_json->'retries')                   |                                                                                             |          |
|                      |             |            |               | ELSE 16 END)) * 60000) +                                   |                                                                                             |          |
|                      |             |            |               | ((state_json->'retries')->>-1)::INT8)::INT8)               |                                                                                             |          |
|                      |             |            |               | / 1000)::INT8::TIMESTAMP                                   |                                                                                             |          |
+----------------------+-------------+------------+---------------+------------------------------------------------------------+---------------------------------------------------------------------------------------------+----------+

Table: surveys
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
|       NAME       |  DATATYPE   | ISNULLABLE | COLUMNDEFAULT |              GENERATIONEXPRESSION              |                       INDICES                       | ISHIDDEN |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| id               | UUID        | false      | 0x4000020460  |                                                | [primary surveys_auto_index_fk_userid_ref_users     | false    |
|                  |             |            |               |                                                | surveys_shortcode_userid_created_idx                |          |
|                  |             |            |               |                                                | surveys_has_followup_shortcode_userid_created_idx]  |          |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| created          | TIMESTAMPTZ | false      | <nil>         |                                                | [surveys_shortcode_userid_created_idx               | false    |
|                  |             |            |               |                                                | surveys_has_followup_shortcode_userid_created_idx]  |          |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| formid           | VARCHAR     | false      | <nil>         |                                                | [surveys_shortcode_userid_created_idx]              | false    |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| form             | VARCHAR     | false      | <nil>         |                                                | [surveys_shortcode_userid_created_idx]              | false    |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| messages         | VARCHAR     | true       | <nil>         |                                                | [surveys_shortcode_userid_created_idx]              | false    |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| shortcode        | VARCHAR     | false      | <nil>         |                                                | [surveys_shortcode_userid_created_idx               | false    |
|                  |             |            |               |                                                | surveys_has_followup_shortcode_userid_created_idx]  |          |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| title            | VARCHAR     | false      | <nil>         |                                                | [surveys_shortcode_userid_created_idx]              | false    |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| userid           | UUID        | false      | <nil>         |                                                | [surveys_auto_index_fk_userid_ref_users             | false    |
|                  |             |            |               |                                                | surveys_shortcode_userid_created_idx                |          |
|                  |             |            |               |                                                | surveys_has_followup_shortcode_userid_created_idx]  |          |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| form_json        | JSONB       | true       | <nil>         | form::JSONB                                    | [surveys_shortcode_userid_created_idx]              | false    |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| messages_json    | JSONB       | true       | <nil>         | messages::JSONB                                | []                                                  | false    |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| has_followup     | BOOL        | true       | <nil>         | (messages::JSONB->>'label.buttonHint.default') | [surveys_has_followup_shortcode_userid_created_idx] | false    |
|                  |             |            |               | IS NOT NULL                                    |                                                     |          |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| metadata         | JSONB       | false      | 0x40000204d0  |                                                | []                                                  | false    |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| survey_name      | VARCHAR     | false      | 0x40000204e0  |                                                | []                                                  | false    |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+
| translation_conf | JSONB       | false      | 0x40000204f0  |                                                | []                                                  | false    |
+------------------+-------------+------------+---------------+------------------------------------------------+-----------------------------------------------------+----------+

Table: users
+-------+----------+------------+---------------+----------------------+---------------------------+----------+
| NAME  | DATATYPE | ISNULLABLE | COLUMNDEFAULT | GENERATIONEXPRESSION |          INDICES          | ISHIDDEN |
+-------+----------+------------+---------------+----------------------+---------------------------+----------+
| id    | UUID     | false      | 0x4000020520  |                      | [primary users_email_key] | false    |
+-------+----------+------------+---------------+----------------------+---------------------------+----------+
| email | VARCHAR  | false      | <nil>         |                      | [users_email_key]         | false    |
+-------+----------+------------+---------------+----------------------+---------------------------+----------+