Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-83008

As a developer I want a SF rule to know the proper schema version to be applied after some upgrade changes

    Details

      Description

      Since DXP 7.0 (in case of modules) and DXP 7.1 (also for the Core) the concept of schema version is really important anytime we need to create a new upgrade process.

      To help developers to define the schema version properly we should create a SF rule which checks the modifications and allows/forces to use the proper schema version.

      Technical proposal for the rule:
      The schema version follows the formula MAJOR.MINOR.MICRO so we should verify from the most to the least restrictive digit to know which kind of change we should apply for every case.

      Checking the modifications made by a certain new commits we should:

      • Warn about the need of made a MAJOR change in case of:
        • DB field is removed. This happens when:
          • The following is found in Java/SQL files: "alter table #tableName drop column"
          • The following is found in Java files: "AlterTableDropColumn"
        • DB table is removed. This happens when:
          • The following is found in Java/SQL files: "drop table"
        • DB Column name is changed:
          • The following is found in Java files: "AlterColumnName"
        • Decreasing the size of a DB field:
          • The following is found in Java files: "AlterColumnType" and the changes in the file _tables.sql _ consist on modify VARCHAR(X) by VARCHAR(Y) being Y smaller than X.
        • DB column type is changed:
          • The following is found in Java files: "AlterColumnType" and the changes in the file _tables.sql _ consist on modifying the type except from VARCHAR to TEXT (in that case we have to allow it since it depends on the nature of the modification)
      • Warn about the need of made a MINOR change in case of:
        • New DB field is added. This happens when:
          • The following is found in Java/SQL files: "alter table #tableName add "
          • The following is found in Java files: "AlterTableAddColumn"
        • New DB table is added:
          • The following is found in Java/SQL files: "create table"

      So in case we detect some of these changes we should show that the changes are MAJOR or MINOR, being MICRO otherwise.

      Additionally, instead of show a warning we should be able to suggest one specific schema version. To achieve that we should check the new upgrade process and its schema version:

      • For modules: find "registry.register(" and get the schemaVersion from second parameter.
      • For the Core: find "upgradeProcesses.put(" and extract the schemaVersion from the first parameter which this format Version("2.0.0")

      If we assume that:

      • Micro digit is zero and minor digit is zero -> major change
      • Only micro digit is zero -> minor change
      • Micro digit is not zero -> micro change

      We will be able to suggest the proper schema version to the developer taking into account the first explained rules.

      If we got any error recovering the schema version (two upgrade processes modifed or no new upgrade processes added) we should show at least the first warning.

      Thanks.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Packages

                Version Package
                7.1.X
                Master