{
  "format": "rpai-station-workflow",
  "version": 1,
  "name": "SQLite notes",
  "variables": [
    {
      "id": "var-folder",
      "name": "folder",
      "type": "string",
      "value": "~/Documents/Station Academy"
    }
  ],
  "activities": [
    {
      "id": "academy-001",
      "type": "comment",
      "name": "About this workflow",
      "properties": {
        "text": "Station Academy, Level 4. Creates a small SQLite database in the practice folder, adds two rows with parameters and reads them back."
      }
    },
    {
      "id": "academy-002",
      "type": "file_operation",
      "name": "Make sure the practice folder exists",
      "properties": {
        "operation": "create_folder",
        "sourcePath": "{{folder}}"
      }
    },
    {
      "id": "academy-003",
      "type": "database_query",
      "name": "Create the table",
      "properties": {
        "mode": "execute",
        "connectionString": "{{folder}}/academy.db",
        "query": "CREATE TABLE IF NOT EXISTS notes (id INTEGER PRIMARY KEY, title TEXT NOT NULL, done INTEGER NOT NULL DEFAULT 0)"
      }
    },
    {
      "id": "academy-004",
      "type": "database_query",
      "name": "Start empty",
      "properties": {
        "mode": "execute",
        "connectionString": "{{folder}}/academy.db",
        "query": "DELETE FROM notes"
      }
    },
    {
      "id": "academy-005",
      "type": "database_query",
      "name": "Add a note",
      "properties": {
        "mode": "execute",
        "connectionString": "{{folder}}/academy.db",
        "query": "INSERT INTO notes (title, done) VALUES (@title, @done)",
        "parameters": "{\"title\": \"Buy paper\", \"done\": 0}"
      }
    },
    {
      "id": "academy-006",
      "type": "database_query",
      "name": "Add another",
      "properties": {
        "mode": "execute",
        "connectionString": "{{folder}}/academy.db",
        "query": "INSERT INTO notes (title, done) VALUES (@title, @done)",
        "parameters": "{\"title\": \"Send the report\", \"done\": 1}"
      }
    },
    {
      "id": "academy-007",
      "type": "database_query",
      "name": "Open notes",
      "properties": {
        "mode": "query",
        "connectionString": "{{folder}}/academy.db",
        "query": "SELECT id, title FROM notes WHERE done = 0",
        "saveToVariable": "open"
      }
    },
    {
      "id": "academy-008",
      "type": "log",
      "name": "Result",
      "properties": {
        "message": "Open notes: {{open}}",
        "level": "info"
      }
    }
  ]
}
