Skip to content

Detect usage of the strings for numeric/boolean types in Liquibase migrations #1111

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

Open
php-coder opened this issue Aug 16, 2019 · 12 comments

Comments

@php-coder
Copy link
Owner

php-coder commented Aug 16, 2019

We should use valueBoolean in this case --https://www.liquibase.org/documentation/column.html

@php-coder
Copy link
Owner Author

Another case that hasn't been spotted in #1107:

<column name="series_id" value="1" />
<column name="number_of_stamps" value="1" />

@php-coder php-coder added this to the 0.4.1 milestone Aug 25, 2019
@php-coder
Copy link
Owner Author

It seems like we can use git grep value="\d+" for finding valueNumeric candidates and git grep value="TRUE|true|FALSE|false" for valueBoolean

@php-coder php-coder modified the milestones: 0.4.1, 0.4.2 Sep 8, 2019
@php-coder php-coder modified the milestones: 0.4.2, next Nov 6, 2019
@php-coder
Copy link
Owner Author

Another idea is to detect usage of old schema: http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd instead of 3.1

@php-coder
Copy link
Owner Author

Yet another one: each <changeSet> must have context attribute with supported values.

@php-coder
Copy link
Owner Author

php-coder commented Dec 2, 2019

One more gotcha -- MySQL doesn't support beforeColumn -- https://liquibase.jira.com/browse/CORE-2347

Update: use afterColumn where possible

@php-coder
Copy link
Owner Author

We can also force a foreign keys to have a name. Also we can check that date fields have names with suffix "_at" and fields that references users have suffix "_by".

@php-coder
Copy link
Owner Author

  • unique constraint naming: uc_<table>_<field>
  • foreign constraint naming: fk_<table>_<field>
  • always specify uniqueConstraintName attribute when unique="true" is used to set a predictable name for the constraint

@php-coder
Copy link
Owner Author

modifyDataType mustn't be used with NOT NULL fields as it loses this property (see #1266)

@php-coder
Copy link
Owner Author

php-coder commented Mar 11, 2020

It has turned out that columnDataType is required for addNotNullConstraint on mysql

@php-coder
Copy link
Owner Author

Yet another one: each must have context attribute with supported values.

Liquibase 4.5.0 has introduced quality checks and at least it has a rule to ensure that every changeset has a context attribute: https://docs.liquibase.com/concepts/advanced/configuring-quality-checks.html#Ensure2

@php-coder
Copy link
Owner Author

It has turned out that columnDataType is required for setColumnRemarks on mysql

@php-coder
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant