Skip to content
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

14.1 (Devel) upgrade script always fails at DB upgrade due to hard-coded DB version (14.0) #8390

Open
E-ThanG opened this issue Nov 14, 2024 · 0 comments

Comments

@E-ThanG
Copy link
Contributor

E-ThanG commented Nov 14, 2024

Describe the bug

  1. The development PF branch fails to upgrade the database with the error message "PREVIOUS VERSION 14.1 DOES NOT MATCH 14.0" regardless of which previous DB version is entered. The upgrade script asks for that information, but then ignores it and uses the hard-coded values. The issue probably exists because 14.1 is not the released version, the DB script upgrade-X.X-X.Y.sql has 14.0 as the hard coded previous version. That's the only version that we can possibly be upgrading from? This means that an upgrade from 14.0 to 14.1 works. But "upgrading" from 14.1 to 14.1 doesn't.
upgrade-X.X-X.Y.sql  contents:
SET @PREV_MAJOR_VERSION = 14;
SET @PREV_MINOR_VERSION = 0;
  1. Why does it ask for the old version but then ignore the input?
  2. Why is it asking questions at all? It can programmatically determine the old DB version since it's in the database and it already knows the version that the upgrade IS.
  3. The text "You need to input the PF version that comes before $UPGRADE_TO" is not clear. It should say "What database version are you upgrading from? :" or something to that effect. But as I mention above, it really shouldn't be asking at all.
  4. If I am staying in 14.1, it shouldn't be trying to upgrade the database at all, unless it really needs to.

To Reproduce
Steps to reproduce the behavior:

  1. Update 14.1 with the upgrade script
  2. See error "PREVIOUS VERSION 14.1 DOES NOT MATCH 14.0" failure.
Upgrade to a devel package detected. Renaming DB upgrade schema accordingly
---------------------------------------------------------------------------------
You need to input the PF version that comes before 14.1. This will replace X.X in the upgrade-X.X-X.Y.sql filename. Only input the minor version (ex: 11.2): 14.1
=================================================================================
Database pf runs version 14.1
Found upgrade path: /usr/local/pf/db/upgrade-14.1-14.1.sql
---------------------------------------------------------------------------------
Running /usr/local/pf/db/upgrade-14.1-14.1.sql
--------------
SET sql_mode = "NO_ENGINE_SUBSTITUTION"
--------------

--------------
SET @MAJOR_VERSION = 14
--------------

--------------
SET @MINOR_VERSION = 1
--------------

--------------
SET @PREV_MAJOR_VERSION = 14
--------------

--------------
SET @PREV_MINOR_VERSION = 0
--------------

--------------
SET @VERSION_INT = @MAJOR_VERSION << 16 | @MINOR_VERSION << 8
--------------

--------------
SET @PREV_VERSION_INT = @PREV_MAJOR_VERSION << 16 | @PREV_MINOR_VERSION << 8
--------------

--------------
DROP PROCEDURE IF EXISTS ValidateVersion
--------------

--------------
CREATE PROCEDURE ValidateVersion()
BEGIN
    DECLARE PREVIOUS_VERSION int(11);
    DECLARE PREVIOUS_VERSION_STRING varchar(11);
    DECLARE _message varchar(255);
    SELECT id, version INTO PREVIOUS_VERSION, PREVIOUS_VERSION_STRING FROM pf_version ORDER BY id DESC LIMIT 1;

      IF PREVIOUS_VERSION != @PREV_VERSION_INT THEN
        SELECT CONCAT('PREVIOUS VERSION ', PREVIOUS_VERSION_STRING, ' DOES NOT MATCH ', CONCAT_WS('.', @PREV_MAJOR_VERSION, @PREV_MINOR_VERSION)) INTO _message;
        SIGNAL SQLSTATE VALUE '99999'
              SET MESSAGE_TEXT = _message;
      END IF;
END
--------------

Checking PacketFence schema version...
--------------
call ValidateVersion
--------------

ERROR 1644 (99999) at line 50: PREVIOUS VERSION 14.1 DOES NOT MATCH 14.0

Expected behavior
dev->dev branch upgrade should work

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