How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control...

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

Transcript of How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control...

Page 1: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

How to use Version

Control in APEX projects?

Oliver Lemm

APEX Connect

26.04.2016

Page 2: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Facts & Figures

Independent Technology House

with Cross-Industry Expertise

Headquarter

Ratingen

(North Rhine – Westphalia)

240

Employees

Founded

1994

Branches

Dortmund, Cologne,

Frankfurt

Top Company

for Trainees &

Students

Privately-

Owned

Corporation

Oracle

Platinum

Partner

24 Mio. Euro

Revenue

2

Page 3: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

about me

Oliver Lemm

since february 2007 working for MT AG in Ratingen

Competence Center Leader APEX & Service Center Leader APEX

Diploma applied computer science at the university of Duisburg-Essen

Projectleader, IT-Architect and Developer

working with Oracle Databases and Oracle Application Express since 2007

Blog http://oliverlemm.blogspot.de

Twitter https://twitter.com/OliverLemm

3

Page 4: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Agenda

1. Motivation

2. Version Control

3. Versioning APEX Application

4. Versioning Database Objects

5. Versioning external Files

4

Page 5: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Motivation

5

Page 6: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Motivation

„make it visible what has changed, who changed it and when was the change“

„create a snapshot of the whole scripts of a delivered software“

„define a central repository for the code“

„make it possible to automate testing and deployment“

6

Page 7: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Version Control

Version Control

Revision Control

Numbers

Source Control

Files

Source Code Management

„SCM“ Software ConfigurationManagement

7

Page 8: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Version Control

proprietary and local

PVCS since 1985

Open Source & Client Server

CVS since 1986

Subversion / SVN since 2000

Distributed

Git since 2005

GitHub – web-based Git repository

8

software history

Page 9: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Version Control

you need a repository server

direct commit into repository

revision and version central

version history only on server

Central approach supports security and rights management

9

Subversion

working directory

repository

Page 10: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Source Control

10

keywords

commit merge diff update

trunk tag branch

Page 11: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Version Control

there is no repository server

all operations are locally

sync mechanism for distributed systems

11

Git

working directory

staging area

repository

Page 12: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Source Control

12

keywords

pull push clone rebase

staging Remote dirty

Page 13: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Version Control

Subversion

TortoiseSVN (Windows) Cornerstone (MAC)https://tortoisesvn.net/ http://www.zennaware.com/cornerstone/

Git

Sourcetree (Windows & Mac)

https://www.sourcetreeapp.com/

13

client tools

Page 14: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Versioning APEX Applications

f100.sql

14

one or many?

Sharedcomponents

Navigation

• Breadcrumbs

• Tabs

User Interface

• lov

• templates

• themes

• shortcuts

Security

• authorization

• authentication

Plugins

• dynamic action

• Item

• Process

• region

Pages

Page 15: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Versioning APEX Application

15

single vs multiple

single file multiple files

web based Export & Import Divide into multiple by using APEXExportSplitter

one big file including static files better usable with version control

bring a single change to other instance

all changes encapsulated dependency tracking by developers

changes always replace – no update scripts

Page 16: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Versioning APEX Applications

export your application as often as you have done changes

commit the application changes together with database changes

commit single file AND splitted files (by automation)

deliver single file for installation

use splitted file for identifying changes

16

conclusion

Page 17: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Ordered?

17

Page 18: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Versioning Database Objects

• Reference Data

• Metadata

• Data Migration

• Grants & Synonyms

• Installation Scripts

• Package

• View

• Trigger

• Type

• Table

• Sequence

• Alter Objects

DDL PLSQL

DMLother

18

Page 19: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Versioning != Versioning

19

Frontend Backend

Page 20: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Versioning Database Objects

divide files by Schema

don‘t use schemanames in script

don‘t mix up DML, DDL and PLSQL

single script for every object

use force in types and views

20

preconditions

Page 21: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Versioning Database Object

create a file for every schema combination for grants

one file for synonyms

Include a check in every DDL and DML

21

optional

Page 22: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

trunk/objects in development

tags/Every release gets a subfolder in tags

branches/objects in parallel development

objects for hotfixes in old releases

22

level 1

/trunk/

/tags/

/branches/

Page 23: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

one folder per release as subfolder

every releasehas the same structureas the trunk

23

level 2 – tags & branches/tags

/1_40_1

/1_40

/…

/1_1

/branches/

/1_40

/1_30

Page 24: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

Windows -> batch

Linux -> shell

Scripts with instance parameters

Scripts usable with CI/CD or

standalone

No SQL or PL/SQL

24

level 2 – trunk/batch or trunk/shell

/trunk

/batch

/shell

/config

/doc

/logs

/app

/schema_main

/schema_export

/schema_import

/scripts

/static-files

/db-model

Page 25: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

25

level 2 – trunk/config

config one file for every target instance

Database-IP

Database-Port

Database-Servicename

Schema and Password

Tablespaces

Datafiles

Release

Additional Parameter

Based on security restrictions parametersnot included dba / datapump / sys

/trunk

/batch

/shell

/config

/doc

/logs

/app

/schema_main

/schema_export

/schema_import

/scripts

/static-files

/db-model

Page 26: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

26

level 2 – trunk/doc

Release Notes

Documentation

Installation Notes

PL/DOC

/trunk

/batch

/shell

/config

/doc

/logs

/app

/schema_main

/schema_export

/schema_import

/scripts

/static-files

/db-model

Page 27: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

27

level 2 – trunk/logs

One Installations/Patchlogsfolder per Instance

Foldername based on Servicename

Serveraddress

Example:/ORCL.DEV-COSMOS.DE

Every installation creates a new entry in /tags/version

If not installing by automationplace logs from installation by hand

/trunk

/batch

/shell

/config

/doc

/logs

/app

/schema_main

/schema_export

/schema_import

/scripts

/static-files

/db-model

Page 28: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

Place your APEX APP here

28

level 2 – trunk/app

/trunk

/batch

/shell

/config

/doc

/logs

/app

/schema_main

/schema_export

/schema_import

/scripts

/static-files

/db-model

Page 29: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

one subfolder per schema

use schema_<name>easier with parameter

human readable

Higher security when runningscripts from one schema separated

29

level 2 – trunk/schema_xxx

/trunk

/batch

/shell

/config

/doc

/logs

/app

/schema_main

/schema_export

/schema_import

/scripts

/static-files

/db-model

Page 30: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

30

level 2 – trunk/scripts

Scripts for the installation processGenerated installationscripts

Recompile

Checking for invalide objects

Pre-Patchchecks

Updating to the new version

Every Script is called byshell or batch script

/trunk

/batch

/shell

/config

/doc

/logs

/app

/schema_main

/schema_export

/schema_import

/scripts

/static-files

/db-model

Page 31: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

Subfolders

/img

Grafiken der Webanwendung png / jpg / gif …

/js

JavaScript Dateien/libraries *.js

/css

Stylesheet Datei einer Webanwendung *.css

31

level 2 – trunk/static-files

/trunk

/batch

/shell

/config

/doc

/logs

/app

/schema_main

/schema_export

/schema_import

/scripts

/static-files

/db-model

Page 32: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

save your SQL DataModeler

optional additional subfolder per schema

divide schema-SQL files

32

level 2 – trunk/db-model

/trunk

/batch

/shell

/config

/doc

/logs

/app

/schema_main

/schema_export

/schema_import

/scripts

/static-files

/db-model

Page 33: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

33

level 2 – trunk/schema_main/apex

View/Package layer for every APEX Page

One subfolder per Page or Page group

easier to handle

page layer gets invalide when related objects change

/trunk/schema_main

/apex

/p0100

/p0200

/p0300

/ddl

/dml

/plsql

Page 34: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

34

level 2 – trunk/schema_main/ddl

Only scripts which are ddl.

No „create or replace“

additional subfolders

/tbl - tables

/seq - sequences

„alter“ Scripts saved in ddl

/trunk/schema_main

/apex

/ddl

/tbl

/seq

/dml

/plsql

Page 35: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

35

level 2 – trunk/schema_main/dml

Only DML

no subfolders

/trunk/schema_main

/apex

/ddl

/dml

/plsql

Page 36: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

folder structure

36

level 2 – trunk/schema_main/plsql

/plsql/

Only scripts with „create or replace“

additional subfolders

/pkg - Packages

/trg - Trigger

/typ - Types

/vw - Views

/trunk/schema_main

/apex

/ddl

/dml

/plsql

/pkg

/trg

/typ

/vw

Page 37: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

Bild mit Durchblick, Erkenntnis, Freude

37

Page 38: How to use Version Control in APEX projects? - doag.org · PDF fileHow to use Version Control in APEX projects? Oliver Lemm APEX Connect ... folder structure trunk/ ... JSON, REST,

38

Presentations by MT AG

Dienstag, 26. April Mittwoch, 17. April Donnerstag, 28. April

14.00 Uhr | Music Hall 1

Echtzeitvisualisierung von Twitter und Co.

| Kai Donato & Oliver Lemm

16.15 Uhr | Music Hall 2

12.00 Uhr | Soul

14.00 Uhr | Music Hall 3

14.00 Uhr | Jazz 1

16.15 Uhr | Music Hall 1

11.00 Uhr | Music Hall 1

11.00 Uhr | Music Hall 3

14.00 Uhr | Music Hall 2

Universal Theme vs. APEX mobile vs.

MAF

| Davide Groppuso & Steven Grzbielok

WebSocket my APEX!

| Kai Donato

Single Sign-On für alle!

| Niels de Bruijn

Workshop: Einstieg in die aktuelle Version

von Oracle Application Express

| Oliver Lemm

Wie versioniere ich in APEX?

| Oliver Lemm

Interactive Reports Downloads Reloaded

| Moritz Klein

Zeitreisen mit PL/SQL

| Daniel Dyla

APEX for mobile only. Gewusst wie!

| Alexej Schneider