module.exports = {
  name: 'ebs_module_runs',
  up: async (client) => {
    await client.query(`
      CREATE TABLE IF NOT EXISTS ebs_module_runs (
        id            SERIAL PRIMARY KEY,
        connection_id INTEGER      NOT NULL,
        run_at        TIMESTAMPTZ  NOT NULL DEFAULT NOW(),
        overall_status TEXT        NOT NULL,
        modules_json  JSONB        NOT NULL,
        is_demo       BOOLEAN      DEFAULT FALSE
      )
    `);
    await client.query(`
      CREATE INDEX IF NOT EXISTS idx_ebs_module_runs_conn_at
        ON ebs_module_runs (connection_id, run_at DESC)
    `);
  },
};
