CREATE TABLE IF NOT EXISTS asset_hashes (
  asset_id uuid PRIMARY KEY REFERENCES assets(id) ON DELETE CASCADE,
  bucket text NOT NULL,
  sha256 text NOT NULL,
  created_at timestamptz NOT NULL DEFAULT now()
);

CREATE UNIQUE INDEX IF NOT EXISTS asset_hashes_bucket_sha256_idx
ON asset_hashes(bucket, sha256) WHERE sha256 IS NOT NULL;
