Package: release.debian.org
User: release.debian....@packages.debian.org
Usertags: pu
Tags: bullseye
Severity: normal

Dear release team,

[ Reason ]
Since ActiveRecord >= 6.0, the SQLite3 connection adapter relies on boolean
serialization to use 1 and 0, but does not natively recognize 't' and 'f' as
booleans were previously serialized. This change makes existing mailing lists
fail, after an upgrade of buster to bullseye, due to the involved ActiveRecord
version bump, as Schleuder isn't able anymore to fetch correct values from the
database.

Unfortunately, we missed this breaking change when bumping ActiveRecord to >=
6.0 recently. This caused quite some work upstream, but also in downstream
environments and, last but not least, at the side of users.

This was reported in Debian via #1002622, and fixed in unstable via 3.6.0-4.

[ Impact ]
Severe, as existing and formerly working setups are left broken, after an
upgrade of buster to bullseye. Manual workarounds do exist, and are documented
upstream [1].

[ Tests ]
Extensive testing happened via upstream CI and multiple, manual tests on
various machines which exhibit this problem. The fix is targeted and worked, in
these tests, as expected.

[ Risks ]
The fix was reviewed upstream to ensure it works as expected, and doesn't cause
any harm. It's guarded to only be effective in setups which makes use of
SQLite3, although that's the default, and probably true for the big majority of
Debian-based setups.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
The fix provided upstream was imported, which adds a database migration to
ensure correct serialization of boolean values, both defaults and
user-provided, if the SQLite3 connection adapter is in use.

Thanks for your work!

Cheers,
Georg


[1] https://0xacab.org/schleuder/schleuder/-/issues/505
diffstat for schleuder-3.6.0 schleuder-3.6.0

 changelog                                               |   12 ++
 patches/0031-db-change-boolean-values-to-integers.patch |   77 ++++++++++++++++
 patches/series                                          |    1 
 3 files changed, 90 insertions(+)

diff -Nru schleuder-3.6.0/debian/changelog schleuder-3.6.0/debian/changelog
--- schleuder-3.6.0/debian/changelog    2021-07-29 20:36:52.000000000 +0000
+++ schleuder-3.6.0/debian/changelog    2021-12-26 16:28:29.000000000 +0000
@@ -1,3 +1,15 @@
+schleuder (3.6.0-3+deb10u1) bullseye; urgency=medium
+
+  * debian/patches:
+    - Pull in upstream patch to migrate boolean values to integers, if the
+      ActiveRecord SQLite3 connection adapter is in use. Since ActiveRecord >=
+      6.0, the relevant code relies on boolean serialization to use 1 and 0,
+      but does not natively recognize 't' and 'f' as booleans were previously
+      serialized. This change made existing mailing lists fail, if people were
+      upgrading buster to bullseye. (Closes: #100262)
+
+ -- Georg Faerber <ge...@debian.org>  Sun, 26 Dec 2021 16:28:29 +0000
+
 schleuder (3.6.0-3) unstable; urgency=medium
 
   * debian/patches:
diff -Nru 
schleuder-3.6.0/debian/patches/0031-db-change-boolean-values-to-integers.patch 
schleuder-3.6.0/debian/patches/0031-db-change-boolean-values-to-integers.patch
--- 
schleuder-3.6.0/debian/patches/0031-db-change-boolean-values-to-integers.patch  
    1970-01-01 00:00:00.000000000 +0000
+++ 
schleuder-3.6.0/debian/patches/0031-db-change-boolean-values-to-integers.patch  
    2021-12-26 16:28:29.000000000 +0000
@@ -0,0 +1,77 @@
+Description: DB: change boolean values to integers
+  Since ActiveRecord >= 6.0, the SQLite3 connection adapter relies on boolean
+  serialization to use 1 and 0, but does not natively recognize 't' and 'f' as
+  booleans were previously serialized. Accordingly, this patch handles
+  conversion via a database migration of both column defaults and stored data
+  provided by a user.
+Author: Georg Faerber <ge...@riseup.net>
+Origin: upstream
+Bug: https://0xacab.org/schleuder/schleuder/-/issues/505
+Applied-Upstream: 9ee12c4a1d6604c860c44073b99d8258bb4bc0ae
+Last-Update: 2021-12-25
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+Index: schleuder/db/migrate/20211106112020_change_boolean_values_to_integers.rb
+===================================================================
+--- /dev/null  1970-01-01 00:00:00.000000000 +0000
++++ schleuder/db/migrate/20211106112020_change_boolean_values_to_integers.rb   
2021-12-26 17:28:42.468530957 +0000
+@@ -0,0 +1,46 @@
++# Since ActiveRecord >= 6.0, the SQLite3 connection adapter relies on boolean
++# serialization to use 1 and 0, but does not natively recognize 't' and 'f' as
++# booleans were previously serialized.
++#
++# Accordingly, this migration handles conversion of both column defaults and
++# stored data provided by a user.
++#
++# In contrast to other migrations, only a 'forward' method is provided, a
++# mechanism to 'reverse' is not. Given the nature of this migration, the later
++# is not really required.
++#
++# Unfortunately, we missed this breaking change when bumping ActiveRecord to 
>=
++# 6.0 in Schleuder version 4.0. This caused quite some work upstream, but also
++# in downstream environments and, last but not least, at the side of users.
++#
++# We should extend our CI to explicitly test, and ensure things work as
++# expected, if running a Schleuder setup in real world. As of now, we don't
++# ensure data provided by a user in Schleuder version x still works after
++# upgrading to version y.
++
++class ChangeBooleanValuesToIntegers < ActiveRecord::Migration[6.0]
++  class Lists < ActiveRecord::Base
++  end
++
++  class Subscriptions < ActiveRecord::Base
++  end
++
++  def up
++    [Lists, Subscriptions].each do |table|
++      unless 
table.connection.is_a?(ActiveRecord::ConnectionAdapters::SQLite3Adapter)
++        return
++      end
++
++      bool_columns_defaults = table.columns.select { |column| column.type == 
:boolean }.map{ |column| [column.name, column.default] }
++
++      bool_columns_defaults.each do |column_name, column_default|
++        column_bool = 
ActiveRecord::Type::Boolean.new.deserialize(column_default)
++
++        change_column_default :"#{table.table_name}", :"#{column_name}", 
column_bool
++
++        table.where("#{column_name} = 'f'").update_all("#{column_name}": 0)
++        table.where("#{column_name} = 't'").update_all("#{column_name}": 1)
++      end
++    end
++  end
++end
+Index: schleuder/db/schema.rb
+===================================================================
+--- schleuder.orig/db/schema.rb        2021-12-26 17:28:42.472530996 +0000
++++ schleuder/db/schema.rb     2021-12-26 17:29:04.460747148 +0000
+@@ -10,7 +10,7 @@
+ #
+ # It's strongly recommended that you check this file into your version 
control system.
+ 
+-ActiveRecord::Schema.define(version: 2020_01_18_170110) do
++ActiveRecord::Schema.define(version: 2021_11_06_112020) do
+ 
+   create_table "lists", force: :cascade do |t|
+     t.datetime "created_at"
diff -Nru schleuder-3.6.0/debian/patches/series 
schleuder-3.6.0/debian/patches/series
--- schleuder-3.6.0/debian/patches/series       2021-07-29 20:36:52.000000000 
+0000
+++ schleuder-3.6.0/debian/patches/series       2021-12-26 16:28:29.000000000 
+0000
@@ -14,3 +14,4 @@
 0001-lib-fix-paths.patch
 0002-etc-fix-paths.patch
 0026-Change-way-to-block-passphrase-interaction.patch
+0031-db-change-boolean-values-to-integers.patch

Reply via email to