SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
Agile Database Modelling
 New GORM Features in Grails 1.4

         Prepared for SF Grails Café Centro
                    March 2011
                 by Christian Hang




      Thanks to Taulia for hosting and food!!
Agenda

 New (GORM) Features in Grails 1.4
 Quick intro to H2
 Reverse Engineering
 Database Migrations
 Other new Grails 1.4 features
 Summary
New (GORM) Features in Grails 1.4

 Replace HQSQL with H2
   Best-of-bread in-memory DB
   Built-in web console
New (GORM) Features in Grails 1.4

 Replace HQSQL with H2
   Best-of-breed in-memory DB
   Built-in web console
 Reverse Engineering
   Based on Hibernate's reverse engineering
   Create GORM classes from existing DB
New (GORM) Features in Grails 1.4

 Replace HQSQL with H2
   Best-of-bread in-memory DB
   Built-in web console
 Reverse Engineering
    Based on Hibernate's reverse engineering
    Create GORM classes from existing DB
 Database Migrations
   Based on Liquibase
   "Revision" the DB
   Allows track/rollback schema changes
Current Status

  No hard dependencies on Grails 1.4
  Everything available as plugins today
  Both main features developed by Burt Beckwith
Current Status

  No hard dependencies on Grails 1.4
  Everything available as plugins today
  Both main features developed by Burt Beckwith
  H2 plugin or JAR dependency
    com.h2database:h2:1.2.147
Current Status

  No hard dependencies on Grails 1.4
  Everything available as plugins today
  Both main features developed by Burt Beckwith
  H2 plugin or JAR dependency
    com.h2database:h2:1.2.147
  Reverse Engineering
    http://grails-plugins.github.com/grails-db-reverse-engineer/
    grails install-plugin db-reverse-engineer
    latest version 0.3
Current Status

  No hard dependencies on Grails 1.4
  Everything available as plugins today
  Both main features developed by Burt Beckwith
  H2 plugin or JAR dependency
    com.h2database:h2:1.2.147
  Reverse Engineering
    http://grails-plugins.github.com/grails-db-reverse-engineer/
    grails install-plugin db-reverse-engineer
    latest version 0.3
  Database Migrations
    http://grails-plugins.github.com/grails-database-migration/
    grails install-plugin database-migration
    latest version 0.2
Take your DB tools with you
H2 in Grails 1.4

  Replaces HSQLDB
  support in-memory, file-based, clustered DB
  comes with a build-in web console
    http://localhost:8080/appname/dbconsole
  Available as (insecure) plugin today
Use legacy databases
in Grails even faster!
Reverse Engineering

 Existing DB + Grails command = GORM classes
Reverse Engineering

 Existing DB + Grails command = GORM classes
 Uses DB connection from DataSource.groovy
 Configuration in grails-app/conf/Config.groovy
 Started with grails db-reverse-engineer
Reverse Engineering

   Existing DB + Grails command = GORM classes
   Uses DB connection from DataSource.groovy
   Configuration in grails-app/conf/Config.groovy
   Started with grails db-reverse-engineer
   Detailed configuration available
      covers many-to-many relations
      include/exclude tables, columns etc.
   Creates belongsTo, hasMany and constraints
Simplest configuration:
grails.plugin.reveng.packageName = com.acme.db
Demo Reverse Engineering
The good and the bad

 Recognizes length limitations & constraints
 Creates relates between entities
 Even handles composite primary keys
The good and the bad

 Recognizes length limitations & constraints
 Creates relates between entities
 Even handles composite primary keys
 Careful: Will probably not get it 100% correct!
 Always review generated classes
The good and the bad

 Recognizes length limitations & constraints
 Creates relates between entities
 Even handles composite primary keys
 Careful: Will probably not get it 100% correct!
 Always review generated classes
 Still helps to save a lot of work
Your source code is in VCS,
but do you version your DB?
Database Migrations

 Liquibase: verbose XML schema changesets
Database Migrations

    Liquibase: verbose XML schema changesets
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
       http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
  <changeSet author="christianhang (generated)" id="1300172497244-1">
       <createTable tableName="BLURB">
         <column autoIncrement="true" name="ID" type="BIGINT">
            <constraints nullable="false" primaryKey="true"
               primaryKeyName="CONSTRAINT_3"/>
         </column>
         <column name="VERSION" type="BIGINT">
            <constraints nullable="false"/>
         </column>
         <column name="CONTENT" type="VARCHAR(100000)"/>
         <column name="NAME" type="VARCHAR(255)">
            <constraints nullable="false"/>
         </column>
       </createTable>
  </changeSet>
  ....
Database Migrations

 Liquibase: verbose XML schema changesets
 Plugin: Groovy changesets & automation
Database Migrations

       Liquibase: verbose XML schema changesets
       Plugin: Groovy changesets & automation
  databaseChangeLog = {

changeSet(author: "christianhang (generated)", id: "1300168672278-1") {
createTable(tableName: "BLURB") {
column(autoIncrement: "true", name: "ID", type: "BIGINT") {
constraints(nullable: "false", primaryKey: "true",
                        primaryKeyName: "CONSTRAINT_3")
}

column(name: "VERSION", type: "BIGINT") {
constraints(nullable: "false")
}

column(name: "CONTENT", type: "VARCHAR(100000)")

column(name: "NAME", type: "VARCHAR(255)") {
constraints(nullable: "false")
}
}
}
     ...
Database Migrations

    Liquibase: verbose XML schema changesets
    Plugin: Groovy changesets & automation
Automatically generate changelogs
    grails dbm-generate-changelog changelog.groovy
grails dbm-gorm-diff


Apply changelogs to database
grails dbm-changelog-sync changelog.groovy
grails dbm-update

Rollback changes
grails dbm-rollback-count
grails dbm-rollback-to-date
Database Migrations

 Liquibase: verbose XML schema changesets
 Plugin: Groovy changesets & automation
 Two options
    track changes manually (changeset first)
    create automatic diffs (GORM first)
Database Migrations

 Liquibase: verbose XML schema changesets
 Plugin: Groovy changesets & automation
 Two options
    track changes manually (changeset first)
    create automatic diffs (GORM first)
 Allows to track schema changes in VCS
    Create DB from scratch
    Apply/rollback incremental changes
Database Migrations

 Liquibase: verbose XML schema changesets
 Plugin: Groovy changesets & automation
 Two options
    track changes manually (changeset first)
    create automatic diffs (GORM first)
 Allows to track schema changes in VCS
    Create DB from scratch
    Apply/rollback incremental changes
 Possibilities:
    Simplifies development with changing DB
    Manage updates to production DB
Demo Database Migrations
Issues to watch out for

  BACKUP your database!
  Always review automatic changesets!
Issues to watch out for

  BACKUP your database!
  Always review automatic changesets!
  Indexes, triggers etc. might be missed
  Checksum errors
     Changes tracked by filename in
    grails-app/conf/migrations/xxxx.groovy
    It doesn't like changeset changes
Summary

 New goodies before Grails 1.4 release
 Lots of automation when working with databases
 Reverse Engineering simplifies app setup
 Best practice: Version your DB
References

http://grails-plugins.github.com/grails-db-reverse-
engineer/docs/manual/index.html

http://grails-plugins.github.com/grails-db-reverse-
engineer/docs/manual/index.html

http://fbflex.wordpress.com/2011/01/19/working-with-the-grails-
database-migration-plugin/

http://burtbeckwith.com/blog/?p=376
Contact
 Email: christian.hang@gmail.com
 Twitter: @livingtocode
 Blog: livingtocode.com




                                          http://sfgrails.com
                                          @sfgrails


Thanks to Taulia for hosting and food!!

Mais conteúdo relacionado

Mais procurados

Building and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextBuilding and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextSvilen Sabev
 
Dropwizard and Groovy
Dropwizard and GroovyDropwizard and Groovy
Dropwizard and Groovytomaslin
 
Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7Phase2
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...Sencha
 
A year in the life of a Grails startup
A year in the life of a Grails startupA year in the life of a Grails startup
A year in the life of a Grails startuptomaslin
 
Drupal 6 to 7 migration guide
Drupal 6 to 7 migration guideDrupal 6 to 7 migration guide
Drupal 6 to 7 migration guideEbizon
 
BOSH / CF Deployment in modern ways #cf_tokyo
BOSH / CF Deployment in modern ways #cf_tokyoBOSH / CF Deployment in modern ways #cf_tokyo
BOSH / CF Deployment in modern ways #cf_tokyoToshiaki Maki
 
AWS Summit Berlin 2012 Talk on Web Data Commons
AWS Summit Berlin 2012 Talk on Web Data CommonsAWS Summit Berlin 2012 Talk on Web Data Commons
AWS Summit Berlin 2012 Talk on Web Data CommonsHannes Mühleisen
 
Google AppEngine (GAE/J) - Introduction and Overview from a Java Guy
Google AppEngine (GAE/J) - Introduction and Overview from a Java GuyGoogle AppEngine (GAE/J) - Introduction and Overview from a Java Guy
Google AppEngine (GAE/J) - Introduction and Overview from a Java GuyMax Völkel
 
The Play Framework at LinkedIn
The Play Framework at LinkedInThe Play Framework at LinkedIn
The Play Framework at LinkedInYevgeniy Brikman
 
Migration from Legacy CMS to Drupal
Migration from Legacy CMS to DrupalMigration from Legacy CMS to Drupal
Migration from Legacy CMS to DrupalRachel Jaro
 
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...
Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...hannonhill
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Ryan Cuprak
 
Volodymyr Lyubinets "Introduction to big data processing with Apache Spark"
Volodymyr Lyubinets "Introduction to big data processing with Apache Spark"Volodymyr Lyubinets "Introduction to big data processing with Apache Spark"
Volodymyr Lyubinets "Introduction to big data processing with Apache Spark"IT Event
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf
 
Webinar slides: Managing MySQL Replication for High Availability
Webinar slides: Managing MySQL Replication for High AvailabilityWebinar slides: Managing MySQL Replication for High Availability
Webinar slides: Managing MySQL Replication for High AvailabilitySeveralnines
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
 

Mais procurados (20)

Working with Git
Working with GitWorking with Git
Working with Git
 
Building and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextBuilding and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and Context
 
Dropwizard and Groovy
Dropwizard and GroovyDropwizard and Groovy
Dropwizard and Groovy
 
Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
 
A year in the life of a Grails startup
A year in the life of a Grails startupA year in the life of a Grails startup
A year in the life of a Grails startup
 
Apache Lucene for Java EE Developers
Apache Lucene for Java EE DevelopersApache Lucene for Java EE Developers
Apache Lucene for Java EE Developers
 
Drupal 6 to 7 migration guide
Drupal 6 to 7 migration guideDrupal 6 to 7 migration guide
Drupal 6 to 7 migration guide
 
BOSH / CF Deployment in modern ways #cf_tokyo
BOSH / CF Deployment in modern ways #cf_tokyoBOSH / CF Deployment in modern ways #cf_tokyo
BOSH / CF Deployment in modern ways #cf_tokyo
 
AWS Summit Berlin 2012 Talk on Web Data Commons
AWS Summit Berlin 2012 Talk on Web Data CommonsAWS Summit Berlin 2012 Talk on Web Data Commons
AWS Summit Berlin 2012 Talk on Web Data Commons
 
Google AppEngine (GAE/J) - Introduction and Overview from a Java Guy
Google AppEngine (GAE/J) - Introduction and Overview from a Java GuyGoogle AppEngine (GAE/J) - Introduction and Overview from a Java Guy
Google AppEngine (GAE/J) - Introduction and Overview from a Java Guy
 
Gradle ex-machina
Gradle ex-machinaGradle ex-machina
Gradle ex-machina
 
The Play Framework at LinkedIn
The Play Framework at LinkedInThe Play Framework at LinkedIn
The Play Framework at LinkedIn
 
Migration from Legacy CMS to Drupal
Migration from Legacy CMS to DrupalMigration from Legacy CMS to Drupal
Migration from Legacy CMS to Drupal
 
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...
Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]
 
Volodymyr Lyubinets "Introduction to big data processing with Apache Spark"
Volodymyr Lyubinets "Introduction to big data processing with Apache Spark"Volodymyr Lyubinets "Introduction to big data processing with Apache Spark"
Volodymyr Lyubinets "Introduction to big data processing with Apache Spark"
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
 
Webinar slides: Managing MySQL Replication for High Availability
Webinar slides: Managing MySQL Replication for High AvailabilityWebinar slides: Managing MySQL Replication for High Availability
Webinar slides: Managing MySQL Replication for High Availability
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 

Semelhante a Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup 2011-03

Liquibase – a time machine for your data
Liquibase – a time machine for your dataLiquibase – a time machine for your data
Liquibase – a time machine for your dataNeev Technologies
 
Liquibase - Open Source version control for your database
Liquibase - Open Source version control for your databaseLiquibase - Open Source version control for your database
Liquibase - Open Source version control for your databaseBlaine Carter
 
Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)
Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)
Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)Igalia
 
What’s New in Rails 5.0?
What’s New in Rails 5.0?What’s New in Rails 5.0?
What’s New in Rails 5.0?Unboxed
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database DeploymentsMike Willbanks
 
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...FIWARE
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database DesignAndrei Solntsev
 
Continuous DB migration based on carbon5 framework
Continuous DB migration based on carbon5 frameworkContinuous DB migration based on carbon5 framework
Continuous DB migration based on carbon5 frameworkb0ris_1
 
Борис Трофимов. Continuous Database migration-это просто!
Борис Трофимов. Continuous Database migration-это просто!Борис Трофимов. Continuous Database migration-это просто!
Борис Трофимов. Continuous Database migration-это просто!Volha Banadyseva
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaJason Noble
 
Grails 3.0 Preview
Grails 3.0 PreviewGrails 3.0 Preview
Grails 3.0 Previewgraemerocher
 
Big Bang And Beyond: Migrating Between Server and Cloud
Big Bang And Beyond: Migrating Between Server and CloudBig Bang And Beyond: Migrating Between Server and Cloud
Big Bang And Beyond: Migrating Between Server and CloudAtlassian
 
Sane SQL Change Management with Sqitch
Sane SQL Change Management with SqitchSane SQL Change Management with Sqitch
Sane SQL Change Management with SqitchDavid Wheeler
 
Take your database source code and data under control
Take your database source code and data under controlTake your database source code and data under control
Take your database source code and data under controlMarcin Przepiórowski
 
Offline strategies for HTML5 web applications - pfCongres2012
Offline strategies for HTML5 web applications - pfCongres2012Offline strategies for HTML5 web applications - pfCongres2012
Offline strategies for HTML5 web applications - pfCongres2012Stephan Hochdörfer
 
Digital Fabrication Studio v.0.2: Information
Digital Fabrication Studio v.0.2: InformationDigital Fabrication Studio v.0.2: Information
Digital Fabrication Studio v.0.2: InformationMassimo Menichinelli
 
Database Change Management as a Service
Database Change Management as a ServiceDatabase Change Management as a Service
Database Change Management as a ServiceAndrew Solomon
 

Semelhante a Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup 2011-03 (20)

Liquibase – a time machine for your data
Liquibase – a time machine for your dataLiquibase – a time machine for your data
Liquibase – a time machine for your data
 
Liquibase - Open Source version control for your database
Liquibase - Open Source version control for your databaseLiquibase - Open Source version control for your database
Liquibase - Open Source version control for your database
 
Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)
Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)
Igalia Focus and Goals 2020 (2019 WebKit Contributors Meeting)
 
What’s New in Rails 5.0?
What’s New in Rails 5.0?What’s New in Rails 5.0?
What’s New in Rails 5.0?
 
Grails Plugins
Grails PluginsGrails Plugins
Grails Plugins
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database Design
 
Continuous DB migration based on carbon5 framework
Continuous DB migration based on carbon5 frameworkContinuous DB migration based on carbon5 framework
Continuous DB migration based on carbon5 framework
 
Борис Трофимов. Continuous Database migration-это просто!
Борис Трофимов. Continuous Database migration-это просто!Борис Трофимов. Continuous Database migration-это просто!
Борис Трофимов. Continuous Database migration-это просто!
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
 
Liquibase
LiquibaseLiquibase
Liquibase
 
Grails 3.0 Preview
Grails 3.0 PreviewGrails 3.0 Preview
Grails 3.0 Preview
 
Big Bang And Beyond: Migrating Between Server and Cloud
Big Bang And Beyond: Migrating Between Server and CloudBig Bang And Beyond: Migrating Between Server and Cloud
Big Bang And Beyond: Migrating Between Server and Cloud
 
Sane SQL Change Management with Sqitch
Sane SQL Change Management with SqitchSane SQL Change Management with Sqitch
Sane SQL Change Management with Sqitch
 
Quickr
QuickrQuickr
Quickr
 
Take your database source code and data under control
Take your database source code and data under controlTake your database source code and data under control
Take your database source code and data under control
 
Offline strategies for HTML5 web applications - pfCongres2012
Offline strategies for HTML5 web applications - pfCongres2012Offline strategies for HTML5 web applications - pfCongres2012
Offline strategies for HTML5 web applications - pfCongres2012
 
Digital Fabrication Studio v.0.2: Information
Digital Fabrication Studio v.0.2: InformationDigital Fabrication Studio v.0.2: Information
Digital Fabrication Studio v.0.2: Information
 
Database Change Management as a Service
Database Change Management as a ServiceDatabase Change Management as a Service
Database Change Management as a Service
 

Último

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup 2011-03

  • 1. Agile Database Modelling New GORM Features in Grails 1.4 Prepared for SF Grails Café Centro March 2011 by Christian Hang Thanks to Taulia for hosting and food!!
  • 2. Agenda New (GORM) Features in Grails 1.4 Quick intro to H2 Reverse Engineering Database Migrations Other new Grails 1.4 features Summary
  • 3. New (GORM) Features in Grails 1.4 Replace HQSQL with H2 Best-of-bread in-memory DB Built-in web console
  • 4. New (GORM) Features in Grails 1.4 Replace HQSQL with H2 Best-of-breed in-memory DB Built-in web console Reverse Engineering Based on Hibernate's reverse engineering Create GORM classes from existing DB
  • 5. New (GORM) Features in Grails 1.4 Replace HQSQL with H2 Best-of-bread in-memory DB Built-in web console Reverse Engineering Based on Hibernate's reverse engineering Create GORM classes from existing DB Database Migrations Based on Liquibase "Revision" the DB Allows track/rollback schema changes
  • 6. Current Status No hard dependencies on Grails 1.4 Everything available as plugins today Both main features developed by Burt Beckwith
  • 7. Current Status No hard dependencies on Grails 1.4 Everything available as plugins today Both main features developed by Burt Beckwith H2 plugin or JAR dependency com.h2database:h2:1.2.147
  • 8. Current Status No hard dependencies on Grails 1.4 Everything available as plugins today Both main features developed by Burt Beckwith H2 plugin or JAR dependency com.h2database:h2:1.2.147 Reverse Engineering http://grails-plugins.github.com/grails-db-reverse-engineer/ grails install-plugin db-reverse-engineer latest version 0.3
  • 9. Current Status No hard dependencies on Grails 1.4 Everything available as plugins today Both main features developed by Burt Beckwith H2 plugin or JAR dependency com.h2database:h2:1.2.147 Reverse Engineering http://grails-plugins.github.com/grails-db-reverse-engineer/ grails install-plugin db-reverse-engineer latest version 0.3 Database Migrations http://grails-plugins.github.com/grails-database-migration/ grails install-plugin database-migration latest version 0.2
  • 10. Take your DB tools with you
  • 11. H2 in Grails 1.4 Replaces HSQLDB support in-memory, file-based, clustered DB comes with a build-in web console http://localhost:8080/appname/dbconsole Available as (insecure) plugin today
  • 12. Use legacy databases in Grails even faster!
  • 13. Reverse Engineering Existing DB + Grails command = GORM classes
  • 14. Reverse Engineering Existing DB + Grails command = GORM classes Uses DB connection from DataSource.groovy Configuration in grails-app/conf/Config.groovy Started with grails db-reverse-engineer
  • 15. Reverse Engineering Existing DB + Grails command = GORM classes Uses DB connection from DataSource.groovy Configuration in grails-app/conf/Config.groovy Started with grails db-reverse-engineer Detailed configuration available covers many-to-many relations include/exclude tables, columns etc. Creates belongsTo, hasMany and constraints Simplest configuration: grails.plugin.reveng.packageName = com.acme.db
  • 17. The good and the bad Recognizes length limitations & constraints Creates relates between entities Even handles composite primary keys
  • 18. The good and the bad Recognizes length limitations & constraints Creates relates between entities Even handles composite primary keys Careful: Will probably not get it 100% correct! Always review generated classes
  • 19. The good and the bad Recognizes length limitations & constraints Creates relates between entities Even handles composite primary keys Careful: Will probably not get it 100% correct! Always review generated classes Still helps to save a lot of work
  • 20. Your source code is in VCS, but do you version your DB?
  • 21. Database Migrations Liquibase: verbose XML schema changesets
  • 22. Database Migrations Liquibase: verbose XML schema changesets <?xml version="1.0" encoding="UTF-8" standalone="no"?> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd"> <changeSet author="christianhang (generated)" id="1300172497244-1"> <createTable tableName="BLURB"> <column autoIncrement="true" name="ID" type="BIGINT"> <constraints nullable="false" primaryKey="true" primaryKeyName="CONSTRAINT_3"/> </column> <column name="VERSION" type="BIGINT"> <constraints nullable="false"/> </column> <column name="CONTENT" type="VARCHAR(100000)"/> <column name="NAME" type="VARCHAR(255)"> <constraints nullable="false"/> </column> </createTable> </changeSet> ....
  • 23. Database Migrations Liquibase: verbose XML schema changesets Plugin: Groovy changesets & automation
  • 24. Database Migrations Liquibase: verbose XML schema changesets Plugin: Groovy changesets & automation databaseChangeLog = { changeSet(author: "christianhang (generated)", id: "1300168672278-1") { createTable(tableName: "BLURB") { column(autoIncrement: "true", name: "ID", type: "BIGINT") { constraints(nullable: "false", primaryKey: "true", primaryKeyName: "CONSTRAINT_3") } column(name: "VERSION", type: "BIGINT") { constraints(nullable: "false") } column(name: "CONTENT", type: "VARCHAR(100000)") column(name: "NAME", type: "VARCHAR(255)") { constraints(nullable: "false") } } } ...
  • 25. Database Migrations Liquibase: verbose XML schema changesets Plugin: Groovy changesets & automation Automatically generate changelogs grails dbm-generate-changelog changelog.groovy grails dbm-gorm-diff Apply changelogs to database grails dbm-changelog-sync changelog.groovy grails dbm-update Rollback changes grails dbm-rollback-count grails dbm-rollback-to-date
  • 26. Database Migrations Liquibase: verbose XML schema changesets Plugin: Groovy changesets & automation Two options track changes manually (changeset first) create automatic diffs (GORM first)
  • 27. Database Migrations Liquibase: verbose XML schema changesets Plugin: Groovy changesets & automation Two options track changes manually (changeset first) create automatic diffs (GORM first) Allows to track schema changes in VCS Create DB from scratch Apply/rollback incremental changes
  • 28. Database Migrations Liquibase: verbose XML schema changesets Plugin: Groovy changesets & automation Two options track changes manually (changeset first) create automatic diffs (GORM first) Allows to track schema changes in VCS Create DB from scratch Apply/rollback incremental changes Possibilities: Simplifies development with changing DB Manage updates to production DB
  • 30. Issues to watch out for BACKUP your database! Always review automatic changesets!
  • 31. Issues to watch out for BACKUP your database! Always review automatic changesets! Indexes, triggers etc. might be missed Checksum errors Changes tracked by filename in grails-app/conf/migrations/xxxx.groovy It doesn't like changeset changes
  • 32. Summary New goodies before Grails 1.4 release Lots of automation when working with databases Reverse Engineering simplifies app setup Best practice: Version your DB
  • 34. Contact Email: christian.hang@gmail.com Twitter: @livingtocode Blog: livingtocode.com http://sfgrails.com @sfgrails Thanks to Taulia for hosting and food!!