Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Painless version controlled, database refactoring

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Wil Moore III Wil Moore III
February 26, 2013

Painless version controlled, database refactoring

Emailing *.sql files to the in-house DBA before each release used to work for your single-node, single-environment website. You have recently been tasked with building a multi-environment application architecture when you realize that you need to come up with a more professional process which is less error-prone.

Avatar for Wil Moore III

Wil Moore III

February 26, 2013
Tweet

More Decks by Wil Moore III

Other Decks in Technology

Transcript

  1. % mkdir timetracker % cd !$ % wget http://liquibase.org/liquibase-3.0.0-beta1-bin.zip %

    wget http://jdbc.postgresql.org/download/postgresql-9.2-1002.jdbc3.jar % wget https://gist.github.com/wilmoore/5034783/raw/liquibase.properties % wget https://gist.github.com/wilmoore/5034783/raw/db-changelog.xml % unzip liquibase-3.0.0-beta1-bin.zip % rm liquibase-3.0.0-beta1-bin.zip % rm -rf docs % chmod +x liquibase % git init % git stage --all % git commit -m ‘Liquibase Bootstrap’ Bootstrap
  2. Branch == (Story|Issue) % git checkout -b issue-001 Switched to

    a new branch ‘issue-001’ % $EDITOR issue-001.sql
  3. Happy? then push it! % git stage db-changelog.xml issue-001.sql %

    git commit -am 'issue-001: creates initial work table' % git push origin HEAD # then make a pull request @ github
  4. Add a new change set % git checkout -b issue-002

    Switched to a new branch ‘issue-002’ % $EDITOR issue-002.sql
  5. Checking our work % git stage db-changelog.xml issue-002.sql % git

    commit -am 'issue-002: archived/deleted boolean columns' % git checkout master % git merge issue-002 % git push origin master
  6. Generate HTML Docs % mkdir -p ./build/dbdoc % ./liquibase dbdoc

    ./build/dbdoc Lists changes, authors, tables, etc.
  7. Find Stuff with Git % git log -S ‘issue-002’ --

    db-changelog.xml % git show 1a26f4f
  8. Liquibase Website http://www.liquibase.org/ Presentation Code https://github.com/slidedecks/schema-evolution-vcs What are the alternatives

    to LiquiBase? quora.com/What-are-the-alternatives-to-LiquiBase PostgreSQL Connection URIs http://www.postgresql.org/docs/9.2/static/libpq- connect.html#AEN38149 Resources
  9. Liquibase Best Practices http://liquibase.org/bestpractices Formatted SQL Changelogs http://liquibase.org/manual/ formatted_sql_changelogs Formatted

    SQL Includes http://forum.liquibase.org/topic/liquibase-formatted- sql-how-to-include-other-changeset-file LiquiBase Command Line http://www.liquibase.org/manual/command_line Documentation