--up
  CREATE TABLE sample_derivations (
    "sample_id" integer NOT NULL REFERENCES samples(id) ON DELETE CASCADE,
    "derived_from_id" integer NOT NULL REFERENCES samples(id) ON DELETE RESTRICT,
    "derivation_type" text NOT NULL,
    "created_at" timestamp NOT NULL DEFAULT NOW(),
    "updated_at" timestamp NOT NULL DEFAULT NOW(),
    UNIQUE ("sample_id", "derived_from_id")
  );

  CREATE TRIGGER set_timestamp
  BEFORE UPDATE ON sample_derivations FOR EACH ROW
  EXECUTE PROCEDURE update_updated_at_column();
--down
  DROP TABLE sample_derivations;
