summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-28 12:41:33 +0100
committerErik Johnston <erik@matrix.org>2015-04-28 12:41:33 +0100
commit18f82477011ee9279bde8ad995d654c116d3f652 (patch)
treee7f351c8597515399195754507e777050ade8016
parentCorrectly handle total/remaining counts in the presence of sent_transasctions... (diff)
downloadsynapse-18f82477011ee9279bde8ad995d654c116d3f652.tar.xz
Use TEXT instead of VARCHAR(n), since PostgreSQL treats them the same except for a limit
-rw-r--r--synapse/storage/schema/delta/12/v12.sql18
-rw-r--r--synapse/storage/schema/delta/13/v13.sql10
-rw-r--r--synapse/storage/schema/delta/14/v14.sql4
-rw-r--r--synapse/storage/schema/delta/15/appservice_txns.sql4
-rw-r--r--synapse/storage/schema/delta/16/users.sql20
-rw-r--r--synapse/storage/schema/full_schemas/11/event_edges.sql34
-rw-r--r--synapse/storage/schema/full_schemas/11/event_signatures.sql20
-rw-r--r--synapse/storage/schema/full_schemas/11/im.sql64
-rw-r--r--synapse/storage/schema/full_schemas/11/keys.sql12
-rw-r--r--synapse/storage/schema/full_schemas/11/media_repository.sql34
-rw-r--r--synapse/storage/schema/full_schemas/11/presence.sql12
-rw-r--r--synapse/storage/schema/full_schemas/11/profiles.sql6
-rw-r--r--synapse/storage/schema/full_schemas/11/redactions.sql4
-rw-r--r--synapse/storage/schema/full_schemas/11/room_aliases.sql8
-rw-r--r--synapse/storage/schema/full_schemas/11/state.sql14
-rw-r--r--synapse/storage/schema/full_schemas/11/transactions.sql16
-rw-r--r--synapse/storage/schema/full_schemas/11/users.sql18
-rw-r--r--synapse/storage/schema/full_schemas/16/application_services.sql14
-rw-r--r--synapse/storage/schema/full_schemas/16/event_edges.sql34
-rw-r--r--synapse/storage/schema/full_schemas/16/event_signatures.sql20
-rw-r--r--synapse/storage/schema/full_schemas/16/im.sql64
-rw-r--r--synapse/storage/schema/full_schemas/16/keys.sql12
-rw-r--r--synapse/storage/schema/full_schemas/16/media_repository.sql34
-rw-r--r--synapse/storage/schema/full_schemas/16/presence.sql12
-rw-r--r--synapse/storage/schema/full_schemas/16/profiles.sql6
-rw-r--r--synapse/storage/schema/full_schemas/16/push.sql22
-rw-r--r--synapse/storage/schema/full_schemas/16/redactions.sql4
-rw-r--r--synapse/storage/schema/full_schemas/16/room_aliases.sql8
-rw-r--r--synapse/storage/schema/full_schemas/16/state.sql14
-rw-r--r--synapse/storage/schema/full_schemas/16/transactions.sql16
-rw-r--r--synapse/storage/schema/full_schemas/16/users.sql18
-rw-r--r--synapse/storage/schema/schema_version.sql2
32 files changed, 289 insertions, 289 deletions
diff --git a/synapse/storage/schema/delta/12/v12.sql b/synapse/storage/schema/delta/12/v12.sql
index a246943f5a..878c36260a 100644
--- a/synapse/storage/schema/delta/12/v12.sql
+++ b/synapse/storage/schema/delta/12/v12.sql
@@ -14,16 +14,16 @@
  */
 
 CREATE TABLE IF NOT EXISTS rejections(
-    event_id VARCHAR(150) NOT NULL,
-    reason VARCHAR(150) NOT NULL,
-    last_check VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    reason TEXT NOT NULL,
+    last_check TEXT NOT NULL,
     UNIQUE (event_id)
 );
 
 -- Push notification endpoints that users have configured
 CREATE TABLE IF NOT EXISTS pushers (
   id INTEGER PRIMARY KEY AUTOINCREMENT,
-  user_name VARCHAR(150) NOT NULL,
+  user_name TEXT NOT NULL,
   profile_tag VARCHAR(32) NOT NULL,
   kind VARCHAR(8) NOT NULL,
   app_id VARCHAR(64) NOT NULL,
@@ -41,19 +41,19 @@ CREATE TABLE IF NOT EXISTS pushers (
 
 CREATE TABLE IF NOT EXISTS push_rules (
   id INTEGER PRIMARY KEY AUTOINCREMENT,
-  user_name VARCHAR(150) NOT NULL,
-  rule_id VARCHAR(150) NOT NULL,
+  user_name TEXT NOT NULL,
+  rule_id TEXT NOT NULL,
   priority_class TINYINT NOT NULL,
   priority INTEGER NOT NULL DEFAULT 0,
-  conditions VARCHAR(150) NOT NULL,
-  actions VARCHAR(150) NOT NULL,
+  conditions TEXT NOT NULL,
+  actions TEXT NOT NULL,
   UNIQUE(user_name, rule_id)
 );
 
 CREATE INDEX IF NOT EXISTS push_rules_user_name on push_rules (user_name);
 
 CREATE TABLE IF NOT EXISTS user_filters(
-  user_id VARCHAR(150),
+  user_id TEXT,
   filter_id BIGINT UNSIGNED,
   filter_json LONGBLOB
 );
diff --git a/synapse/storage/schema/delta/13/v13.sql b/synapse/storage/schema/delta/13/v13.sql
index d1da2b48e2..3265924013 100644
--- a/synapse/storage/schema/delta/13/v13.sql
+++ b/synapse/storage/schema/delta/13/v13.sql
@@ -15,10 +15,10 @@
 
 CREATE TABLE IF NOT EXISTS application_services(
     id INTEGER PRIMARY KEY AUTOINCREMENT,
-    url VARCHAR(150),
-    token VARCHAR(150),
-    hs_token VARCHAR(150),
-    sender VARCHAR(150),
+    url TEXT,
+    token TEXT,
+    hs_token TEXT,
+    sender TEXT,
     UNIQUE(token)
 );
 
@@ -26,6 +26,6 @@ CREATE TABLE IF NOT EXISTS application_services_regex(
     id INTEGER PRIMARY KEY AUTOINCREMENT,
     as_id BIGINT UNSIGNED NOT NULL,
     namespace INTEGER,  /* enum[room_id|room_alias|user_id] */
-    regex VARCHAR(150),
+    regex TEXT,
     FOREIGN KEY(as_id) REFERENCES application_services(id)
 );
diff --git a/synapse/storage/schema/delta/14/v14.sql b/synapse/storage/schema/delta/14/v14.sql
index e5fedc5851..1d09ad7a15 100644
--- a/synapse/storage/schema/delta/14/v14.sql
+++ b/synapse/storage/schema/delta/14/v14.sql
@@ -14,8 +14,8 @@
  */
 CREATE TABLE IF NOT EXISTS push_rules_enable (
   id INTEGER PRIMARY KEY AUTOINCREMENT,
-  user_name VARCHAR(150) NOT NULL,
-  rule_id VARCHAR(150) NOT NULL,
+  user_name TEXT NOT NULL,
+  rule_id TEXT NOT NULL,
   enabled TINYINT,
   UNIQUE(user_name, rule_id)
 );
diff --git a/synapse/storage/schema/delta/15/appservice_txns.sql b/synapse/storage/schema/delta/15/appservice_txns.sql
index 1c3324f415..db2e720393 100644
--- a/synapse/storage/schema/delta/15/appservice_txns.sql
+++ b/synapse/storage/schema/delta/15/appservice_txns.sql
@@ -14,13 +14,13 @@
  */
 
 CREATE TABLE IF NOT EXISTS application_services_state(
-    as_id VARCHAR(150) PRIMARY KEY,
+    as_id TEXT PRIMARY KEY,
     state VARCHAR(5),
     last_txn INTEGER
 );
 
 CREATE TABLE IF NOT EXISTS application_services_txns(
-    as_id VARCHAR(150) NOT NULL,
+    as_id TEXT NOT NULL,
     txn_id INTEGER NOT NULL,
     event_ids TEXT NOT NULL,
     UNIQUE(as_id, txn_id)
diff --git a/synapse/storage/schema/delta/16/users.sql b/synapse/storage/schema/delta/16/users.sql
index db27bdca02..cd0709250d 100644
--- a/synapse/storage/schema/delta/16/users.sql
+++ b/synapse/storage/schema/delta/16/users.sql
@@ -2,9 +2,9 @@
 -- MUST BE DONE BEFORE REMOVING ID COLUMN FROM USERS TABLE BELOW
 CREATE TABLE IF NOT EXISTS new_access_tokens(
     id BIGINT UNSIGNED PRIMARY KEY,
-    user_id VARCHAR(150) NOT NULL,
-    device_id VARCHAR(150),
-    token VARCHAR(150) NOT NULL,
+    user_id TEXT NOT NULL,
+    device_id TEXT,
+    token TEXT NOT NULL,
     last_used BIGINT UNSIGNED,
     UNIQUE(token)
 );
@@ -20,8 +20,8 @@ ALTER TABLE new_access_tokens RENAME TO access_tokens;
 
 -- Remove ID column from `users` table
 CREATE TABLE IF NOT EXISTS new_users(
-    name VARCHAR(150),
-    password_hash VARCHAR(150),
+    name TEXT,
+    password_hash TEXT,
     creation_ts BIGINT UNSIGNED,
     admin BOOL DEFAULT 0 NOT NULL,
     UNIQUE(name)
@@ -36,11 +36,11 @@ ALTER TABLE new_users RENAME TO users;
 
 -- Remove UNIQUE constraint from `user_ips` table
 CREATE TABLE IF NOT EXISTS new_user_ips (
-    user_id VARCHAR(150) NOT NULL,
-    access_token VARCHAR(150) NOT NULL,
-    device_id VARCHAR(150),
-    ip VARCHAR(150) NOT NULL,
-    user_agent VARCHAR(150) NOT NULL,
+    user_id TEXT NOT NULL,
+    access_token TEXT NOT NULL,
+    device_id TEXT,
+    ip TEXT NOT NULL,
+    user_agent TEXT NOT NULL,
     last_seen BIGINT UNSIGNED NOT NULL
 );
 
diff --git a/synapse/storage/schema/full_schemas/11/event_edges.sql b/synapse/storage/schema/full_schemas/11/event_edges.sql
index 05d0874f0d..f7020f7793 100644
--- a/synapse/storage/schema/full_schemas/11/event_edges.sql
+++ b/synapse/storage/schema/full_schemas/11/event_edges.sql
@@ -14,8 +14,8 @@
  */
 
 CREATE TABLE IF NOT EXISTS event_forward_extremities(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     UNIQUE (event_id, room_id)
 );
 
@@ -24,8 +24,8 @@ CREATE INDEX ev_extrem_id ON event_forward_extremities(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_backward_extremities(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     UNIQUE (event_id, room_id)
 );
 
@@ -34,9 +34,9 @@ CREATE INDEX ev_b_extrem_id ON event_backward_extremities(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_edges(
-    event_id VARCHAR(150) NOT NULL,
-    prev_event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    prev_event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     is_state BOOL NOT NULL,
     UNIQUE (event_id, prev_event_id, room_id, is_state)
 );
@@ -46,7 +46,7 @@ CREATE INDEX ev_edges_prev_id ON event_edges(prev_event_id);
 
 
 CREATE TABLE IF NOT EXISTS room_depth(
-    room_id VARCHAR(150) NOT NULL,
+    room_id TEXT NOT NULL,
     min_depth INTEGER NOT NULL,
     UNIQUE (room_id)
 );
@@ -55,8 +55,8 @@ CREATE INDEX room_depth_room ON room_depth(room_id);
 
 
 create TABLE IF NOT EXISTS event_destinations(
-    event_id VARCHAR(150) NOT NULL,
-    destination VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    destination TEXT NOT NULL,
     delivered_ts BIGINT DEFAULT 0, -- or 0 if not delivered
     UNIQUE (event_id, destination)
 );
@@ -65,10 +65,10 @@ CREATE INDEX event_destinations_id ON event_destinations(event_id);
 
 
 CREATE TABLE IF NOT EXISTS state_forward_extremities(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
-    type VARCHAR(150) NOT NULL,
-    state_key VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
+    type TEXT NOT NULL,
+    state_key TEXT NOT NULL,
     UNIQUE (event_id, room_id)
 );
 
@@ -79,9 +79,9 @@ CREATE INDEX st_extrem_id ON state_forward_extremities(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_auth(
-    event_id VARCHAR(150) NOT NULL,
-    auth_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    auth_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     UNIQUE (event_id, auth_id, room_id)
 );
 
diff --git a/synapse/storage/schema/full_schemas/11/event_signatures.sql b/synapse/storage/schema/full_schemas/11/event_signatures.sql
index 4291827368..636b2d3353 100644
--- a/synapse/storage/schema/full_schemas/11/event_signatures.sql
+++ b/synapse/storage/schema/full_schemas/11/event_signatures.sql
@@ -14,8 +14,8 @@
  */
 
 CREATE TABLE IF NOT EXISTS event_content_hashes (
-    event_id VARCHAR(150),
-    algorithm VARCHAR(150),
+    event_id TEXT,
+    algorithm TEXT,
     hash bytea,
     UNIQUE (event_id, algorithm)
 );
@@ -24,8 +24,8 @@ CREATE INDEX event_content_hashes_id ON event_content_hashes(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_reference_hashes (
-    event_id VARCHAR(150),
-    algorithm VARCHAR(150),
+    event_id TEXT,
+    algorithm TEXT,
     hash bytea,
     UNIQUE (event_id, algorithm)
 );
@@ -34,9 +34,9 @@ CREATE INDEX event_reference_hashes_id ON event_reference_hashes(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_signatures (
-    event_id VARCHAR(150),
-    signature_name VARCHAR(150),
-    key_id VARCHAR(150),
+    event_id TEXT,
+    signature_name TEXT,
+    key_id TEXT,
     signature bytea,
     UNIQUE (event_id, signature_name, key_id)
 );
@@ -45,9 +45,9 @@ CREATE INDEX event_signatures_id ON event_signatures(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_edge_hashes(
-    event_id VARCHAR(150),
-    prev_event_id VARCHAR(150),
-    algorithm VARCHAR(150),
+    event_id TEXT,
+    prev_event_id TEXT,
+    algorithm TEXT,
     hash bytea,
     UNIQUE (event_id, prev_event_id, algorithm)
 );
diff --git a/synapse/storage/schema/full_schemas/11/im.sql b/synapse/storage/schema/full_schemas/11/im.sql
index addbec5885..1901654ac2 100644
--- a/synapse/storage/schema/full_schemas/11/im.sql
+++ b/synapse/storage/schema/full_schemas/11/im.sql
@@ -16,9 +16,9 @@
 CREATE TABLE IF NOT EXISTS events(
     stream_ordering INTEGER PRIMARY KEY AUTOINCREMENT,
     topological_ordering BIGINT NOT NULL,
-    event_id VARCHAR(150) NOT NULL,
-    type VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    type TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     content TEXT NOT NULL,
     unrecognized_keys TEXT,
     processed BOOL NOT NULL,
@@ -33,8 +33,8 @@ CREATE INDEX events_room_id ON events (room_id);
 
 
 CREATE TABLE IF NOT EXISTS event_json(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     internal_metadata TEXT NOT NULL,
     json TEXT NOT NULL,
     UNIQUE (event_id)
@@ -44,11 +44,11 @@ CREATE INDEX event_json_room_id ON event_json(room_id);
 
 
 CREATE TABLE IF NOT EXISTS state_events(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
-    type VARCHAR(150) NOT NULL,
-    state_key VARCHAR(150) NOT NULL,
-    prev_state VARCHAR(150),
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
+    type TEXT NOT NULL,
+    state_key TEXT NOT NULL,
+    prev_state TEXT,
     UNIQUE (event_id)
 );
 
@@ -58,10 +58,10 @@ CREATE INDEX state_events_state_key ON state_events (state_key);
 
 
 CREATE TABLE IF NOT EXISTS current_state_events(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
-    type VARCHAR(150) NOT NULL,
-    state_key VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
+    type TEXT NOT NULL,
+    state_key TEXT NOT NULL,
     UNIQUE (room_id, type, state_key)
 );
 
@@ -71,11 +71,11 @@ CREATE INDEX current_state_events_type ON current_state_events (type);
 CREATE INDEX current_state_events_state_key ON current_state_events (state_key);
 
 CREATE TABLE IF NOT EXISTS room_memberships(
-    event_id VARCHAR(150) NOT NULL,
-    user_id VARCHAR(150) NOT NULL,
-    sender VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
-    membership VARCHAR(150) NOT NULL
+    event_id TEXT NOT NULL,
+    user_id TEXT NOT NULL,
+    sender TEXT NOT NULL,
+    room_id TEXT NOT NULL,
+    membership TEXT NOT NULL
 );
 
 CREATE INDEX room_memberships_event_id ON room_memberships (event_id);
@@ -83,16 +83,16 @@ CREATE INDEX room_memberships_room_id ON room_memberships (room_id);
 CREATE INDEX room_memberships_user_id ON room_memberships (user_id);
 
 CREATE TABLE IF NOT EXISTS feedback(
-    event_id VARCHAR(150) NOT NULL,
-    feedback_type VARCHAR(150),
-    target_event_id VARCHAR(150),
-    sender VARCHAR(150),
-    room_id VARCHAR(150)
+    event_id TEXT NOT NULL,
+    feedback_type TEXT,
+    target_event_id TEXT,
+    sender TEXT,
+    room_id TEXT
 );
 
 CREATE TABLE IF NOT EXISTS topics(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     topic TEXT NOT NULL
 );
 
@@ -100,8 +100,8 @@ CREATE INDEX topics_event_id ON topics(event_id);
 CREATE INDEX topics_room_id ON topics(room_id);
 
 CREATE TABLE IF NOT EXISTS room_names(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     name TEXT NOT NULL
 );
 
@@ -109,14 +109,14 @@ CREATE INDEX room_names_event_id ON room_names(event_id);
 CREATE INDEX room_names_room_id ON room_names(room_id);
 
 CREATE TABLE IF NOT EXISTS rooms(
-    room_id VARCHAR(150) PRIMARY KEY NOT NULL,
+    room_id TEXT PRIMARY KEY NOT NULL,
     is_public BOOL,
-    creator VARCHAR(150)
+    creator TEXT
 );
 
 CREATE TABLE IF NOT EXISTS room_hosts(
-    room_id VARCHAR(150) NOT NULL,
-    host VARCHAR(150) NOT NULL,
+    room_id TEXT NOT NULL,
+    host TEXT NOT NULL,
     UNIQUE (room_id, host)
 );
 
diff --git a/synapse/storage/schema/full_schemas/11/keys.sql b/synapse/storage/schema/full_schemas/11/keys.sql
index 459b510427..afc142045e 100644
--- a/synapse/storage/schema/full_schemas/11/keys.sql
+++ b/synapse/storage/schema/full_schemas/11/keys.sql
@@ -13,18 +13,18 @@
  * limitations under the License.
  */
 CREATE TABLE IF NOT EXISTS server_tls_certificates(
-  server_name VARCHAR(150), -- Server name.
-  fingerprint VARCHAR(150), -- Certificate fingerprint.
-  from_server VARCHAR(150), -- Which key server the certificate was fetched from.
+  server_name TEXT, -- Server name.
+  fingerprint TEXT, -- Certificate fingerprint.
+  from_server TEXT, -- Which key server the certificate was fetched from.
   ts_added_ms BIGINT, -- When the certifcate was added.
   tls_certificate bytea, -- DER encoded x509 certificate.
   UNIQUE (server_name, fingerprint)
 );
 
 CREATE TABLE IF NOT EXISTS server_signature_keys(
-  server_name VARCHAR(150), -- Server name.
-  key_id VARCHAR(150), -- Key version.
-  from_server VARCHAR(150), -- Which key server the key was fetched form.
+  server_name TEXT, -- Server name.
+  key_id TEXT, -- Key version.
+  from_server TEXT, -- Which key server the key was fetched form.
   ts_added_ms BIGINT, -- When the key was added.
   verify_key bytea, -- NACL verification key.
   UNIQUE (server_name, key_id)
diff --git a/synapse/storage/schema/full_schemas/11/media_repository.sql b/synapse/storage/schema/full_schemas/11/media_repository.sql
index 6e0ee0db41..e927e581d1 100644
--- a/synapse/storage/schema/full_schemas/11/media_repository.sql
+++ b/synapse/storage/schema/full_schemas/11/media_repository.sql
@@ -14,21 +14,21 @@
  */
 
 CREATE TABLE IF NOT EXISTS local_media_repository (
-    media_id VARCHAR(150), -- The id used to refer to the media.
-    media_type VARCHAR(150), -- The MIME-type of the media.
+    media_id TEXT, -- The id used to refer to the media.
+    media_type TEXT, -- The MIME-type of the media.
     media_length INTEGER, -- Length of the media in bytes.
     created_ts BIGINT, -- When the content was uploaded in ms.
-    upload_name VARCHAR(150), -- The name the media was uploaded with.
-    user_id VARCHAR(150), -- The user who uploaded the file.
+    upload_name TEXT, -- The name the media was uploaded with.
+    user_id TEXT, -- The user who uploaded the file.
     UNIQUE (media_id)
 );
 
 CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
-    media_id VARCHAR(150), -- The id used to refer to the media.
+    media_id TEXT, -- The id used to refer to the media.
     thumbnail_width INTEGER, -- The width of the thumbnail in pixels.
     thumbnail_height INTEGER, -- The height of the thumbnail in pixels.
-    thumbnail_type VARCHAR(150), -- The MIME-type of the thumbnail.
-    thumbnail_method VARCHAR(150), -- The method used to make the thumbnail.
+    thumbnail_type TEXT, -- The MIME-type of the thumbnail.
+    thumbnail_method TEXT, -- The method used to make the thumbnail.
     thumbnail_length INTEGER, -- The length of the thumbnail in bytes.
     UNIQUE (
         media_id, thumbnail_width, thumbnail_height, thumbnail_type
@@ -39,25 +39,25 @@ CREATE INDEX local_media_repository_thumbnails_media_id
     ON local_media_repository_thumbnails (media_id);
 
 CREATE TABLE IF NOT EXISTS remote_media_cache (
-    media_origin VARCHAR(150), -- The remote HS the media came from.
-    media_id VARCHAR(150), -- The id used to refer to the media on that server.
-    media_type VARCHAR(150), -- The MIME-type of the media.
+    media_origin TEXT, -- The remote HS the media came from.
+    media_id TEXT, -- The id used to refer to the media on that server.
+    media_type TEXT, -- The MIME-type of the media.
     created_ts BIGINT, -- When the content was uploaded in ms.
-    upload_name VARCHAR(150), -- The name the media was uploaded with.
+    upload_name TEXT, -- The name the media was uploaded with.
     media_length INTEGER, -- Length of the media in bytes.
-    filesystem_id VARCHAR(150), -- The name used to store the media on disk.
+    filesystem_id TEXT, -- The name used to store the media on disk.
     UNIQUE (media_origin, media_id)
 );
 
 CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails (
-    media_origin VARCHAR(150), -- The remote HS the media came from.
-    media_id VARCHAR(150), -- The id used to refer to the media.
+    media_origin TEXT, -- The remote HS the media came from.
+    media_id TEXT, -- The id used to refer to the media.
     thumbnail_width INTEGER, -- The width of the thumbnail in pixels.
     thumbnail_height INTEGER, -- The height of the thumbnail in pixels.
-    thumbnail_method VARCHAR(150), -- The method used to make the thumbnail
-    thumbnail_type VARCHAR(150), -- The MIME-type of the thumbnail.
+    thumbnail_method TEXT, -- The method used to make the thumbnail
+    thumbnail_type TEXT, -- The MIME-type of the thumbnail.
     thumbnail_length INTEGER, -- The length of the thumbnail in bytes.
-    filesystem_id VARCHAR(150), -- The name used to store the media on disk.
+    filesystem_id TEXT, -- The name used to store the media on disk.
     UNIQUE (
         media_origin, media_id, thumbnail_width, thumbnail_height,
         thumbnail_type
diff --git a/synapse/storage/schema/full_schemas/11/presence.sql b/synapse/storage/schema/full_schemas/11/presence.sql
index fce324b890..d8d82e9fe3 100644
--- a/synapse/storage/schema/full_schemas/11/presence.sql
+++ b/synapse/storage/schema/full_schemas/11/presence.sql
@@ -13,23 +13,23 @@
  * limitations under the License.
  */
 CREATE TABLE IF NOT EXISTS presence(
-  user_id VARCHAR(150) NOT NULL,
+  user_id TEXT NOT NULL,
   state VARCHAR(20),
-  status_msg VARCHAR(150),
+  status_msg TEXT,
   mtime BIGINT -- miliseconds since last state change
 );
 
 -- For each of /my/ users which possibly-remote users are allowed to see their
 -- presence state
 CREATE TABLE IF NOT EXISTS presence_allow_inbound(
-  observed_user_id VARCHAR(150) NOT NULL,
-  observer_user_id VARCHAR(150) NOT NULL -- a UserID,
+  observed_user_id TEXT NOT NULL,
+  observer_user_id TEXT NOT NULL -- a UserID,
 );
 
 -- For each of /my/ users (watcher), which possibly-remote users are they
 -- watching?
 CREATE TABLE IF NOT EXISTS presence_list(
-  user_id VARCHAR(150) NOT NULL,
-  observed_user_id VARCHAR(150) NOT NULL, -- a UserID,
+  user_id TEXT NOT NULL,
+  observed_user_id TEXT NOT NULL, -- a UserID,
   accepted BOOLEAN NOT NULL
 );
diff --git a/synapse/storage/schema/full_schemas/11/profiles.sql b/synapse/storage/schema/full_schemas/11/profiles.sql
index ffe75edf9f..26e4204437 100644
--- a/synapse/storage/schema/full_schemas/11/profiles.sql
+++ b/synapse/storage/schema/full_schemas/11/profiles.sql
@@ -13,7 +13,7 @@
  * limitations under the License.
  */
 CREATE TABLE IF NOT EXISTS profiles(
-    user_id VARCHAR(150) NOT NULL,
-    displayname VARCHAR(150),
-    avatar_url VARCHAR(150)
+    user_id TEXT NOT NULL,
+    displayname TEXT,
+    avatar_url TEXT
 );
diff --git a/synapse/storage/schema/full_schemas/11/redactions.sql b/synapse/storage/schema/full_schemas/11/redactions.sql
index 492fd22033..69621955d4 100644
--- a/synapse/storage/schema/full_schemas/11/redactions.sql
+++ b/synapse/storage/schema/full_schemas/11/redactions.sql
@@ -13,8 +13,8 @@
  * limitations under the License.
  */
 CREATE TABLE IF NOT EXISTS redactions (
-    event_id VARCHAR(150) NOT NULL,
-    redacts VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    redacts TEXT NOT NULL,
     UNIQUE (event_id)
 );
 
diff --git a/synapse/storage/schema/full_schemas/11/room_aliases.sql b/synapse/storage/schema/full_schemas/11/room_aliases.sql
index 6226913227..5027b1e3f6 100644
--- a/synapse/storage/schema/full_schemas/11/room_aliases.sql
+++ b/synapse/storage/schema/full_schemas/11/room_aliases.sql
@@ -14,11 +14,11 @@
  */
 
 CREATE TABLE IF NOT EXISTS room_aliases(
-    room_alias VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL
+    room_alias TEXT NOT NULL,
+    room_id TEXT NOT NULL
 );
 
 CREATE TABLE IF NOT EXISTS room_alias_servers(
-    room_alias VARCHAR(150) NOT NULL,
-    server VARCHAR(150) NOT NULL
+    room_alias TEXT NOT NULL,
+    server TEXT NOT NULL
 );
diff --git a/synapse/storage/schema/full_schemas/11/state.sql b/synapse/storage/schema/full_schemas/11/state.sql
index 62c20819fd..ffd164ab71 100644
--- a/synapse/storage/schema/full_schemas/11/state.sql
+++ b/synapse/storage/schema/full_schemas/11/state.sql
@@ -15,20 +15,20 @@
 
 CREATE TABLE IF NOT EXISTS state_groups(
     id INTEGER PRIMARY KEY,
-    room_id VARCHAR(150) NOT NULL,
-    event_id VARCHAR(150) NOT NULL
+    room_id TEXT NOT NULL,
+    event_id TEXT NOT NULL
 );
 
 CREATE TABLE IF NOT EXISTS state_groups_state(
     state_group INTEGER NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
-    type VARCHAR(150) NOT NULL,
-    state_key VARCHAR(150) NOT NULL,
-    event_id VARCHAR(150) NOT NULL
+    room_id TEXT NOT NULL,
+    type TEXT NOT NULL,
+    state_key TEXT NOT NULL,
+    event_id TEXT NOT NULL
 );
 
 CREATE TABLE IF NOT EXISTS event_to_state_groups(
-    event_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
     state_group INTEGER NOT NULL,
     UNIQUE (event_id)
 );
diff --git a/synapse/storage/schema/full_schemas/11/transactions.sql b/synapse/storage/schema/full_schemas/11/transactions.sql
index 524a696920..cc5b54f5aa 100644
--- a/synapse/storage/schema/full_schemas/11/transactions.sql
+++ b/synapse/storage/schema/full_schemas/11/transactions.sql
@@ -14,8 +14,8 @@
  */
 -- Stores what transaction ids we have received and what our response was
 CREATE TABLE IF NOT EXISTS received_transactions(
-    transaction_id VARCHAR(150),
-    origin VARCHAR(150),
+    transaction_id TEXT,
+    origin TEXT,
     ts BIGINT,
     response_code INTEGER,
     response_json bytea,
@@ -30,8 +30,8 @@ CREATE INDEX transactions_have_ref ON received_transactions(origin, has_been_ref
 -- since referenced the transaction in another outgoing transaction
 CREATE TABLE IF NOT EXISTS sent_transactions(
     id INTEGER PRIMARY KEY AUTOINCREMENT, -- This is used to apply insertion ordering
-    transaction_id VARCHAR(150),
-    destination VARCHAR(150),
+    transaction_id TEXT,
+    destination TEXT,
     response_code INTEGER DEFAULT 0,
     response_json TEXT,
     ts BIGINT
@@ -47,9 +47,9 @@ CREATE INDEX sent_transaction_sent ON sent_transactions(response_code);
 -- For sent transactions only.
 CREATE TABLE IF NOT EXISTS transaction_id_to_pdu(
     transaction_id INTEGER,
-    destination VARCHAR(150),
-    pdu_id VARCHAR(150),
-    pdu_origin VARCHAR(150)
+    destination TEXT,
+    pdu_id TEXT,
+    pdu_origin TEXT
 );
 
 CREATE INDEX transaction_id_to_pdu_tx ON transaction_id_to_pdu(transaction_id, destination);
@@ -57,7 +57,7 @@ CREATE INDEX transaction_id_to_pdu_dest ON transaction_id_to_pdu(destination);
 
 -- To track destination health
 CREATE TABLE IF NOT EXISTS destinations(
-    destination VARCHAR(150) PRIMARY KEY,
+    destination TEXT PRIMARY KEY,
     retry_last_ts BIGINT,
     retry_interval INTEGER
 );
diff --git a/synapse/storage/schema/full_schemas/11/users.sql b/synapse/storage/schema/full_schemas/11/users.sql
index 48a6aecfe8..eec3da3c35 100644
--- a/synapse/storage/schema/full_schemas/11/users.sql
+++ b/synapse/storage/schema/full_schemas/11/users.sql
@@ -14,8 +14,8 @@
  */
 CREATE TABLE IF NOT EXISTS users(
     id INTEGER PRIMARY KEY AUTOINCREMENT,
-    name VARCHAR(150),
-    password_hash VARCHAR(150),
+    name TEXT,
+    password_hash TEXT,
     creation_ts BIGINT,
     admin SMALLINT DEFAULT 0 NOT NULL,
     UNIQUE(name)
@@ -23,18 +23,18 @@ CREATE TABLE IF NOT EXISTS users(
 
 CREATE TABLE IF NOT EXISTS access_tokens(
     id INTEGER PRIMARY KEY AUTOINCREMENT,
-    user_id VARCHAR(150) NOT NULL,
-    device_id VARCHAR(150),
-    token VARCHAR(150) NOT NULL,
+    user_id TEXT NOT NULL,
+    device_id TEXT,
+    token TEXT NOT NULL,
     last_used BIGINT,
     UNIQUE(token)
 );
 
 CREATE TABLE IF NOT EXISTS user_ips (
-    user VARCHAR(150) NOT NULL,
-    access_token VARCHAR(150) NOT NULL,
-    device_id VARCHAR(150),
-    ip VARCHAR(150) NOT NULL,
+    user TEXT NOT NULL,
+    access_token TEXT NOT NULL,
+    device_id TEXT,
+    ip TEXT NOT NULL,
     user_agent TEXT NOT NULL,
     last_seen BIGINT NOT NULL,
     UNIQUE (user, access_token, ip, user_agent)
diff --git a/synapse/storage/schema/full_schemas/16/application_services.sql b/synapse/storage/schema/full_schemas/16/application_services.sql
index 5d63d57d59..d382d63fbd 100644
--- a/synapse/storage/schema/full_schemas/16/application_services.sql
+++ b/synapse/storage/schema/full_schemas/16/application_services.sql
@@ -15,10 +15,10 @@
 
 CREATE TABLE IF NOT EXISTS application_services(
     id BIGINT PRIMARY KEY,
-    url VARCHAR(150),
-    token VARCHAR(150),
-    hs_token VARCHAR(150),
-    sender VARCHAR(150),
+    url TEXT,
+    token TEXT,
+    hs_token TEXT,
+    sender TEXT,
     UNIQUE(token)
 );
 
@@ -26,18 +26,18 @@ CREATE TABLE IF NOT EXISTS application_services_regex(
     id BIGINT PRIMARY KEY,
     as_id BIGINT NOT NULL,
     namespace INTEGER,  /* enum[room_id|room_alias|user_id] */
-    regex VARCHAR(150),
+    regex TEXT,
     FOREIGN KEY(as_id) REFERENCES application_services(id)
 );
 
 CREATE TABLE IF NOT EXISTS application_services_state(
-    as_id VARCHAR(150) PRIMARY KEY,
+    as_id TEXT PRIMARY KEY,
     state VARCHAR(5),
     last_txn INTEGER
 );
 
 CREATE TABLE IF NOT EXISTS application_services_txns(
-    as_id VARCHAR(150) NOT NULL,
+    as_id TEXT NOT NULL,
     txn_id INTEGER NOT NULL,
     event_ids TEXT NOT NULL,
     UNIQUE(as_id, txn_id)
diff --git a/synapse/storage/schema/full_schemas/16/event_edges.sql b/synapse/storage/schema/full_schemas/16/event_edges.sql
index 05d0874f0d..f7020f7793 100644
--- a/synapse/storage/schema/full_schemas/16/event_edges.sql
+++ b/synapse/storage/schema/full_schemas/16/event_edges.sql
@@ -14,8 +14,8 @@
  */
 
 CREATE TABLE IF NOT EXISTS event_forward_extremities(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     UNIQUE (event_id, room_id)
 );
 
@@ -24,8 +24,8 @@ CREATE INDEX ev_extrem_id ON event_forward_extremities(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_backward_extremities(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     UNIQUE (event_id, room_id)
 );
 
@@ -34,9 +34,9 @@ CREATE INDEX ev_b_extrem_id ON event_backward_extremities(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_edges(
-    event_id VARCHAR(150) NOT NULL,
-    prev_event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    prev_event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     is_state BOOL NOT NULL,
     UNIQUE (event_id, prev_event_id, room_id, is_state)
 );
@@ -46,7 +46,7 @@ CREATE INDEX ev_edges_prev_id ON event_edges(prev_event_id);
 
 
 CREATE TABLE IF NOT EXISTS room_depth(
-    room_id VARCHAR(150) NOT NULL,
+    room_id TEXT NOT NULL,
     min_depth INTEGER NOT NULL,
     UNIQUE (room_id)
 );
@@ -55,8 +55,8 @@ CREATE INDEX room_depth_room ON room_depth(room_id);
 
 
 create TABLE IF NOT EXISTS event_destinations(
-    event_id VARCHAR(150) NOT NULL,
-    destination VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    destination TEXT NOT NULL,
     delivered_ts BIGINT DEFAULT 0, -- or 0 if not delivered
     UNIQUE (event_id, destination)
 );
@@ -65,10 +65,10 @@ CREATE INDEX event_destinations_id ON event_destinations(event_id);
 
 
 CREATE TABLE IF NOT EXISTS state_forward_extremities(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
-    type VARCHAR(150) NOT NULL,
-    state_key VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
+    type TEXT NOT NULL,
+    state_key TEXT NOT NULL,
     UNIQUE (event_id, room_id)
 );
 
@@ -79,9 +79,9 @@ CREATE INDEX st_extrem_id ON state_forward_extremities(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_auth(
-    event_id VARCHAR(150) NOT NULL,
-    auth_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    auth_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     UNIQUE (event_id, auth_id, room_id)
 );
 
diff --git a/synapse/storage/schema/full_schemas/16/event_signatures.sql b/synapse/storage/schema/full_schemas/16/event_signatures.sql
index 4291827368..636b2d3353 100644
--- a/synapse/storage/schema/full_schemas/16/event_signatures.sql
+++ b/synapse/storage/schema/full_schemas/16/event_signatures.sql
@@ -14,8 +14,8 @@
  */
 
 CREATE TABLE IF NOT EXISTS event_content_hashes (
-    event_id VARCHAR(150),
-    algorithm VARCHAR(150),
+    event_id TEXT,
+    algorithm TEXT,
     hash bytea,
     UNIQUE (event_id, algorithm)
 );
@@ -24,8 +24,8 @@ CREATE INDEX event_content_hashes_id ON event_content_hashes(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_reference_hashes (
-    event_id VARCHAR(150),
-    algorithm VARCHAR(150),
+    event_id TEXT,
+    algorithm TEXT,
     hash bytea,
     UNIQUE (event_id, algorithm)
 );
@@ -34,9 +34,9 @@ CREATE INDEX event_reference_hashes_id ON event_reference_hashes(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_signatures (
-    event_id VARCHAR(150),
-    signature_name VARCHAR(150),
-    key_id VARCHAR(150),
+    event_id TEXT,
+    signature_name TEXT,
+    key_id TEXT,
     signature bytea,
     UNIQUE (event_id, signature_name, key_id)
 );
@@ -45,9 +45,9 @@ CREATE INDEX event_signatures_id ON event_signatures(event_id);
 
 
 CREATE TABLE IF NOT EXISTS event_edge_hashes(
-    event_id VARCHAR(150),
-    prev_event_id VARCHAR(150),
-    algorithm VARCHAR(150),
+    event_id TEXT,
+    prev_event_id TEXT,
+    algorithm TEXT,
     hash bytea,
     UNIQUE (event_id, prev_event_id, algorithm)
 );
diff --git a/synapse/storage/schema/full_schemas/16/im.sql b/synapse/storage/schema/full_schemas/16/im.sql
index 5b4b494484..576653a3c9 100644
--- a/synapse/storage/schema/full_schemas/16/im.sql
+++ b/synapse/storage/schema/full_schemas/16/im.sql
@@ -16,9 +16,9 @@
 CREATE TABLE IF NOT EXISTS events(
     stream_ordering INTEGER PRIMARY KEY,
     topological_ordering BIGINT NOT NULL,
-    event_id VARCHAR(150) NOT NULL,
-    type VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    type TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     content TEXT NOT NULL,
     unrecognized_keys TEXT,
     processed BOOL NOT NULL,
@@ -37,8 +37,8 @@ CREATE INDEX events_order_room ON events (
 
 
 CREATE TABLE IF NOT EXISTS event_json(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     internal_metadata TEXT NOT NULL,
     json TEXT NOT NULL,
     UNIQUE (event_id)
@@ -48,11 +48,11 @@ CREATE INDEX event_json_room_id ON event_json(room_id);
 
 
 CREATE TABLE IF NOT EXISTS state_events(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
-    type VARCHAR(150) NOT NULL,
-    state_key VARCHAR(150) NOT NULL,
-    prev_state VARCHAR(150),
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
+    type TEXT NOT NULL,
+    state_key TEXT NOT NULL,
+    prev_state TEXT,
     UNIQUE (event_id)
 );
 
@@ -62,10 +62,10 @@ CREATE INDEX state_events_state_key ON state_events (state_key);
 
 
 CREATE TABLE IF NOT EXISTS current_state_events(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
-    type VARCHAR(150) NOT NULL,
-    state_key VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
+    type TEXT NOT NULL,
+    state_key TEXT NOT NULL,
     UNIQUE (event_id),
     UNIQUE (room_id, type, state_key)
 );
@@ -75,11 +75,11 @@ CREATE INDEX current_state_events_type ON current_state_events (type);
 CREATE INDEX current_state_events_state_key ON current_state_events (state_key);
 
 CREATE TABLE IF NOT EXISTS room_memberships(
-    event_id VARCHAR(150) NOT NULL,
-    user_id VARCHAR(150) NOT NULL,
-    sender VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
-    membership VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    user_id TEXT NOT NULL,
+    sender TEXT NOT NULL,
+    room_id TEXT NOT NULL,
+    membership TEXT NOT NULL,
     UNIQUE (event_id)
 );
 
@@ -87,17 +87,17 @@ CREATE INDEX room_memberships_room_id ON room_memberships (room_id);
 CREATE INDEX room_memberships_user_id ON room_memberships (user_id);
 
 CREATE TABLE IF NOT EXISTS feedback(
-    event_id VARCHAR(150) NOT NULL,
-    feedback_type VARCHAR(150),
-    target_event_id VARCHAR(150),
-    sender VARCHAR(150),
-    room_id VARCHAR(150),
+    event_id TEXT NOT NULL,
+    feedback_type TEXT,
+    target_event_id TEXT,
+    sender TEXT,
+    room_id TEXT,
     UNIQUE (event_id)
 );
 
 CREATE TABLE IF NOT EXISTS topics(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     topic TEXT NOT NULL,
     UNIQUE (event_id)
 );
@@ -105,8 +105,8 @@ CREATE TABLE IF NOT EXISTS topics(
 CREATE INDEX topics_room_id ON topics(room_id);
 
 CREATE TABLE IF NOT EXISTS room_names(
-    event_id VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     name TEXT NOT NULL,
     UNIQUE (event_id)
 );
@@ -114,14 +114,14 @@ CREATE TABLE IF NOT EXISTS room_names(
 CREATE INDEX room_names_room_id ON room_names(room_id);
 
 CREATE TABLE IF NOT EXISTS rooms(
-    room_id VARCHAR(150) PRIMARY KEY NOT NULL,
+    room_id TEXT PRIMARY KEY NOT NULL,
     is_public BOOL,
-    creator VARCHAR(150)
+    creator TEXT
 );
 
 CREATE TABLE IF NOT EXISTS room_hosts(
-    room_id VARCHAR(150) NOT NULL,
-    host VARCHAR(150) NOT NULL,
+    room_id TEXT NOT NULL,
+    host TEXT NOT NULL,
     UNIQUE (room_id, host)
 );
 
diff --git a/synapse/storage/schema/full_schemas/16/keys.sql b/synapse/storage/schema/full_schemas/16/keys.sql
index 459b510427..afc142045e 100644
--- a/synapse/storage/schema/full_schemas/16/keys.sql
+++ b/synapse/storage/schema/full_schemas/16/keys.sql
@@ -13,18 +13,18 @@
  * limitations under the License.
  */
 CREATE TABLE IF NOT EXISTS server_tls_certificates(
-  server_name VARCHAR(150), -- Server name.
-  fingerprint VARCHAR(150), -- Certificate fingerprint.
-  from_server VARCHAR(150), -- Which key server the certificate was fetched from.
+  server_name TEXT, -- Server name.
+  fingerprint TEXT, -- Certificate fingerprint.
+  from_server TEXT, -- Which key server the certificate was fetched from.
   ts_added_ms BIGINT, -- When the certifcate was added.
   tls_certificate bytea, -- DER encoded x509 certificate.
   UNIQUE (server_name, fingerprint)
 );
 
 CREATE TABLE IF NOT EXISTS server_signature_keys(
-  server_name VARCHAR(150), -- Server name.
-  key_id VARCHAR(150), -- Key version.
-  from_server VARCHAR(150), -- Which key server the key was fetched form.
+  server_name TEXT, -- Server name.
+  key_id TEXT, -- Key version.
+  from_server TEXT, -- Which key server the key was fetched form.
   ts_added_ms BIGINT, -- When the key was added.
   verify_key bytea, -- NACL verification key.
   UNIQUE (server_name, key_id)
diff --git a/synapse/storage/schema/full_schemas/16/media_repository.sql b/synapse/storage/schema/full_schemas/16/media_repository.sql
index 0e819fca38..dacbda40ca 100644
--- a/synapse/storage/schema/full_schemas/16/media_repository.sql
+++ b/synapse/storage/schema/full_schemas/16/media_repository.sql
@@ -14,21 +14,21 @@
  */
 
 CREATE TABLE IF NOT EXISTS local_media_repository (
-    media_id VARCHAR(150), -- The id used to refer to the media.
-    media_type VARCHAR(150), -- The MIME-type of the media.
+    media_id TEXT, -- The id used to refer to the media.
+    media_type TEXT, -- The MIME-type of the media.
     media_length INTEGER, -- Length of the media in bytes.
     created_ts BIGINT, -- When the content was uploaded in ms.
-    upload_name VARCHAR(150), -- The name the media was uploaded with.
-    user_id VARCHAR(150), -- The user who uploaded the file.
+    upload_name TEXT, -- The name the media was uploaded with.
+    user_id TEXT, -- The user who uploaded the file.
     UNIQUE (media_id)
 );
 
 CREATE TABLE IF NOT EXISTS local_media_repository_thumbnails (
-    media_id VARCHAR(150), -- The id used to refer to the media.
+    media_id TEXT, -- The id used to refer to the media.
     thumbnail_width INTEGER, -- The width of the thumbnail in pixels.
     thumbnail_height INTEGER, -- The height of the thumbnail in pixels.
-    thumbnail_type VARCHAR(150), -- The MIME-type of the thumbnail.
-    thumbnail_method VARCHAR(150), -- The method used to make the thumbnail.
+    thumbnail_type TEXT, -- The MIME-type of the thumbnail.
+    thumbnail_method TEXT, -- The method used to make the thumbnail.
     thumbnail_length INTEGER, -- The length of the thumbnail in bytes.
     UNIQUE (
         media_id, thumbnail_width, thumbnail_height, thumbnail_type
@@ -39,25 +39,25 @@ CREATE INDEX local_media_repository_thumbnails_media_id
     ON local_media_repository_thumbnails (media_id);
 
 CREATE TABLE IF NOT EXISTS remote_media_cache (
-    media_origin VARCHAR(150), -- The remote HS the media came from.
-    media_id VARCHAR(150), -- The id used to refer to the media on that server.
-    media_type VARCHAR(150), -- The MIME-type of the media.
+    media_origin TEXT, -- The remote HS the media came from.
+    media_id TEXT, -- The id used to refer to the media on that server.
+    media_type TEXT, -- The MIME-type of the media.
     created_ts BIGINT, -- When the content was uploaded in ms.
-    upload_name VARCHAR(150), -- The name the media was uploaded with.
+    upload_name TEXT, -- The name the media was uploaded with.
     media_length INTEGER, -- Length of the media in bytes.
-    filesystem_id VARCHAR(150), -- The name used to store the media on disk.
+    filesystem_id TEXT, -- The name used to store the media on disk.
     UNIQUE (media_origin, media_id)
 );
 
 CREATE TABLE IF NOT EXISTS remote_media_cache_thumbnails (
-    media_origin VARCHAR(150), -- The remote HS the media came from.
-    media_id VARCHAR(150), -- The id used to refer to the media.
+    media_origin TEXT, -- The remote HS the media came from.
+    media_id TEXT, -- The id used to refer to the media.
     thumbnail_width INTEGER, -- The width of the thumbnail in pixels.
     thumbnail_height INTEGER, -- The height of the thumbnail in pixels.
-    thumbnail_method VARCHAR(150), -- The method used to make the thumbnail
-    thumbnail_type VARCHAR(150), -- The MIME-type of the thumbnail.
+    thumbnail_method TEXT, -- The method used to make the thumbnail
+    thumbnail_type TEXT, -- The MIME-type of the thumbnail.
     thumbnail_length INTEGER, -- The length of the thumbnail in bytes.
-    filesystem_id VARCHAR(150), -- The name used to store the media on disk.
+    filesystem_id TEXT, -- The name used to store the media on disk.
     UNIQUE (
         media_origin, media_id, thumbnail_width, thumbnail_height,
         thumbnail_type
diff --git a/synapse/storage/schema/full_schemas/16/presence.sql b/synapse/storage/schema/full_schemas/16/presence.sql
index 9c41be296e..80088413ba 100644
--- a/synapse/storage/schema/full_schemas/16/presence.sql
+++ b/synapse/storage/schema/full_schemas/16/presence.sql
@@ -13,9 +13,9 @@
  * limitations under the License.
  */
 CREATE TABLE IF NOT EXISTS presence(
-  user_id VARCHAR(150) NOT NULL,
+  user_id TEXT NOT NULL,
   state VARCHAR(20),
-  status_msg VARCHAR(150),
+  status_msg TEXT,
   mtime BIGINT, -- miliseconds since last state change
   UNIQUE (user_id)
 );
@@ -23,16 +23,16 @@ CREATE TABLE IF NOT EXISTS presence(
 -- For each of /my/ users which possibly-remote users are allowed to see their
 -- presence state
 CREATE TABLE IF NOT EXISTS presence_allow_inbound(
-  observed_user_id VARCHAR(150) NOT NULL,
-  observer_user_id VARCHAR(150) NOT NULL, -- a UserID,
+  observed_user_id TEXT NOT NULL,
+  observer_user_id TEXT NOT NULL, -- a UserID,
   UNIQUE (observed_user_id, observer_user_id)
 );
 
 -- For each of /my/ users (watcher), which possibly-remote users are they
 -- watching?
 CREATE TABLE IF NOT EXISTS presence_list(
-  user_id VARCHAR(150) NOT NULL,
-  observed_user_id VARCHAR(150) NOT NULL, -- a UserID,
+  user_id TEXT NOT NULL,
+  observed_user_id TEXT NOT NULL, -- a UserID,
   accepted BOOLEAN NOT NULL,
   UNIQUE (user_id, observed_user_id)
 );
diff --git a/synapse/storage/schema/full_schemas/16/profiles.sql b/synapse/storage/schema/full_schemas/16/profiles.sql
index 21c58a99bc..934be86520 100644
--- a/synapse/storage/schema/full_schemas/16/profiles.sql
+++ b/synapse/storage/schema/full_schemas/16/profiles.sql
@@ -13,8 +13,8 @@
  * limitations under the License.
  */
 CREATE TABLE IF NOT EXISTS profiles(
-    user_id VARCHAR(150) NOT NULL,
-    displayname VARCHAR(150),
-    avatar_url VARCHAR(150),
+    user_id TEXT NOT NULL,
+    displayname TEXT,
+    avatar_url TEXT,
     UNIQUE(user_id)
 );
diff --git a/synapse/storage/schema/full_schemas/16/push.sql b/synapse/storage/schema/full_schemas/16/push.sql
index 5c0c7bc201..db6e05cbdf 100644
--- a/synapse/storage/schema/full_schemas/16/push.sql
+++ b/synapse/storage/schema/full_schemas/16/push.sql
@@ -14,16 +14,16 @@
  */
 
 CREATE TABLE IF NOT EXISTS rejections(
-    event_id VARCHAR(150) NOT NULL,
-    reason VARCHAR(150) NOT NULL,
-    last_check VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    reason TEXT NOT NULL,
+    last_check TEXT NOT NULL,
     UNIQUE (event_id)
 );
 
 -- Push notification endpoints that users have configured
 CREATE TABLE IF NOT EXISTS pushers (
   id BIGINT PRIMARY KEY,
-  user_name VARCHAR(150) NOT NULL,
+  user_name TEXT NOT NULL,
   profile_tag VARCHAR(32) NOT NULL,
   kind VARCHAR(8) NOT NULL,
   app_id VARCHAR(64) NOT NULL,
@@ -41,19 +41,19 @@ CREATE TABLE IF NOT EXISTS pushers (
 
 CREATE TABLE IF NOT EXISTS push_rules (
   id BIGINT PRIMARY KEY,
-  user_name VARCHAR(150) NOT NULL,
-  rule_id VARCHAR(150) NOT NULL,
+  user_name TEXT NOT NULL,
+  rule_id TEXT NOT NULL,
   priority_class SMALLINT NOT NULL,
   priority INTEGER NOT NULL DEFAULT 0,
-  conditions VARCHAR(150) NOT NULL,
-  actions VARCHAR(150) NOT NULL,
+  conditions TEXT NOT NULL,
+  actions TEXT NOT NULL,
   UNIQUE(user_name, rule_id)
 );
 
 CREATE INDEX push_rules_user_name on push_rules (user_name);
 
 CREATE TABLE IF NOT EXISTS user_filters(
-  user_id VARCHAR(150),
+  user_id TEXT,
   filter_id BIGINT,
   filter_json bytea
 );
@@ -64,8 +64,8 @@ CREATE INDEX user_filters_by_user_id_filter_id ON user_filters(
 
 CREATE TABLE IF NOT EXISTS push_rules_enable (
   id BIGINT PRIMARY KEY,
-  user_name VARCHAR(150) NOT NULL,
-  rule_id VARCHAR(150) NOT NULL,
+  user_name TEXT NOT NULL,
+  rule_id TEXT NOT NULL,
   enabled SMALLINT,
   UNIQUE(user_name, rule_id)
 );
diff --git a/synapse/storage/schema/full_schemas/16/redactions.sql b/synapse/storage/schema/full_schemas/16/redactions.sql
index 492fd22033..69621955d4 100644
--- a/synapse/storage/schema/full_schemas/16/redactions.sql
+++ b/synapse/storage/schema/full_schemas/16/redactions.sql
@@ -13,8 +13,8 @@
  * limitations under the License.
  */
 CREATE TABLE IF NOT EXISTS redactions (
-    event_id VARCHAR(150) NOT NULL,
-    redacts VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
+    redacts TEXT NOT NULL,
     UNIQUE (event_id)
 );
 
diff --git a/synapse/storage/schema/full_schemas/16/room_aliases.sql b/synapse/storage/schema/full_schemas/16/room_aliases.sql
index 2c0853a2a9..412bb97fad 100644
--- a/synapse/storage/schema/full_schemas/16/room_aliases.sql
+++ b/synapse/storage/schema/full_schemas/16/room_aliases.sql
@@ -14,16 +14,16 @@
  */
 
 CREATE TABLE IF NOT EXISTS room_aliases(
-    room_alias VARCHAR(150) NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
+    room_alias TEXT NOT NULL,
+    room_id TEXT NOT NULL,
     UNIQUE (room_alias)
 );
 
 CREATE INDEX room_aliases_id ON room_aliases(room_id);
 
 CREATE TABLE IF NOT EXISTS room_alias_servers(
-    room_alias VARCHAR(150) NOT NULL,
-    server VARCHAR(150) NOT NULL
+    room_alias TEXT NOT NULL,
+    server TEXT NOT NULL
 );
 
 CREATE INDEX room_alias_servers_alias ON room_alias_servers(room_alias);
diff --git a/synapse/storage/schema/full_schemas/16/state.sql b/synapse/storage/schema/full_schemas/16/state.sql
index b0cd5ee75a..705cac6ce9 100644
--- a/synapse/storage/schema/full_schemas/16/state.sql
+++ b/synapse/storage/schema/full_schemas/16/state.sql
@@ -15,20 +15,20 @@
 
 CREATE TABLE IF NOT EXISTS state_groups(
     id BIGINT PRIMARY KEY,
-    room_id VARCHAR(150) NOT NULL,
-    event_id VARCHAR(150) NOT NULL
+    room_id TEXT NOT NULL,
+    event_id TEXT NOT NULL
 );
 
 CREATE TABLE IF NOT EXISTS state_groups_state(
     state_group BIGINT NOT NULL,
-    room_id VARCHAR(150) NOT NULL,
-    type VARCHAR(150) NOT NULL,
-    state_key VARCHAR(150) NOT NULL,
-    event_id VARCHAR(150) NOT NULL
+    room_id TEXT NOT NULL,
+    type TEXT NOT NULL,
+    state_key TEXT NOT NULL,
+    event_id TEXT NOT NULL
 );
 
 CREATE TABLE IF NOT EXISTS event_to_state_groups(
-    event_id VARCHAR(150) NOT NULL,
+    event_id TEXT NOT NULL,
     state_group BIGINT NOT NULL,
     UNIQUE (event_id)
 );
diff --git a/synapse/storage/schema/full_schemas/16/transactions.sql b/synapse/storage/schema/full_schemas/16/transactions.sql
index ed431bd3af..1ab77cdb63 100644
--- a/synapse/storage/schema/full_schemas/16/transactions.sql
+++ b/synapse/storage/schema/full_schemas/16/transactions.sql
@@ -14,8 +14,8 @@
  */
 -- Stores what transaction ids we have received and what our response was
 CREATE TABLE IF NOT EXISTS received_transactions(
-    transaction_id VARCHAR(150),
-    origin VARCHAR(150),
+    transaction_id TEXT,
+    origin TEXT,
     ts BIGINT,
     response_code INTEGER,
     response_json bytea,
@@ -30,8 +30,8 @@ CREATE INDEX transactions_have_ref ON received_transactions(origin, has_been_ref
 -- since referenced the transaction in another outgoing transaction
 CREATE TABLE IF NOT EXISTS sent_transactions(
     id BIGINT PRIMARY KEY, -- This is used to apply insertion ordering
-    transaction_id VARCHAR(150),
-    destination VARCHAR(150),
+    transaction_id TEXT,
+    destination TEXT,
     response_code INTEGER DEFAULT 0,
     response_json TEXT,
     ts BIGINT
@@ -47,9 +47,9 @@ CREATE INDEX sent_transaction_sent ON sent_transactions(response_code);
 -- For sent transactions only.
 CREATE TABLE IF NOT EXISTS transaction_id_to_pdu(
     transaction_id INTEGER,
-    destination VARCHAR(150),
-    pdu_id VARCHAR(150),
-    pdu_origin VARCHAR(150),
+    destination TEXT,
+    pdu_id TEXT,
+    pdu_origin TEXT,
     UNIQUE (transaction_id, destination)
 );
 
@@ -57,7 +57,7 @@ CREATE INDEX transaction_id_to_pdu_dest ON transaction_id_to_pdu(destination);
 
 -- To track destination health
 CREATE TABLE IF NOT EXISTS destinations(
-    destination VARCHAR(150) PRIMARY KEY,
+    destination TEXT PRIMARY KEY,
     retry_last_ts BIGINT,
     retry_interval INTEGER
 );
diff --git a/synapse/storage/schema/full_schemas/16/users.sql b/synapse/storage/schema/full_schemas/16/users.sql
index 033e3244b5..d2fa3122da 100644
--- a/synapse/storage/schema/full_schemas/16/users.sql
+++ b/synapse/storage/schema/full_schemas/16/users.sql
@@ -13,8 +13,8 @@
  * limitations under the License.
  */
 CREATE TABLE IF NOT EXISTS users(
-    name VARCHAR(150),
-    password_hash VARCHAR(150),
+    name TEXT,
+    password_hash TEXT,
     creation_ts BIGINT,
     admin SMALLINT DEFAULT 0 NOT NULL,
     UNIQUE(name)
@@ -22,18 +22,18 @@ CREATE TABLE IF NOT EXISTS users(
 
 CREATE TABLE IF NOT EXISTS access_tokens(
     id BIGINT PRIMARY KEY,
-    user_id VARCHAR(150) NOT NULL,
-    device_id VARCHAR(150),
-    token VARCHAR(150) NOT NULL,
+    user_id TEXT NOT NULL,
+    device_id TEXT,
+    token TEXT NOT NULL,
     last_used BIGINT,
     UNIQUE(token)
 );
 
 CREATE TABLE IF NOT EXISTS user_ips (
-    user_id VARCHAR(150) NOT NULL,
-    access_token VARCHAR(150) NOT NULL,
-    device_id VARCHAR(150),
-    ip VARCHAR(150) NOT NULL,
+    user_id TEXT NOT NULL,
+    access_token TEXT NOT NULL,
+    device_id TEXT,
+    ip TEXT NOT NULL,
     user_agent TEXT NOT NULL,
     last_seen BIGINT NOT NULL
 );
diff --git a/synapse/storage/schema/schema_version.sql b/synapse/storage/schema/schema_version.sql
index d9494611e0..d682608aa0 100644
--- a/synapse/storage/schema/schema_version.sql
+++ b/synapse/storage/schema/schema_version.sql
@@ -22,6 +22,6 @@ CREATE TABLE IF NOT EXISTS schema_version(
 
 CREATE TABLE IF NOT EXISTS applied_schema_deltas(
     version INTEGER NOT NULL,
-    file VARCHAR(150) NOT NULL,
+    file TEXT NOT NULL,
     UNIQUE(version, file)
 );