exports.up = (pgm) => {
  pgm.sql(`
    CREATE TABLE slide_candidates (
      id             uuid PRIMARY KEY DEFAULT gen_random_uuid(),
      slide_id       uuid NOT NULL REFERENCES slides ON DELETE CASCADE,
      component_key  varchar(100) NOT NULL,
      display_mode   varchar(50),
      props          jsonb,
      score          numeric NOT NULL DEFAULT 0,
      proposed_by    varchar(200) NOT NULL,
      proposed_by_name varchar(200),
      created_at     timestamptz DEFAULT NOW(),
      updated_at     timestamptz DEFAULT NOW(),
      UNIQUE(slide_id, proposed_by)
    )
  `);
  pgm.sql('CREATE INDEX idx_slide_candidates_slide_id ON slide_candidates(slide_id)');
};

exports.down = (pgm) => {
  pgm.dropTable('slide_candidates');
};
