Hi Ace, Airflow uses something called Alembic for db migration and it's always safe to run `airflow upgradedb` (provided that you want to match the version of the db with the version of the app you are running). It makes sense to have that command as part of your deploy script.
For the record, migrations live here https://github.com/apache/incubator-airflow/tree/master/airflow/migrations/versions and `heads` means that it targets the latest migration. Each migration points to a previous migration so that they are ordered. Max On Fri, Jun 30, 2017 at 7:43 PM, Ace Haidrey <[email protected]> wrote: > Airflow has an upgradedb command that needs to be run when upgrading > Airflow versions. I wonder if it's safe to run even if the version is the > same. Wondering if that'd be okay to put part of my ansible deployment. > I've tried asking on Gitter and Stack Overflow but to no avail. > > Code wise I see: > def upgradedb(): > logging.info("Creating tables") > current_dir = os.path.dirname(os.path.abspath(__file__)) > package_dir = os.path.normpath(os.path.join(current_dir, '..')) > directory = os.path.join(package_dir, 'migrations') > config = Config(os.path.join(package_dir, 'alembic.ini')) > config.set_main_option('script_location', directory) > config.set_main_option('sqlalchemy.url', settings.SQL_ALCHEMY_CONN) > command.upgrade(config, 'heads') > > Where only the last line I guess is what I have a hard time following: > command.upgrade(config, 'heads'). Where is the heads defined? For instance, > if I'm on version 1.8.0 and then I run this command, will it put the heads > for the most recent version of Airflow from git? > I don't think so but just want to make sure it's safe. > > How foolish of me to not introduce myself. > My name is Ace Haidrey and I'm a Software Engineer at Pandora trying to > incorporate Airflow as part of our work management systems. > > Cheers, > ☺ >
