summary refs log tree commit diff
path: root/synapse/storage/schema/delta/50
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-10-21 12:56:42 +0100
committerErik Johnston <erik@matrix.org>2019-10-21 16:05:06 +0100
commitc66a06ac6b69b0a03f5c6284ded980399e9df94e (patch)
tree01dfd3b9098a9ace759403744d122c18efbd97ff /synapse/storage/schema/delta/50
parentMerge branch 'master' into develop (diff)
downloadsynapse-c66a06ac6b69b0a03f5c6284ded980399e9df94e.tar.xz
Move storage classes into a main "data store".
This is in preparation for having multiple data stores that offer
different functionality, e.g. splitting out state or event storage.
Diffstat (limited to 'synapse/storage/schema/delta/50')
-rw-r--r--synapse/storage/schema/delta/50/add_creation_ts_users_index.sql19
-rw-r--r--synapse/storage/schema/delta/50/erasure_store.sql21
-rw-r--r--synapse/storage/schema/delta/50/make_event_content_nullable.py96
3 files changed, 0 insertions, 136 deletions
diff --git a/synapse/storage/schema/delta/50/add_creation_ts_users_index.sql b/synapse/storage/schema/delta/50/add_creation_ts_users_index.sql
deleted file mode 100644
index c93ae47532..0000000000
--- a/synapse/storage/schema/delta/50/add_creation_ts_users_index.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-INSERT into background_updates (update_name, progress_json)
-    VALUES ('users_creation_ts', '{}');
diff --git a/synapse/storage/schema/delta/50/erasure_store.sql b/synapse/storage/schema/delta/50/erasure_store.sql
deleted file mode 100644
index 5d8641a9ab..0000000000
--- a/synapse/storage/schema/delta/50/erasure_store.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2018 New Vector Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
--- a table of users who have requested that their details be erased
-CREATE TABLE erased_users (
-    user_id TEXT NOT NULL
-);
-
-CREATE UNIQUE INDEX erased_users_user ON erased_users(user_id);
diff --git a/synapse/storage/schema/delta/50/make_event_content_nullable.py b/synapse/storage/schema/delta/50/make_event_content_nullable.py
deleted file mode 100644
index b1684a8441..0000000000
--- a/synapse/storage/schema/delta/50/make_event_content_nullable.py
+++ /dev/null
@@ -1,96 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2018 New Vector Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""
-We want to stop populating 'event.content', so we need to make it nullable.
-
-If this has to be rolled back, then the following should populate the missing data:
-
-Postgres:
-
-    UPDATE events SET content=(ej.json::json)->'content' FROM event_json ej
-    WHERE ej.event_id = events.event_id AND
-        stream_ordering < (
-            SELECT stream_ordering FROM events WHERE content IS NOT NULL
-            ORDER BY stream_ordering LIMIT 1
-        );
-
-    UPDATE events SET content=(ej.json::json)->'content' FROM event_json ej
-    WHERE ej.event_id = events.event_id AND
-        stream_ordering > (
-            SELECT stream_ordering FROM events WHERE content IS NOT NULL
-            ORDER BY stream_ordering DESC LIMIT 1
-        );
-
-SQLite:
-
-    UPDATE events SET content=(
-        SELECT json_extract(json,'$.content') FROM event_json ej
-        WHERE ej.event_id = events.event_id
-    )
-    WHERE
-        stream_ordering < (
-            SELECT stream_ordering FROM events WHERE content IS NOT NULL
-            ORDER BY stream_ordering LIMIT 1
-        )
-        OR stream_ordering > (
-            SELECT stream_ordering FROM events WHERE content IS NOT NULL
-            ORDER BY stream_ordering DESC LIMIT 1
-        );
-
-"""
-
-import logging
-
-from synapse.storage.engines import PostgresEngine
-
-logger = logging.getLogger(__name__)
-
-
-def run_create(cur, database_engine, *args, **kwargs):
-    pass
-
-
-def run_upgrade(cur, database_engine, *args, **kwargs):
-    if isinstance(database_engine, PostgresEngine):
-        cur.execute(
-            """
-            ALTER TABLE events ALTER COLUMN content DROP NOT NULL;
-        """
-        )
-        return
-
-    # sqlite is an arse about this. ref: https://www.sqlite.org/lang_altertable.html
-
-    cur.execute(
-        "SELECT sql FROM sqlite_master WHERE tbl_name='events' AND type='table'"
-    )
-    (oldsql,) = cur.fetchone()
-
-    sql = oldsql.replace("content TEXT NOT NULL", "content TEXT")
-    if sql == oldsql:
-        raise Exception("Couldn't find null constraint to drop in %s" % oldsql)
-
-    logger.info("Replacing definition of 'events' with: %s", sql)
-
-    cur.execute("PRAGMA schema_version")
-    (oldver,) = cur.fetchone()
-    cur.execute("PRAGMA writable_schema=ON")
-    cur.execute(
-        "UPDATE sqlite_master SET sql=? WHERE tbl_name='events' AND type='table'",
-        (sql,),
-    )
-    cur.execute("PRAGMA schema_version=%i" % (oldver + 1,))
-    cur.execute("PRAGMA writable_schema=OFF")