@@ -155,43 +155,11 @@ def run_upgrade(
155155Boolean columns require special treatment, since SQLite treats booleans the
156156same as integers.
157157
158- There are three separate aspects to this:
159-
160- * Any new boolean column must be added to the ` BOOLEAN_COLUMNS ` list in
158+ Any new boolean column must be added to the ` BOOLEAN_COLUMNS ` list in
161159 ` synapse/_scripts/synapse_port_db.py ` . This tells the port script to cast
162160 the integer value from SQLite to a boolean before writing the value to the
163161 postgres database.
164162
165- * Before SQLite 3.23, ` TRUE ` and ` FALSE ` were not recognised as constants by
166- SQLite, and the ` IS [NOT] TRUE ` /` IS [NOT] FALSE ` operators were not
167- supported. This makes it necessary to avoid using ` TRUE ` and ` FALSE `
168- constants in SQL commands.
169-
170- For example, to insert a ` TRUE ` value into the database, write:
171-
172- ``` python
173- txn.execute(" INSERT INTO tbl(col) VALUES (?)" , (True , ))
174- ```
175-
176- * Default values for new boolean columns present a particular
177- difficulty. Generally it is best to create separate schema files for
178- Postgres and SQLite. For example:
179-
180- ``` sql
181- # in 00delta.sql.postgres:
182- ALTER TABLE tbl ADD COLUMN col BOOLEAN DEFAULT FALSE;
183- ```
184-
185- ``` sql
186- # in 00delta.sql.sqlite:
187- ALTER TABLE tbl ADD COLUMN col BOOLEAN DEFAULT 0 ;
188- ```
189-
190- Note that there is a particularly insidious failure mode here: the Postgres
191- flavour will be accepted by SQLite 3.22, but will give a column whose
192- default value is the ** string** ` "FALSE" ` - which, when cast back to a boolean
193- in Python, evaluates to ` True ` .
194-
195163
196164## ` event_id ` global uniqueness
197165
0 commit comments