From 3431b5f602f86f9feda5af6e4d0144a5e051ec35 Mon Sep 17 00:00:00 2001
From: Runxi Yu <me@runxiyu.org>
Date: Sun, 16 Feb 2025 03:49:51 +0800
Subject: schema.sql: Don't use key_string UNIQUE

It creates a btree index, so very long keys won't work.
---
 schema.sql | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'schema.sql')

diff --git a/schema.sql b/schema.sql
index 9dc83c7..1797466 100644
--- a/schema.sql
+++ b/schema.sql
@@ -52,8 +52,10 @@ CREATE TABLE users (
 );
 
 CREATE TABLE ssh_public_keys (
-	key_string TEXT PRIMARY KEY NOT NULL,
-	user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE
+	id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
+	key_string TEXT NOT NULL,
+	user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
+	CONSTRAINT unique_key_string EXCLUDE USING HASH (key_string WITH =)
 );
 
 CREATE TABLE sessions (
-- 
cgit v1.2.3

