--up
CREATE TABLE lalala_files (
    id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    sample_id integer NOT NULL REFERENCES samples(id),
    lalala_id text NOT NULL,
    expires_at timestamp without time zone NOT NULL,
    created_at timestamp without time zone NOT NULL DEFAULT now(),
    updated_at timestamp without time zone NOT NULL DEFAULT now()
);

COMMENT ON COLUMN lalala_files.lalala_id IS 'ID returned by Lalala API upon upload';

CREATE TRIGGER set_timestamp
BEFORE UPDATE ON lalala_files FOR EACH ROW
EXECUTE PROCEDURE update_updated_at_column();

--down
DROP TRIGGER set_timestamp ON lalala_files;
DROP TABLE lalala_files;
