-
Notifications
You must be signed in to change notification settings - Fork 1
Fix Render Deployment - Database Schema Configuration #8
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Iyedchaabane/Book-Social-Network
Length of output: 130
🌐 Web query:
Spring Boot Hibernate ddl-auto production best practices and risks of using update in production environments💡 Result:
Production best practices (Spring Boot + Hibernate)
spring.jpa.hibernate.ddl-auto=updatein production. Prefer:none(Hibernate performs no schema changes), orvalidate(fails startup if schema doesn’t match mappings). (docs.spring.vmware.com)update/create/create-drop) can’t leak into prod. (runebook.dev)ddl-autotocreate-drop; otherwise it defaults tonone. Always set it explicitly for prod. (docs.spring.vmware.com)Key risks of
ddl-auto=updatein productionupdatecommonly adds tables/columns but often won’t handle renames, drops, or type changes correctly—leading to orphan columns, wrong column types, lingering constraints, and manual cleanup/migrations anyway. (stackoverflow.com)Citations:
🌐 Web query:
Flyway Liquibase database migration alternatives to Hibernate ddl-auto💡 Result:
Why replace
hibernate ddl-auto?Hibernate’s automatic schema generation (“HBM2DDL”) is great for testing/prototyping, but for production it’s “more flexible to manage the schema using incremental migration scripts.” [1]
Primary alternatives (versioned, repeatable, auditable migrations)
1) Flyway (SQL-first)
V<VERSION>__<NAME>.sqlunderclasspath:db/migration(configurable viaspring.flyway.locations). Spring Boot auto-runs them on startup whenflyway-coreis on the classpath. [2]Use it when: you prefer plain SQL, tight control over vendor-specific features, and a simple migration model.
2) Liquibase (changelogs: YAML/XML/JSON/SQL)
DATABASECHANGELOG(created automatically if missing). [4]runOnChange(checksum-based). [6]Use it when: you want higher-level, structured change definitions, environment targeting, and richer metadata.
What to set
ddl-autoto when using Flyway/Liquibasenone), optionally usingvalidateto detect mismatches at startup. (Spring Boot documents theddl-automodes likenone/validate/update/create/create-drop.) [7]Other (lighter) alternatives
schema.sql/data.sql) for simple initialization—but don’t combine it with Hibernate DDL generation. [7]Sources: Hibernate ORM User Guide on schema generation vs migrations [1]; Spring Boot docs on Flyway conventions/locations and auto-running migrations [2]; Flyway schema history table docs [3]; Liquibase docs on
DATABASECHANGELOG[4], contexts [5], andrunOnChange[6]; Spring Boot docs onddl-autovalues and initialization constraints [7].Citations: [1] (docs.jboss.org) [2] (docs.spring.io) [3] (documentation.red-gate.com) [4] (docs.liquibase.com) [5] (docs.liquibase.com) [6] (docs.liquibase.com) [7] (docs.spring.io)
Citations:
🏁 Script executed:
# Read the application-prod.yml file to see the actual configuration cat -n ./book-network/src/main/resources/application-prod.ymlRepository: Iyedchaabane/Book-Social-Network
Length of output: 2724
Replace
ddl-auto: updatewith environment-gated validation or use versioned migrations.Production environments should never auto-apply schema changes. Spring Boot and Hibernate documentation explicitly recommend against
ddl-auto=updatein production due to unreliable schema diffs (renames, drops, type changes often fail), missing DDL generation (indexes), concurrency race conditions in clustered startups, and no versioning/rollback capability.For initial deployment, use an environment variable override:
setting
HIBERNATE_DDL_AUTO=updateonly during bootstrap. For ongoing deployments, migrate to a proper migration tool (Flyway or Liquibase) to ensure reviewed, versioned, repeatable, auditable schema changes.🤖 Prompt for AI Agents