Git Product home page Git Product logo

heroku-pgmigrate's Introduction

heroku pg:migrate

Installation

# upgrade to the latest heroku gem
gem update heroku
# install this plugin
heroku plugins:install git://github.com/heroku/heroku-pgmigrate

Usage

In short: heroku pg:migrate --app your_app

This command will move from the legacy Shared Database plans to the newer Heroku Postgres Dev plans. This is done using a series of API calls that have been available for some time, and a few new ones made to this purpose.

The general process used internally by the software is as follows:

# Add a pgbackups:plus plan, if no pgbackups plan is found at all
heroku addons:add pgbackups:plus -a <appname>

# Create a Dev plan as a target to do a pgbackups restore into
heroku addons:add heroku-postgresql:dev -a <appname>

# Set maintenance mode
heroku maintenance:on -a <appname>

# Scale all processes to zero
heroku scale <all-process-types>=0 -a <appname>

# Copy the database (this API is not currently exposed via command
# line)
heroku pgbackups:transfer <SHARED_DATABASE_URL> <DEV_PLAN_URL> -a <appname>

# Having confirmed that it succeeds...
#
# Rebind all config variables that had the SHARED_DATABASE_URL to
# the new DEV_PLAN_URL.  SHARED_DATABASE_URL will also be rebound
# to the dev addon.
heroku config:add <...> -a <appname>

# Now that everything is reconfigured, bring the app back up
heroku scale <all-process-types>=<original-value> -a <appname>
heroku maintenance:off -a <appname>

Bugs

pg:migrate can be dangerous if one has moved, duplicated, or overwritten their SHARED_DATABASE_URL configuration, including both within one application and between multiple applications.

pg:migrate is not safe to use under concurrent access (multiple users at the same time). In event of an abort, it may be necessary to determine:

  • If one wishes to roll back the attempt to migrate and try again, whether one should delete the target dev-plan database, as migrations are safest to completely empty database.

  • If the database was properly restored into its destination

  • If one wishes to use the new database or old database URL

  • If one needs to rebind any config variables, should config var rewriting have only half-completed.

  • If one wishes to turn off maintenance mode and scale processes back to their original level, after assessing that all config vars are in the correct state.

THIS IS BETA SOFTWARE

Thanks for trying it out. If you find any issues, please notify us at [email protected]

heroku-pgmigrate's People

Contributors

svc-scm avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

msakrejda

heroku-pgmigrate's Issues

Shouldn't require a pgbackups slot

Got this once:

Transferring...
! must delete a backup before creating a new one

Would be nice if you could avoid this check for transfers?

Ambiguous phrasing: Leaving maintenance mode on…

The final line of output:

Leaving maintenance mode on application APP_NAME... done

I initially read this as "Leaving maintenance mode turned on …", and thought it was a warning that I would need to turn it off myself.

Perhaps one of these would be clearer?

Turning off maintenance mode for APP_NAME... done
Exiting maintenance mode on application APP_NAME... done
Leaving maintenance mode for application APP_NAME... done

Cheers,
Paul

confirm outcome of ps:scale before migrating

We do not check for convergence whereby psmgr confirms the non-existence of processes before continuing the migration process. Thus, quiescence may not be complete. (Note: in the case of two applications sharing a database, it won't be complete anyway)

pg transfer failure

From @fdr:

the cause of such failures is so mysterious that it doesn't make sense to know whether to retry or not?

heroku pg:migrate -a bestdamnburger-production
Checking for pgbackups addon... done, already present
Installing heroku-postgresql:dev... done, attached as HEROKU_POSTGRESQL_COBALT
Entering maintenance mode on application bestdamnburger-production... done
Scaling process web to 0... done
WARNING: 'heroku run' processes are not cancelled at this time
Transferring... 
Pg_dump... 68.4kB -
ERROR: Transfer failed, aborting
Restoring process web scale to 1... done
Leaving maintenance mode on application bestdamnburger-production... done

Trying a second time worked:

heroku pg:migrate -a bestdamnburger-production
Checking for pgbackups addon... done, already present
Installing heroku-postgresql:dev... done, attached as HEROKU_POSTGRESQL_BROWN
Entering maintenance mode on application bestdamnburger-production... done
Scaling process web to 0... done
WARNING: 'heroku run' processes are not cancelled at this time
Transferring... 
Pg_dump... 68.4kB -
done
Binding new database configuration to: SHARED_DATABASE_URL, DATABASE_URL... done
Restoring process web scale to 1... done
Leaving maintenance mode on application bestdamnburger-production... done

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.