{
  "scenarios": [
    {
      "type": "create",
      "name": "Create Table for Views",
      "endpoint": "NODE-table.obj",
      "sql_endpoint": "NODE-table.sql_id",
      "data": {
        "name": "test_view_table",
        "check_constraint": [],
        "coll_inherits": "[]",
        "columns": [
          {
            "name": "col1",
            "cltype": "integer"
          }
        ],
        "schema": "public"
      }
    },
    {
      "type": "create",
      "name": "Create View",
      "endpoint": "NODE-view.obj",
      "sql_endpoint": "NODE-view.sql_id",
      "msql_endpoint": "NODE-view.msql",
      "data": {
        "definition": "select col1 from test_view_table;",
        "name": "testview_$%{}[]()&*^!@\"'`\\/#",
        "owner": "<OWNER>",
        "schema": "public",
        "check_option": "local",
        "security_barrier": false,
        "security_invoker": false,
        "comment": "Testcomment",
        "datacl": [
          {
            "grantee": "<OWNER>",
            "old_grantee": "<OWNER>",
            "grantor": "<OWNER>",
            "privileges": [
              {
                "privilege_type": "a",
                "privilege": true,
                "with_grant": false
              }
            ]
          }
        ]
      },
      "expected_sql_file": "create_view.sql",
      "expected_msql_file": "create_view_msql.sql"
    },
    {
      "type": "alter",
      "name": "Alter View",
      "endpoint": "NODE-view.obj_id",
      "sql_endpoint": "NODE-view.sql_id",
      "msql_endpoint": "NODE-view.msql_id",
      "data": {
        "name": "testview_$%{}[]()&*^!@\"'`\\/#",
        "owner": "<OWNER>",
        "schema": "public",
        "check_option": "cascaded",
        "security_barrier": true,
        "security_invoker": true,
        "comment": "Testcomment-updated",
        "datacl": [
          {
            "grantee": "<OWNER>",
            "grantor": "<OWNER>",
            "old_grantee": "<OWNER>",
            "privileges": [
              {
                "privilege_type": "a",
                "privilege": true,
                "with_grant": false
              }
            ]
          }
        ]
      },
      "expected_sql_file": "alter_view.sql",
      "expected_msql_file": "alter_view_msql.sql"
    },
    {
      "type": "alter",
      "name": "Alter View (changing code)",
      "endpoint": "NODE-view.obj_id",
      "sql_endpoint": "NODE-view.sql_id",
      "msql_endpoint": "NODE-view.msql_id",
      "data": {
        "definition": "SELECT * FROM test_view_table;"
      },
      "expected_sql_file": "alter_view_definition.sql",
      "expected_msql_file": "alter_view_definition_msql.sql"
    },
    {
      "type": "alter",
      "name": "Alter View (adding privileges)",
      "endpoint": "NODE-view.obj_id",
      "sql_endpoint": "NODE-view.sql_id",
      "msql_endpoint": "NODE-view.msql_id",
      "data": {
        "name": "testview_$%{}[]()&*^!@\"'`\\/#",
        "owner": "<OWNER>",
        "schema": "public",
        "check_option": "cascaded",
        "security_barrier": true,
        "comment": "Testcomment-updated",
        "datacl": {
          "added": [
            {
              "grantee": "PUBLIC",
              "grantor": "<OWNER>",
              "privileges": [
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                }
              ]
            }
          ]
        }
      },
      "expected_sql_file": "alter_view_add_some_priv.sql",
      "expected_msql_file": "alter_view_add_some_priv_msql.sql"
    },
    {
      "type": "alter",
      "name": "Alter View (deleting privileges (PUBLIC))",
      "endpoint": "NODE-view.obj_id",
      "sql_endpoint": "NODE-view.sql_id",
      "msql_endpoint": "NODE-view.msql_id",
      "data": {
        "name": "testview_$%{}[]()&*^!@\"'`\\/#",
        "owner": "<OWNER>",
        "schema": "public",
        "check_option": "cascaded",
        "security_barrier": true,
        "comment": "Testcomment-updated",
        "datacl": {
          "deleted": [
            {
              "grantee": "PUBLIC",
              "grantor": "<OWNER>",
              "privileges": [
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                }
              ]
            }
          ]
        }
      }
    },
    {
      "type": "alter",
      "name": "Alter View (changing privileges (postgres to PUBLIC))",
      "endpoint": "NODE-view.obj_id",
      "sql_endpoint": "NODE-view.sql_id",
      "msql_endpoint": "NODE-view.msql_id",
      "data": {
        "name": "testview_$%{}[]()&*^!@\"'`\\/#",
        "owner": "<OWNER>",
        "schema": "public",
        "check_option": "cascaded",
        "security_barrier": true,
        "comment": "Testcomment-updated",
        "datacl": {
          "changed": [
            {
              "grantee": "PUBLIC",
              "grantor": "<OWNER>",
              "old_grantee": "<OWNER>",
              "privileges": [
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                }
              ]
            }
          ]
        }
      },
      "expected_sql_file": "alter_view_update_priv.sql",
      "expected_msql_file": "alter_view_update_priv_msql.sql"
    },
    {
      "type": "alter",
      "name": "Alter View (deleting privileges)",
      "endpoint": "NODE-view.obj_id",
      "sql_endpoint": "NODE-view.sql_id",
      "msql_endpoint": "NODE-view.msql_id",
      "data": {
        "name": "testview_$%{}[]()&*^!@\"'`\\/#",
        "owner": "<OWNER>",
        "schema": "public",
        "check_option": "cascaded",
        "security_barrier": true,
        "comment": "Testcomment-updated",
        "datacl": {
          "deleted": [
            {
              "grantee": "PUBLIC",
              "grantor": "<OWNER>",
              "privileges": [
                {
                  "privilege_type": "r",
                  "privilege": true,
                  "with_grant": false
                }
              ]
            }
          ]
        }
      },
      "expected_sql_file": "alter_view_delete_priv.sql",
      "expected_msql_file": "alter_view_delete_priv_msql.sql"
    },
    {
      "type": "delete",
      "name": "Drop View",
      "endpoint": "NODE-view.obj_id",
      "data": {
        "name": "testview_$%{}[]()&*^!@\"'`\\/#",
        "owner": "<OWNER>",
        "schema": "public"
      }
    },
    {
      "type": "delete",
      "name": "Drop Table for view",
      "endpoint": "NODE-table.obj_id",
      "data": {
        "name": "test_view_table",
        "owner": "<OWNER>",
        "schema": "public"
      }
    }
  ]
}
