{
  "scenarios": [
    {
      "type": "create",
      "name": "Create FDW for foreign table",
      "endpoint": "NODE-foreign_data_wrapper.obj",
      "sql_endpoint": "NODE-foreign_data_wrapper.sql_id",
      "data": {
        "name": "test_fdw_for_foreign_table",
        "fdwacl": [],
        "fdwoptions": []
      },
      "store_object_id": "True"
    }, {
      "type": "create",
      "name": "Create foreign server for foreign table",
      "endpoint": "NODE-foreign_server.obj",
      "sql_endpoint": "NODE-foreign_server.sql_id",
      "data": {
        "name":"test_fs_for_foreign_table"
      },
      "store_object_id": "True"
    }, {
      "type": "create",
      "name": "Create Foreign Table with all options",
      "endpoint": "NODE-foreign_table.obj",
      "sql_endpoint": "NODE-foreign_table.sql_id",
      "msql_endpoint": "NODE-foreign_table.msql",
      "data": {
        "name": "FT1_$%{}[]()&*^!@\"'`\\/#",
        "owner":"postgres",
        "schema": "public",
        "basensp":"public",
        "description":"Test Comment",
        "ftsrvname":"test_fs_for_foreign_table",
        "columns":[{
          "attname":"col1",
          "datatype":"bigint",
          "coloptions":[]
        },{
          "attname":"col2",
          "datatype":"text",
          "coloptions":[]
        }],
        "ftoptions":[{
          "option":"schema_name",
          "value":"public"
        },{
          "option":"table_name",
          "value":"test_table"
        }],
        "acl":[{
          "grantee":"PUBLIC",
          "grantor":"postgres",
          "privileges":[{
            "privilege_type":"a",
            "privilege":true,
            "with_grant":false
          },{
            "privilege_type":"r",
            "privilege":true,
            "with_grant":false
          },{
            "privilege_type":"w",
            "privilege":true,
            "with_grant":false
          },{
            "privilege_type":"x",
            "privilege":true,
            "with_grant":false
          }]
        }]
      },
      "expected_sql_file": "create_foreign_table_with_all_options.sql",
      "expected_msql_file": "create_foreign_table_with_all_options_msql.sql"
    }, {
      "type": "delete",
      "name": "Drop foreign table",
      "endpoint": "NODE-foreign_table.delete_id"
    },
    {
      "type": "create",
      "name": "Create Foreign Table",
      "endpoint": "NODE-foreign_table.obj",
      "sql_endpoint": "NODE-foreign_table.sql_id",
      "data": {
        "name": "FT1_$%{}[]()&*^!@\"'`\\/#",
        "owner": "postgres",
        "schema": "public",
        "basensp": "public",
        "ftsrvname": "test_fs_for_foreign_table",
        "columns": []
      }
    }, {
      "type": "alter",
      "name": "Alter Foreign Table comment and add columns",
      "endpoint": "NODE-foreign_table.obj_id",
      "sql_endpoint": "NODE-foreign_table.sql_id",
      "msql_endpoint": "NODE-foreign_table.msql_id",
      "data": {
        "description":"Test Comment",
        "columns": {
          "added": [{
            "attname":"col1",
            "datatype":"bigint",
            "coloptions":[]
          },{
            "attname":"col2",
            "datatype":"text",
            "coloptions":[]
          }]
        }
      },
      "expected_sql_file": "alter_comment_add_columns.sql",
      "expected_msql_file": "alter_comment_add_columns_msql.sql"
    },{
      "type": "alter",
      "name": "Alter Foreign Table add options",
      "endpoint": "NODE-foreign_table.obj_id",
      "sql_endpoint": "NODE-foreign_table.sql_id",
      "msql_endpoint": "NODE-foreign_table.msql_id",
      "data": {
        "ftoptions": {
          "added": [{
            "option":"schema_name",
            "value":"public"
          },{
            "option":"table_name",
            "value":"test_table"
          }]
        }
      },
      "expected_sql_file": "alter_add_opts.sql",
      "expected_msql_file": "alter_add_opts_msql.sql"
    }, {
      "type": "alter",
      "name": "Alter Foreign Table add privileges",
      "endpoint": "NODE-foreign_table.obj_id",
      "sql_endpoint": "NODE-foreign_table.sql_id",
      "msql_endpoint": "NODE-foreign_table.msql_id",
      "data": {
        "acl":{
          "added": [{
            "grantee":"PUBLIC",
            "grantor":"postgres",
            "privileges":[{
              "privilege_type":"r",
              "privilege":true,
              "with_grant":false
            }]
          }]
        }
      },
      "expected_sql_file": "alter_add_priv.sql",
      "expected_msql_file": "alter_add_priv_msql.sql"
    }, {
      "type": "alter",
      "name": "Alter Foreign Table change option and column",
      "endpoint": "NODE-foreign_table.obj_id",
      "sql_endpoint": "NODE-foreign_table.sql_id",
      "msql_endpoint": "NODE-foreign_table.msql_id",
      "data": {
        "ftoptions": {
          "changed": [{
            "option":"schema_name",
            "value":"test_public"
          }]
        },
        "columns": {
          "changed": [{
            "attname": "col1",
            "attnum": 1,
            "attoptions": null,
            "collname": "",
            "coloptions": [],
            "datatype": "integer",
            "fulltype": "bigint"
          }],
          "deleted": [{
            "attname":"col2",
            "datatype":"text"
          }]
        }
      },
      "expected_sql_file": "alter_col_opts.sql",
      "expected_msql_file": "alter_col_opts_msql.sql"
    }, {
      "type": "alter",
      "name": "Alter Foreign Table remove option, privileges",
      "endpoint": "NODE-foreign_table.obj_id",
      "sql_endpoint": "NODE-foreign_table.sql_id",
      "msql_endpoint": "NODE-foreign_table.msql_id",
      "data": {
        "acl":{
          "deleted": [{
            "grantee":"PUBLIC",
            "grantor":"postgres",
            "privileges":[{
              "privilege_type":"a",
              "privilege":true,
              "with_grant":false
            },{
              "privilege_type":"r",
              "privilege":true,
              "with_grant":false
            }]
          }]
        },
        "ftoptions": {
          "deleted": [{
            "option":"schema_name",
            "value":"public"
          }]
        }
      },
      "expected_sql_file": "alter_remove_opts_priv.sql",
      "expected_msql_file": "alter_remove_opts_priv_msql.sql"
    }, {
      "type": "delete",
      "name": "Drop foreign table",
      "endpoint": "NODE-foreign_table.delete_id"
    }, {
      "type": "delete",
      "name": "Drop foreign server",
      "endpoint": "NODE-foreign_server.delete_id",
      "data": {
        "name": "test_fs_for_foreign_table"
      }
    }, {
      "type": "delete",
      "name": "Drop FDW",
      "endpoint": "NODE-foreign_data_wrapper.delete_id",
      "data": {
        "name": "test_fdw_for_foreign_table"
      }
    }
  ]
}
