(I am not a lawyer, etc)
Gonzalez vs. Raich was not a ruling on the specific drug. It was a ruling on whether or not Congress (and, by extension, the executive) can apply the interstate commerce clause to the regulation of drugs, even if they don't cross state lines.
It's also a pretty straightforward consequence of Wickard v. Filburn, which is basically the same thing for wheat in the 1940s.
"Gonzales v. Raich (previously Ashcroft v. Raich), 545 U.S. 1 (2005), was a decision by the United States Supreme Court ruling that under the Commerce Clause of the US Constitution, Congress may criminalize the production and use of homegrown cannabis even if states approve its use for medicinal purposes."
https://en.wikipedia.org/wiki/Gonzales_v._Raich