Skip to content

Commit

Permalink
Fix failing schema validation for mysql when boolean/enum is used
Browse files Browse the repository at this point in the history
  • Loading branch information
pmohan committed Jul 18, 2024
1 parent 67913b6 commit 8544837
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ spring:
# modify fetch size as necessary
hibernate.jdbc.fetch_size: 150
hibernate.criteria.literal_handling_mode: BIND
<%_ if (prodDatabaseTypeMysql) { _%>
hibernate.type.preferred_boolean_jdbc_type: TINYINT
<%_ } _%>
<%_ } _%>
hibernate.query.fail_on_pagination_over_collection_fetch: true
hibernate.query.in_clause_parameter_padding: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import org.hibernate.type.SqlTypes;
@JdbcTypeCode(SqlTypes.VARCHAR)
@Column(name = "<%- field.fieldNameAsDatabaseColumn %>", length = 36<% if (field.fieldValidationRequired) { %>, nullable = false<% } %><% if (field.fieldValidationUnique) { %>, unique = true<% } %>)
<%_ } else { _%>
@Column(name = "<%- field.fieldNameAsDatabaseColumn %>"<% if (field.fieldValidate === true) { %><% if (field.fieldValidationMaxLength) { %>, length = <%= field.fieldValidateRulesMaxlength %><% } %><% if (field.fieldValidationRequired) { %>, nullable = false<% } %><% if (field.fieldValidationUnique) { %>, unique = true<% } %><% } %>)
@Column(name = "<%- field.fieldNameAsDatabaseColumn %>"<% if (field.fieldValidate === true) { %><% if (field.fieldValidationMaxLength) { %>, length = <%= field.fieldValidateRulesMaxlength %><% } %><% if (field.fieldValidationRequired) { %>, nullable = false<% } %><% if (field.fieldValidationUnique) { %>, unique = true<% } %><% } %><% if (field.fieldIsEnum && prodDatabaseTypeMysql) { %>, columnDefinition = "VARCHAR(255)"<% } %>)
<%_ } _%>
<&_ } -&>
<%_ } -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ spring:
jpa:
open-in-view: false
hibernate:
<%_ if (devDatabaseTypeMysql) { _%>
ddl-auto: validate
<%_ } else { _%>
ddl-auto: none
<%_ } _%>
naming:
physical-strategy: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
Expand All @@ -75,10 +79,17 @@ spring:
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: false
<%_ if (devDatabaseTypeMysql) { _%>
hibernate.hbm2ddl.auto: validate
<%_ } else { _%>
hibernate.hbm2ddl.auto: none #TODO: temp relief for integration tests, revisit required
<%_ } _%>
hibernate.type.preferred_instant_jdbc_type: TIMESTAMP
hibernate.jdbc.time_zone: UTC
hibernate.timezone.default_storage: NORMALIZE
hibernate.query.fail_on_pagination_over_collection_fetch: true
<%_ if (devDatabaseTypeMysql) { _%>
hibernate.type.preferred_boolean_jdbc_type: TINYINT
<%_ } _%>
<%_ } _%>

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ spring:
jpa:
open-in-view: false
hibernate:
<%_ if (prodDatabaseTypeMysql) { _%>
ddl-auto: validate
<%_ } else { _%>
ddl-auto: none
<%_ } _%>
naming:
physical-strategy: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
Expand All @@ -63,8 +67,15 @@ spring:
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: false
<%_ if (prodDatabaseTypeMysql) { _%>
hibernate.hbm2ddl.auto: validate
<%_ } else { _%>
hibernate.hbm2ddl.auto: none #TODO: temp relief for integration tests, revisit required
<%_ } _%>
hibernate.type.preferred_instant_jdbc_type: TIMESTAMP
hibernate.jdbc.time_zone: UTC
hibernate.timezone.default_storage: NORMALIZE
hibernate.query.fail_on_pagination_over_collection_fetch: true
<%_ if (prodDatabaseTypeMysql) { _%>
hibernate.type.preferred_boolean_jdbc_type: TINYINT
<%_ } _%>

0 comments on commit 8544837

Please sign in to comment.