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

Prepare for authenticated media freeze #17433

Merged
merged 8 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion synapse/storage/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
#

SCHEMA_VERSION = 85 # remember to update the list below when updating
SCHEMA_VERSION = 86 # remember to update the list below when updating
"""Represents the expectations made by the codebase about the database schema

This should be incremented whenever the codebase changes its requirements on the
Expand Down Expand Up @@ -139,6 +139,9 @@

Changes in SCHEMA_VERSION = 85
- Add a column `suspended` to the `users` table

Changes in SCHEMA_VERSION = 86
- Add a column `authenticated` to the tables `local_media_repository` and `remote_media_cache`
"""


Expand Down
16 changes: 16 additions & 0 deletions synapse/storage/schema/main/delta/86/01_authenticate_media.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--
H-Shay marked this conversation as resolved.
Show resolved Hide resolved
-- This file is licensed under the Affero General Public License (AGPL) version 3.
--
-- Copyright (C) 2024 New Vector, Ltd
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as
-- published by the Free Software Foundation, either version 3 of the
-- License, or (at your option) any later version.
--
-- See the GNU Affero General Public License for more details:
-- <https://www.gnu.org/licenses/agpl-3.0.html>.


ALTER TABLE remote_media_cache ADD COLUMN authenticated BOOLEAN;
ALTER TABLE local_media_repository ADD COLUMN authenticated BOOLEAN;
Copy link
Contributor

Choose a reason for hiding this comment

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

should we have a DEFAULT value here, and make it NOT NULL?

It would be nice to add a comment describing the semantics of the value here, even briefly. If it's a nullable column, that should be described too, which is why I'm tempted to suggest making this NOT NULL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess the default could be False, although the code essentially assumes any media item for which this column isn't True is unauthenticated so I think the null works (but is probably unclear, as you are pointing out)- setting the default might make that clearer. Essentially all existing media in the table should be either null or False once the column is added, but I can make that clearer.

Copy link
Member

Choose a reason for hiding this comment

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

Note that setting a DEFAULT means that the table needs to get rewritten to insert the new values, which takes a while. Leaving it as NULLABLE is somewhat annoying but by far the easiest.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

🤯