I had pain all over (my doctor thought I had fibromyalgia) and felt 100 years old, serious insomnia, migranes and a very long list of other symptoms due to severe magnesium deficiency. Up to 50% of people with migraines have a magnesium deficiency.
To produce serotonin from tryptophan (an amino acid which forms the building blocks of protein) you need plenty of magnesium, vitamin B6 as well as vitamin D. These are essential coenzymes necessary in the conversion of tryptophan into serotonin. Serotonin is needed to produce melatonin (sleeping hormone).
Excerpt from John Hopkins - Nutrition & Rheumatoid Arthritis...
"The most commonly observed vitamin and mineral deficiencies in patients with RA, are folic acid, vitamin C, vitamin D, vitamin B6, vitamin B12, vitamin E, folic acid, calcium, magnesium, zinc and selenium.(ref 4)"