π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Finalize token hash constraints
Neeraj Gupta27eea8449ecd
diff --git a/server/migrations/136_token_hash_unique_idx.down.sql b/server/migrations/136_token_hash_unique_idx.down.sqlnew file mode 100644index 0000000000..097c7c0337--- /dev/null+++ b/server/migrations/136_token_hash_unique_idx.down.sql@@ -0,0 +1 @@+DROP INDEX CONCURRENTLY tokens_token_hash_unique_idx;diff --git a/server/migrations/136_token_hash_unique_idx.up.sql b/server/migrations/136_token_hash_unique_idx.up.sqlnew file mode 100644index 0000000000..52b27e1219--- /dev/null+++ b/server/migrations/136_token_hash_unique_idx.up.sql@@ -0,0 +1 @@+CREATE UNIQUE INDEX CONCURRENTLY tokens_token_hash_unique_idx ON tokens (token_hash);diff --git a/server/migrations/137_token_hash_constraints.down.sql b/server/migrations/137_token_hash_constraints.down.sqlnew file mode 100644index 0000000000..f9a4bad0a1--- /dev/null+++ b/server/migrations/137_token_hash_constraints.down.sql@@ -0,0 +1,3 @@+ALTER TABLE tokens+ DROP CONSTRAINT tokens_token_hash_present,+ DROP CONSTRAINT tokens_token_hash_length;diff --git a/server/migrations/137_token_hash_constraints.up.sql b/server/migrations/137_token_hash_constraints.up.sqlnew file mode 100644index 0000000000..30ce3d1390--- /dev/null+++ b/server/migrations/137_token_hash_constraints.up.sql@@ -0,0 +1,3 @@+ALTER TABLE tokens+ ADD CONSTRAINT tokens_token_hash_present CHECK (token_hash IS NOT NULL) NOT VALID,+ ADD CONSTRAINT tokens_token_hash_length CHECK (octet_length(token_hash) = 32) NOT VALID;diff --git a/server/migrations/138_validate_token_hash_constraints.down.sql b/server/migrations/138_validate_token_hash_constraints.down.sqlnew file mode 100644index 0000000000..051e54d0d4--- /dev/null+++ b/server/migrations/138_validate_token_hash_constraints.down.sql@@ -0,0 +1,5 @@+ALTER TABLE tokens+ DROP CONSTRAINT tokens_token_hash_present,+ ADD CONSTRAINT tokens_token_hash_present CHECK (token_hash IS NOT NULL) NOT VALID,+ DROP CONSTRAINT tokens_token_hash_length,+ ADD CONSTRAINT tokens_token_hash_length CHECK (octet_length(token_hash) = 32) NOT VALID;diff --git a/server/migrations/138_validate_token_hash_constraints.up.sql b/server/migrations/138_validate_token_hash_constraints.up.sqlnew file mode 100644index 0000000000..c5e5f54228--- /dev/null+++ b/server/migrations/138_validate_token_hash_constraints.up.sql@@ -0,0 +1,3 @@+ALTER TABLE tokens+ VALIDATE CONSTRAINT tokens_token_hash_present,+ VALIDATE CONSTRAINT tokens_token_hash_length;diff --git a/server/migrations/139_finalize_token_hash_columns.down.sql b/server/migrations/139_finalize_token_hash_columns.down.sqlnew file mode 100644index 0000000000..495566d1b5--- /dev/null+++ b/server/migrations/139_finalize_token_hash_columns.down.sql@@ -0,0 +1,3 @@+ALTER TABLE tokens+ ALTER COLUMN token_hash DROP NOT NULL,+ ADD CONSTRAINT tokens_token_hash_present CHECK (token_hash IS NOT NULL);diff --git a/server/migrations/139_finalize_token_hash_columns.up.sql b/server/migrations/139_finalize_token_hash_columns.up.sqlnew file mode 100644index 0000000000..07be0c54bb--- /dev/null+++ b/server/migrations/139_finalize_token_hash_columns.up.sql@@ -0,0 +1,9 @@+BEGIN;++ALTER TABLE tokens+ ALTER COLUMN token_hash SET NOT NULL;++ALTER TABLE tokens+ DROP CONSTRAINT tokens_token_hash_present;++COMMIT;