ALTER TABLE "games"
ADD COLUMN IF NOT EXISTS "automation_rules" jsonb DEFAULT '[]'::jsonb NOT NULL;

UPDATE "games"
SET
  "automation_rules" = '[
    {
      "id": "cs2-install-latest-counterstrikesharp-runtime",
      "event": "server.install.completed",
      "enabled": true,
      "runOncePerServer": true,
      "continueOnError": false,
      "actions": [
        {
          "id": "install-cs2-runtime",
          "type": "github_release_extract",
          "owner": "roflmuffin",
          "repo": "CounterStrikeSharp",
          "assetNamePatterns": [
            "^counterstrikesharp-with-runtime-.*linux.*\\\\.zip$",
            "^counterstrikesharp-with-runtime.*\\\\.zip$"
          ],
          "destination": "/game/csgo",
          "stripComponents": 0,
          "maxBytes": 268435456
        }
      ]
    }
  ]'::jsonb,
  "updated_at" = now()
WHERE
  "slug" = 'cs2'
  AND (
    "automation_rules" IS NULL
    OR "automation_rules" = '[]'::jsonb
  );
