djangae.contrib.sqlmigrator

This is a utility for applying Django migrations to Google Cloud SQL databases from a web view, rather than from the command line.

It allows you to avoid having to expose any internet-accessible connections to your Cloud SQL instance, and also avoids the need to repeatedly update your instance's network settings with your current office/home IP address in order to run migration commands from your local machine.

Installation

Due to the fact that Django authentication cannot be used until the database tables exist, this tool uses Google's Identity-Aware Proxy (IAP) to control access.

You will probably want to run sqlmigrator on a separate App Engine service, in order to be able to apply IAP to it.

  • Add djangae.contrib.sqlmigrator to INSTALLED_APPS.
  • Include djangae.contrib.sqlmigrator.urls in your urlconf.
  • Set up a separate App Engine service to serve this app.
  • Ensure that you don't have any middleware which tries to access DB tables from your SQL DB(s).
  • Lock down the service with IAP: https://console.cloud.google.com/security/iap
    • 🚨 Ensure that the only users who can log in with IAP are trusted users whom you want to be able to run migrations.