How can I cache (MySQL) database migrations

caching
cache
mysql
circle.yml

#1

Hi, We’re set up with CircleCI for validation and deployments with MySQL database migrations. With our 179 (and growing) migration files, applying these migrations is the slowest part of spinning up our instance.

Is there a way to cache the MySQL directory (or otherwise) for the next time to speed it up? Ideally we could cache conditionally on a successful set of tests, rather than always.

Our circle.yaml file looks like:

machine:
  node:
    version: 6.9.1
  environment:
    MYSQL_PORT: 3306
    MYSQL_USER: root
    MYSQL_PASSWORD: root
...
dependencies:
  pre:
     - npm install -g https://github.com/honeyfund/node-mysql-script-deploy
...
database:
  override:
    # replace CircleCI's generated database.yml
    - echo "SET PASSWORD for 'root'@'localhost' = PASSWORD('root');" | mysql -u root
    - mysql -u root -proot -e "CREATE DATABASE XXX"
    - mysql -u root -proot XXX < database/schema_and_seed_data.sql
    - mysql-deploy root:root@localhost/XXX -s database/schema
...

Thanks in advance, Josh


#2

Hey - did you ever find a solution to this?

Cheers.


#3