migrations: Only don't import "migrate" if it's not available
authorChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 29 Mar 2016 16:44:34 +0000 (09:44 -0700)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 29 Mar 2016 16:44:34 +0000 (09:44 -0700)
* mediagoblin/db/migrations.py: Import migrate if available; if not
  print a warning.

mediagoblin/db/migrations.py

index 257da6eef581fb292cfc19547073047acfae4a94..55d6429449de62d81d04a8b5118dafbe6e4c1653 100644 (file)
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
+
 import datetime
 import uuid
 
 import six
 
-if six.PY2:
+try:
     import migrate
+except ImportError:
+    # Apparently sqlalchemy-migrate is not installed, so we assume
+    # we must not need it
+    # TODO: Better error handling here, or require sqlalchemy-migrate
+    print("sqlalchemy-migrate not found... assuming we don't need it")
+    print("I hope you aren't running the legacy migrations!")
 
 import pytz
 import dateutil.tz