Copyright 2014 Oracle and/or its affiliates. All rights reserved.

Similar documents
Oracle Corporation Developer Advocate for Open Source

Automatically deploy Schema Changes with Ansible and Liquibase

Liquibase Version Control For Your Schema. Nathan Voxland April 3,

Automatically deploy Schema Changes with Ansible and Liquibase

Revision control. INF5750/ Lecture 2 (Part I)

Getting the files for the first time...2. Making Changes, Commiting them and Pull Requests:...5. Update your repository from the upstream master...

Let Robots Manage Your Schema Without Killing All Humans. Jenni

Git. Charles J. Geyer School of Statistics University of Minnesota. Stat 8054 Lecture Notes

Managing Network Configurations with Git and GitLab

withenv Documentation

Hg Tutorial. For : COP Object oriented Programming (Using C++) Biswas Parajuli

Installation and Release Notes

CS108, Stanford Handout #37. Source Control CVS

git Version: 2.0b Merge combines trees, and checks out the result Pull does a fetch, then a merge If you only can remember one command:

Version Control. Kyungbaek Kim. Chonnam National University School of Electronics and Computer Engineering. Original slides from James Brucker

Signals Documentation

1. Which of these Git client commands creates a copy of the repository and a working directory in the client s workspace. (Choose one.

Installation and Release Notes

Create Datamart. Alessandro Taurelli 2010/06/15 13:41

flask-dynamo Documentation

Version Control Systems

AccuRev Plugin for Crucible Installation and Release Notes

Git & Github Fundamental by Rajesh Kumar.

Revision Control. How can 4. Slides #4 CMPT 276 Dr. B. Fraser. Local Topology Simplified. Git Basics. Revision Control:

BanzaiDB Documentation

Jenkins: AMPLab s Friendly Butler. He will build your projects so you don t have to!

CS314 Software Engineering Configuration Management

Software Development I

Lab 01 How to Survive & Introduction to Git. Web Programming DataLab, CS, NTHU

How to version control like a pro: a roadmap to your reproducible & collaborative research

Oracle Big Data Cloud Service, Oracle Storage Cloud Service, Oracle Database Cloud Service

Version Control for the 2- Pizza Team: Merge Conflicts (ELLS 9.5) Armando Fox

pydrill Documentation

Configuring a JDBC Resource for IBM DB2/ iseries in Metadata Manager HotFix 2

Traffic violations revisited

git commit --amend git rebase <base> git reflog git checkout -b Create and check out a new branch named <branch>. Drop the -b

TCSS 360: SOFTWARE DEVELOPMENT AND QUALITY ASSURANCE

How to use Version Control in APEX projects? Oliver Lemm APEX Connect

Learning Objectives. Description. Your AU Expert(s) Trent Earley Behlen Mfg. Co. Shane Wemhoff Behlen Mfg. Co.

Con$nuous Integra$on Development Environment. Kovács Gábor

Human-Computer Interaction Design

The Old World. Have you ever had to collaborate on a project by

Tutorial 2 GitHub Tutorial

Working in Teams CS 520 Theory and Practice of Software Engineering Fall 2018

CPSC 491. Lecture 19 & 20: Source Code Version Control. VCS = Version Control Software SCM = Source Code Management

Revision Control. An Introduction Using Git 1/15

EasyLogin. Intro to the Alpha version

USING GIT FOR AUTOMATION AND COLLABORATION JUSTIN ELLIOTT - MATT HANSEN PENN STATE UNIVERSITY

GIT TO DA REPO! VERSION CONTROL, GITLAB, AND ISU

Git: Distributed Version Control

Application Management Webinar. Daniela Field

Selenium Testing Course Content

Learn about Oracle DECODE and see some examples in this article. section below for an example on how to use the DECODE function in the WHERE clause.

About CVS. 1 Version Control - what is it? why is it useful?

django CMS Export Objects Documentation

Greenplum-Spark Connector Examples Documentation. kong-yew,chan

Human-Computer Interaction Design

Configuring a JDBC Resource for MySQL in Metadata Manager

Database and MySQL Temasek Polytechnic

Git, the magical version control

Lecture 3: Processing Language Data, Git/GitHub. LING 1340/2340: Data Science for Linguists Na-Rae Han

Introduction to Git and Github

Version Control. Second level Third level Fourth level Fifth level. - Software Development Project. January 17, 2018

CVS. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 21

Continuous Delivery the hard way with Kubernetes. Luke Marsden, Developer

Recap: Developer's Environment

xmljson Documentation

git-flow Documentation

Git Introduction CS 400. February 11, 2018

Web API Lab. The next two deliverables you shall write yourself.

Set Current Schema Command Oracle Sql Developer Alter Session

Introduction to Git. Database Systems DataLab, CS, NTHU Spring, 2018

WMTOOL. Technical Specification. Date: 10/2012 Version: APITechSpecv1.4CRO0512 WMTOOL 1. Technical Specification

Git GitHub & secrets

open-helpdesk Documentation

Tutorial 4 Data Persistence in Java

StarTeam File Federation 1.0. User Guide

GEL Scripts Advanced. Your Guides: Ben Rimmasch, Yogesh Renapure

Software Engineering

API Gateway Version September Key Property Store User Guide

MOOSE-Based Application Development on GitLab

Additional Connectivity Options

ForeScout Extended Module for ServiceNow

eventbrite-sdk-python Documentation

This assignment requires that you complete the following tasks (in no particular order).

Command Line Interface

Apache Subversion Tutorial

Granting Read-only Access To An Existing Oracle Schema

ourwiki Documentation

New Contributor Tutorial and Best Practices

AgileSCM Release 4.1. AgileSCM Release 4.0. AgileSCM Release 3.2. New Features. Bug Fixes. New Features. Bug Fixes

Midterm Next Week. Last year s midterm (which didn t include remotes):

SECTION 2: CODE REASONING + PROGRAMMING TOOLS. slides borrowed and adapted from Alex Mariakis and CSE 390a

Ingegneria del Software Corso di Laurea in Informatica per il Management (D)VCS. Davide Rossi Dipartimento di Informatica Università di Bologna

What s new in IBM Operational Decision Manager 8.9 Standard Edition

django-idioticon Documentation

HashiCorp Vault on the AWS Cloud

Red Hat Developer Studio 12.9

Git: Distributed Version Control

$HIVE_HOME/bin/hive is a shell utility which can be used to run Hive queries in either interactive or batch mode.

Transcription:

Copyright 2014 Oracle and/or its affiliates. All rights reserved.

Howdy, I m Blaine Carter Oracle Developer Advocate for Open Source Oracle Corporation Email: blaine.carter@oracle.com Blog: learncodeshare.net Team: community.oracle.com/docs/doc-917690 2

Database Change Management The Hard Way MasterCreate directory: RunAllVer5.sql CreateLB_Groups.sql CreateLB_People.sql LoadLB_GroupsData.sql Update4to5 directory: UpdateAllVer4to5.sql AddColGroupsRules.sql AddColPeopleFavorite_color.sql Problems: Which script has been run? Update or Rollback to a specific version? Test data? LoadTestData.sql? 3

Leveraging Open Source for Oracle Database Development Liquibase Cross platform database change management. http://www.liquibase.org/ https://github.com/liquibase/liquibase Blaine Carter 4

Version Control / Change Management Basics: Track changes. Rollback / Switch to a specific revision. Branch / Merge Diffs 5

What is Liquibase? Liquibase is change management for your database. Database changes are made using changesets. When you run an update, the changesets are run in order. Liquibase tracks what has been run, when and who ran it. You can roll back to a specific version. Populate default and/or test data. Contexts - http://www.liquibase.org/documentation/contexts.html Diffs - http://www.liquibase.org/documentation/diff.html Documentation - http://www.liquibase.org/documentation/dbdoc.html SQL Output - http://www.liquibase.org/documentation/sql_output.html Offline - http://www.liquibase.org/documentation/offline.html 6

How Does It Work? 7

Changelog Master { } "databasechangelog": [ {"include": {"file":"changelog/db.changelog-1.json"}} ] 8

ChangeSet {"databasechangelog": [ {"preconditions": [{ "runningas": { "username": "lb_demo" } }] }, {"changeset": { "id": "1", "author": "BlaineCarter", "changes": [ {"createtable": { "tablename": "lb_person", "columns": [ {"column": { "name": "id", "type": "int", "autoincrement": true, "constraints": { "primarykey": true, "nullable": false... 9

Java Command Line java $JAVA_OPTS -jar /opt/liquibase/liquibase.jar --driver=oracle.jdbc.oracledriver --classpath="/usr/lib/oracle/12.1/client64/lib/ojdbc7.jar" --url=jdbc:oracle:thin:lb_demo/dd@dbaccess --changelogfile=changelog/db.changelog-master.json updatesql >> output.sql options --loglevel=debug --logfile=liquibase.logfile $JAVA_OPTS is used for my Oracle Exadata Express cloud connection. 10

Properties File (liquibase.properties) driver: oracle.jdbc.oracledriver classpath: /usr/lib/oracle/12.1/client64/lib/ojdbc7.jar url: jdbc: oracle:thin:lb_demo/dd@dbaccess changelogfile: changelog/db.changelog-master.json 11

Liquibase Best Recommended Practices http://www.liquibase.org/bestpractices.html Ignore the directory structure I m using in the demo s. 12

Software We ll Be Using SQL Developer Oracle Exadata Express Cloud Database or Virtual Box Liquibase - http://www.liquibase.org 13

Install 1. Download - http://www.liquibase.org/download/index.html 2. Install It's just Java, extract it and go. 14

Enough blah blah, let's see it. 15

Create Changelog and ChangeSet Files Changelog Example: http://www.liquibase.org/quickstart.html - step 1 Changeset Example: http://www.liquibase.org/quickstart.html - step 2 Recommended to only perform one change per Change set, but you can do more if you need. 16

Run It http://www.liquibase.org/quickstart.html - step 3 Jar File: java $JAVA_OPTS -jar /opt/liquibase/liquibase.jar updatesql Shell Script: liquibase updatesql Batch File: liquibase.bat updatesql Put the Liquibase directory in your path and run it: liquibase update The shell script / batch files use the same JAVA_OPTS environment variable for my Exadata Express Cloud connection. 17

Rollback X Number of Change Sets Warning: Rolling back anything in the database can be tricky. Be very careful if you ever do this in Production. liquibase rollbackcount 1 18

Tag a Changeset You can tag a changeset in the file: "changeset": { "id": "1", "author": "BlaineCarter", "tagdatabase": {"tag":"ver-1"}, "changes": [ You can also use the command line: liquibase tag ver-1 19

Rollback to Tag http://www.liquibase.org/documentation/rollback.html liquibase rollback ver-1 Other Options: http://www.liquibase.org/documentation/command_line.html 20

Load Data From a File "changes": [ { "loaddata": { "file": "changelog/groups.csv", "schemaname": "lb_demo", "tablename": "lb_groups" } }] groups.csv name,description Trucks,People who like trucks Rockets,People who like rockets Horses,People who like horses Snakes,People who like snakes 21

Insert Data... "changes": [ { "insert": { "schemaname": "lb_demo", "tablename": "lb_people", "columns": [ { "column": { "name": "firstname", "value": "Bob" } }, { "column": { "name": "group_id", "valuecomputed": "(SELECT id FROM lb_groups where name = 'Trucks')" } } 22

Context Test In the change set: "changeset": { "id": "loaddata-example", "author": "liquibase-docs", "context": "test", Liquibase.properties contexts:!test Command Line overrides the properties file: liquibase --contexts=test update Context vs Labels http://www.liquibase.org/2014/11/contexts-vs-labels.html 23

Data Changes Are NOT Automatically Rolled Back. Define your own Rollback { "rollback": { "delete": { "tablename": "lb_people" } } } 24

Diff http://www.liquibase.org/documentation/diff.html Command Line: liquibase.sh --url=jdbc:oracle:thin:lb_demo/dd@unknowndb \ diff \ --referenceurl=jdbc:oracle:thin:lb_demo/dd@gooddb Liquibase.properties: referenceurl: jdbc:oracle:thin:lb_diff_demo/dd@dbaccess 25

Generate Changelog (Reverse Engineer) http://www.liquibase.org/documentation/generating_changelogs.html Note that this command currently has some limitations. It does not export the following types of objects: Stored procedures, functions, packages & Triggers liquibase --changelogfile=generated.json generatechangelog 26

Review The Output The output won t be perfect. Generated by update: id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL Generated by generatechangelog: ID NUMBER(*, 0) DEFAULT "LB_DEMO"."ISEQ$$_69966".nnextval NOT NULL 27

DBDoc http://www.liquibase.org/documentation/dbdoc.html liquibase DBDoc docs 28

Extensions / Plugins https://liquibase.jira.com/wiki/display/contrib/liquibase+extensions+portal 29

We Can Make It Better http://www.liquibase.org/ Github Repo - https://github.com/liquibase/liquibase Fork Change Pull Request There are many ways to contribute. Enhance code Add tests Improve documentation Submit / review issues 30

Howdy, I m Blaine Carter Oracle Developer Advocate for Open Source Oracle Corporation Email: blaine.carter@oracle.com Blog: learncodeshare.net Team: community.oracle.com/docs/doc-917690 31

Commands Used For The Demo (by slide number) #17 liquibase updatesql liquibase update #18 liquibase rollbackcount 1 liquibase update #19 liquibase update liquibase tag mycooltag #20 liquibase rollback ver-1 liquibase update #21 liquibase update #23 liquibase --contexts=test update #24 liquibase rollbackcount 2 liquibase rollbackcount 1 liquibase --contexts=test rollbackcount 2 liquibase --contexts=test update #25 liquibase diff liquibase --difftypes=tables,columns diff liquibase diffchangelog #26 liquibase --changelogfile=generated.json generatechangelog #28 liquibase dropall liquibase DBDoc docs liquibase update liquibase DBDoc docs 32