It's important not just to deal with migraines when they occur, but also to try to prevent them in everyday life.
Literal
Migraine [subject-が] occurred when [at-に] deal-with [only-だけ] is-not, everyday life [possessive-の] inside [at-で], migraine [object-を] as-much-as-possible prevent-going [also-のも] important thing is.
~だけではなく~も (not just X but also Y) structures the advice. ~ていく on 防ぐ (prevent) points the effort forward into the future. なるべく (as much as possible) softens the recommendation. The sentence builds a practical health message about proactive care.