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

schema: Fix broken upgrade script 1.3.0 #856

Merged
merged 1 commit into from
Dec 6, 2024
Merged

Conversation

yhabteab
Copy link
Member

PR #792 mistakenly added a NOT NULL clause to a nullable columns. This PR corrects that by dropping that clause and adding a DEFAULT NULL clause, making it consistent the actual schema file.

fixes #855

@yhabteab yhabteab added bug Something isn't working area/schema labels Nov 15, 2024
@yhabteab yhabteab added this to the 1.3.0 milestone Nov 15, 2024
@yhabteab yhabteab requested a review from oxzi November 15, 2024 13:12
@cla-bot cla-bot bot added the cla/signed label Nov 15, 2024
oxzi
oxzi previously approved these changes Nov 15, 2024
Copy link
Member

@oxzi oxzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. That should not have happened. Thanks to @alamp1360 for trying out the current development state.

The fix looks good. To make sure, I have compared the schema change and update script from #792 again.

Thanks for fixing!

PR #792 mistakenly added a `NOT NULL` clause to a nullable columns. This
PR corrects that by dropping that clause and adding a `DEFAULT NULL`
clause, making it consistent the actual schema file.
@yhabteab
Copy link
Member Author

Sorry, but I had to force push again because of this :), but it should be fine now!

4c4
< -- Host: localhost    Database: icingadb
---
> -- Host: localhost    Database: test_test
99c99
<   `argument_key_override` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
---
>   `argument_key_override` varchar(255) DEFAULT NULL,
393c393
<   `argument_key_override` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
---
>   `argument_key_override` varchar(255) DEFAULT NULL,
726c726
< ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
---
> ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
931c931
<   `argument_key_override` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
---
>   `argument_key_override` varchar(255) DEFAULT NULL,
1478c1478
< -- Dump completed on 2024-11-20 12:39:24
---
> -- Dump completed on 2024-11-20 12:39:36

@yhabteab yhabteab requested a review from oxzi November 20, 2024 12:48
Copy link
Member

@oxzi oxzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again!

@oxzi oxzi mentioned this pull request Dec 6, 2024
7 tasks
@oxzi oxzi self-assigned this Dec 6, 2024
@oxzi oxzi self-requested a review December 6, 2024 10:12
Copy link
Member

@oxzi oxzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ docker run --name mariadb -e MARIADB_ROOT_PASSWORD=supersicher -p 3306:3306 -d mariadb:latest

$ docker exec -it mariadb mariadb --password=supersicher --binary-as-hex
MariaDB [(none)]> create database icingadb;
MariaDB [(none)]> ^D

$ git checkout v1.2.0

$ docker exec -i mariadb mariadb -p --password=supersicher --binary-as-hex icingadb < schema/mysql/schema.sql

$ git checkout broken-upgrade-script
$ git rev-parse HEAD
f7cef3679980f36b466258783db98826d08dd253

$ docker exec -i mariadb mariadb -p --password=supersicher --binary-as-hex icingadb < schema/mysql/upgrades/1.3.0.sql

$ docker exec -it mariadb mariadb-dump -p --password=supersicher icingadb > pr856-after-upgrade.sql

$ docker exec -it mariadb mariadb --password=supersicher --binary-as-hex
MariaDB [(none)]> drop database icingadb;
MariaDB [(none)]> create database icingadb;
MariaDB [(none)]> ^D

$ docker exec -i mariadb mariadb -p --password=supersicher --binary-as-hex icingadb < schema/mysql/schema.sql
$ docker exec -it mariadb mariadb-dump -p --password=supersicher icingadb > pr856-schema-import.sql

$ diff -u pr856-*
--- pr856-after-upgrade.sql     2024-12-06 11:28:12.326222486 +0100
+++ pr856-schema-import.sql     2024-12-06 11:29:34.374459652 +0100
@@ -966,7 +966,7 @@
   `version` smallint(5) unsigned NOT NULL,
   `timestamp` bigint(20) unsigned NOT NULL,
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
 /*!40101 SET character_set_client = @saved_cs_client */;

 --
@@ -976,8 +976,7 @@
 LOCK TABLES `icingadb_schema` WRITE;
 /*!40000 ALTER TABLE `icingadb_schema` DISABLE KEYS */;
 INSERT INTO `icingadb_schema` VALUES
-(1,5,1733480520000),
-(2,6,1733480684000);
+(1,6,1733480964000);
 /*!40000 ALTER TABLE `icingadb_schema` ENABLE KEYS */;
 UNLOCK TABLES;

@@ -2027,4 +2026,4 @@
 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
 /*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */;

--- Dump completed on 2024-12-06 10:28:12
+-- Dump completed on 2024-12-06 10:29:34

@oxzi oxzi merged commit f923d6f into main Dec 6, 2024
32 checks passed
@oxzi oxzi deleted the broken-upgrade-script branch December 6, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/schema bug Something isn't working cla/signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schema update to version 6 produces error
2 participants