change the timing of setting the environment variables

Can't use environment variables in before_migrate.