#!/bin/bash

sqlite3 /4server/data/contracts.db <<EOF
ALTER TABLE containers ADD COLUMN env_list TEXT;
UPDATE containers
SET env_list = (
  SELECT group_concat(key || '=' || value, ', ')
  FROM json_each(containers.env)
);
ALTER TABLE containers ADD COLUMN secret_list TEXT;
UPDATE containers
SET secret_list = (
  SELECT group_concat(key || '=' || value, ', ')
  FROM json_each(containers.secret)
);
EOF
