Skip to content

Initialize Spring Data JDBC schema generation module #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2025

Conversation

rashidi
Copy link
Owner

@rashidi rashidi commented Apr 13, 2025

No description provided.

This commit adds a new module for generating Liquibase changesets
based on Spring Data JDBC entities. It includes domain models,
repositories, test configurations, and examples to automate schema
migration script generation.
@rashidi rashidi added the enhancement New feature or request label Apr 13, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @rashidi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request introduces a new module for generating Liquibase changesets from Spring Data JDBC entities. This allows for automated database schema migration script creation based on the domain model. The changes include adding necessary dependencies, entity classes (Book, Author), repository interfaces, a test configuration using Testcontainers, and a test case to generate the Liquibase changeset. Additionally, the pull request includes documentation in README.adoc and a dedicated AsciiDoc page.

Highlights

  • Module Initialization: Initializes the data-jdbc-schema-generation module, providing functionality to generate Liquibase changesets.
  • Dependency Management: Adds dependencies for Spring Data JDBC, Liquibase, PostgreSQL, and Testcontainers to the module's build.gradle file.
  • Entity Definition: Defines Book and Author entities with appropriate annotations for Spring Data JDBC, including @Table, @Id, and @MappedCollection.
  • Repository Interfaces: Creates BookRepository and AuthorRepository interfaces extending CrudRepository to enable basic CRUD operations.
  • Test Configuration: Sets up a test configuration using Testcontainers to provide a PostgreSQL database for integration tests.
  • Changeset Generation: Implements a test case (BookRepositoryTests) that uses LiquibaseChangeSetWriter to generate a Liquibase changeset from the defined entities.
  • Documentation: Adds documentation in README.adoc and a dedicated AsciiDoc page (data-jdbc-schema-generation.adoc) explaining how to use the module.

Changelog

Click here to see the changelog
  • README.adoc
    • Added a link to the new data-jdbc-schema-generation tutorial in the table of contents.
  • data-jdbc-schema-generation/.gitattributes
    • Added a .gitattributes file to handle line endings for different file types.
  • data-jdbc-schema-generation/.gitignore
    • Added a .gitignore file to exclude build artifacts, IDE configuration files, and other unnecessary files from version control.
  • data-jdbc-schema-generation/README.adoc
    • Created a comprehensive README file explaining the purpose and usage of the module, including background information, domain model details, repository interfaces, changeset generation process, test configuration, and usage instructions.
  • data-jdbc-schema-generation/build.gradle
    • Configured the build.gradle file with necessary plugins, dependencies, and Java toolchain settings for the module.
  • data-jdbc-schema-generation/settings.gradle
    • Defined the root project name for the module.
  • data-jdbc-schema-generation/src/main/java/zin/rashidi/boot/jdbcscgm/DataJdbcSchemaGenerationApplication.java
    • Created a basic Spring Boot application class.
  • data-jdbc-schema-generation/src/main/java/zin/rashidi/boot/jdbcscgm/book/Author.java
    • Defined the Author entity class with @Table and @Id annotations.
  • data-jdbc-schema-generation/src/main/java/zin/rashidi/boot/jdbcscgm/book/AuthorRepository.java
    • Created the AuthorRepository interface extending CrudRepository.
  • data-jdbc-schema-generation/src/main/java/zin/rashidi/boot/jdbcscgm/book/Book.java
    • Defined the Book entity class with @Table, @Id, and @MappedCollection annotations.
  • data-jdbc-schema-generation/src/main/java/zin/rashidi/boot/jdbcscgm/book/BookRepository.java
    • Created the BookRepository interface extending CrudRepository.
  • data-jdbc-schema-generation/src/main/resources/application.properties
    • Set the spring.application.name property.
  • data-jdbc-schema-generation/src/main/resources/db/changelog/db.changelog-master.yaml
    • Configured the master Liquibase changelog file to include the user.yaml changeset.
  • data-jdbc-schema-generation/src/main/resources/db/changelog/user.yaml
    • Added a sample Liquibase changeset file (likely auto-generated).
  • data-jdbc-schema-generation/src/test/java/zin/rashidi/boot/jdbcscgm/DataJdbcSchemaGenerationApplicationTests.java
    • Created a basic Spring Boot test class.
  • data-jdbc-schema-generation/src/test/java/zin/rashidi/boot/jdbcscgm/TestDataJdbcSchemaGenerationApplication.java
    • Created a test application class that includes the Testcontainers configuration.
  • data-jdbc-schema-generation/src/test/java/zin/rashidi/boot/jdbcscgm/TestcontainersConfiguration.java
    • Configured Testcontainers to provide a PostgreSQL container for testing.
  • data-jdbc-schema-generation/src/test/java/zin/rashidi/boot/jdbcscgm/book/BookRepositoryTests.java
    • Implemented a test case to generate the Liquibase changeset using LiquibaseChangeSetWriter.
  • docs/modules/ROOT/nav.adoc
    • Added a link to the new data-jdbc-schema-generation.adoc documentation page in the navigation.
  • docs/modules/ROOT/pages/data-jdbc-schema-generation.adoc
    • Created a comprehensive AsciiDoc page explaining the purpose and usage of the module, mirroring the content of the README file.
  • settings.gradle
    • Included the data-jdbc-schema-generation module in the overall project settings.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A database's silent plea,
For structure, clear to see,
Liquibase's grace,
Finds its rightful place,
Migrations set it free.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new module for generating Liquibase changesets from Spring Data JDBC entities. The changes include adding a new tutorial, updating the settings.gradle file, and creating the necessary source code and test files. Overall, the code is well-structured and the tutorial provides a clear explanation of how to use the new module. However, there are a few areas that could be improved.

Summary of Findings

  • Missing License Headers: The new Java files in the data-jdbc-schema-generation module are missing license headers. It's important to include these headers for legal and attribution purposes. While I am not making repeated comments on this, please ensure that all Java files have the appropriate license headers.
  • Inconsistent use of @DataJdbcTest properties: In the BookRepositoryTests class, the spring.liquibase.enabled=false property is commented out. This inconsistency should be addressed to ensure the test behaves as expected.
  • README improvements: The README files could benefit from minor improvements in wording and formatting to enhance readability and clarity.

Merge Readiness

The pull request is almost ready for merging. However, the missing license headers and the inconsistency in the @DataJdbcTest properties should be addressed before merging. The README improvements are minor and can be addressed at the author's discretion. I am unable to approve the pull request, and recommend that others review and approve this code before merging.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@rashidi rashidi merged commit a003571 into master Apr 13, 2025
6 of 7 checks passed
@rashidi rashidi deleted the data/jdbc-schema-generation branch April 13, 2025 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant