2020-07-16 10:46:44 +00:00
|
|
|
#
|
2023-11-21 20:29:58 +00:00
|
|
|
# This file is licensed under the Affero General Public License (AGPL) version 3.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2023 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>.
|
|
|
|
#
|
|
|
|
# Originally licensed under the Apache License, Version 2.0:
|
|
|
|
# <http://www.apache.org/licenses/LICENSE-2.0>.
|
|
|
|
#
|
|
|
|
# [This file includes modifications made by New Vector Limited]
|
2020-07-16 10:46:44 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
"""
|
|
|
|
Adds a postgres SEQUENCE for generating guest user IDs.
|
|
|
|
"""
|
|
|
|
|
2023-04-27 12:44:53 +00:00
|
|
|
from synapse.storage.database import LoggingTransaction
|
2020-08-05 20:38:57 +00:00
|
|
|
from synapse.storage.databases.main.registration import (
|
2020-07-16 10:46:44 +00:00
|
|
|
find_max_generated_user_id_localpart,
|
|
|
|
)
|
2023-04-27 12:44:53 +00:00
|
|
|
from synapse.storage.engines import BaseDatabaseEngine, PostgresEngine
|
2020-07-16 10:46:44 +00:00
|
|
|
|
|
|
|
|
2023-04-27 12:44:53 +00:00
|
|
|
def run_create(cur: LoggingTransaction, database_engine: BaseDatabaseEngine) -> None:
|
2020-07-16 10:46:44 +00:00
|
|
|
if not isinstance(database_engine, PostgresEngine):
|
|
|
|
return
|
|
|
|
|
|
|
|
next_id = find_max_generated_user_id_localpart(cur) + 1
|
|
|
|
cur.execute("CREATE SEQUENCE user_id_seq START WITH %s", (next_id,))
|