Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Prune migration comments

Manav Rathi9a07b87d5df9
diff --git a/server/migrations/107_add_srp_fake_session_tracking.down.sql b/server/migrations/107_add_srp_fake_session_tracking.down.sql
index 2ec79f310f..a99e69115b 100644
--- a/server/migrations/107_add_srp_fake_session_tracking.down.sql
+++ b/server/migrations/107_add_srp_fake_session_tracking.down.sql
@@ -1,3 +1,2 @@
--- Remove the fake session tracking
DROP INDEX IF EXISTS idx_srp_sessions_fake_created;
ALTER TABLE srp_sessions DROP COLUMN IF EXISTS is_fake;
diff --git a/server/migrations/107_add_srp_fake_session_tracking.up.sql b/server/migrations/107_add_srp_fake_session_tracking.up.sql
index b251a27178..8cda65244d 100644
--- a/server/migrations/107_add_srp_fake_session_tracking.up.sql
+++ b/server/migrations/107_add_srp_fake_session_tracking.up.sql
@@ -2,7 +2,6 @@
ALTER TABLE srp_sessions
ADD COLUMN IF NOT EXISTS is_fake BOOLEAN NOT NULL DEFAULT false;
--- Create an index to help with cleanup of fake sessions
CREATE INDEX IF NOT EXISTS idx_srp_sessions_fake_created
ON srp_sessions(is_fake, created_at)
WHERE is_fake = true;
diff --git a/server/migrations/109_add_admin_role_enum.up.sql b/server/migrations/109_add_admin_role_enum.up.sql
index 8e99cf79c8..19925605df 100644
--- a/server/migrations/109_add_admin_role_enum.up.sql
+++ b/server/migrations/109_add_admin_role_enum.up.sql
@@ -1,2 +1 @@
--- Add ADMIN role to collection share role enum
ALTER TYPE role_enum ADD VALUE IF NOT EXISTS 'ADMIN';
diff --git a/server/migrations/111_update_favorites_constraint.down.sql b/server/migrations/111_update_favorites_constraint.down.sql
index 20e3beab0a..79a4c2c429 100644
--- a/server/migrations/111_update_favorites_constraint.down.sql
+++ b/server/migrations/111_update_favorites_constraint.down.sql
@@ -1,7 +1,4 @@
--- Revert favorites uniqueness back to per (owner_id) only
-
DROP INDEX IF EXISTS collections_favorites_constraint_index_v2;
CREATE UNIQUE INDEX IF NOT EXISTS collections_favorites_constraint_index ON collections (owner_id)
WHERE (type = 'favorites');
-
diff --git a/server/migrations/111_update_favorites_constraint.up.sql b/server/migrations/111_update_favorites_constraint.up.sql
index e65da6ed7d..cdc30b6875 100644
--- a/server/migrations/111_update_favorites_constraint.up.sql
+++ b/server/migrations/111_update_favorites_constraint.up.sql
@@ -1,9 +1,4 @@
--- Make favorites unique per (owner_id, app), similar to uncategorized
-
CREATE UNIQUE INDEX IF NOT EXISTS collections_favorites_constraint_index_v2 ON collections (owner_id, app)
WHERE (type = 'favorites');
--- Drop the older index if it exists
-
DROP INDEX IF EXISTS collections_favorites_constraint_index;
-
diff --git a/server/migrations/114_comments_reactions.down.sql b/server/migrations/114_comments_reactions.down.sql
index 53d59890e5..187718865b 100644
--- a/server/migrations/114_comments_reactions.down.sql
+++ b/server/migrations/114_comments_reactions.down.sql
@@ -1,6 +1,3 @@
--- Drop comments/reactions schema introduced in 114_comments_reactions.up.sql
-
--- Drop triggers first
DROP TRIGGER IF EXISTS check_reaction_target ON reactions;
DROP TRIGGER IF EXISTS update_reactions_updated_at ON reactions;
DROP TRIGGER IF EXISTS reactions_null_cipher_on_delete ON reactions;
@@ -10,7 +7,6 @@ DROP TRIGGER IF EXISTS check_reply_scope ON comments;
DROP TRIGGER IF EXISTS update_comments_updated_at ON comments;
DROP TRIGGER IF EXISTS comments_null_cipher_on_delete ON comments;
--- Drop indexes (will be dropped with table if cascade, but include for clarity)
DROP INDEX IF EXISTS idx_reactions_user;
DROP INDEX IF EXISTS idx_reactions_anon;
DROP INDEX IF EXISTS idx_reactions_comment;
@@ -25,14 +21,12 @@ DROP INDEX IF EXISTS idx_comments_anon;
DROP INDEX IF EXISTS idx_anon_users_collection;
--- Drop tables
DROP TRIGGER IF EXISTS update_anon_users_updated_at ON anon_users;
DROP TABLE IF EXISTS reactions;
DROP TABLE IF EXISTS comments;
DROP TABLE IF EXISTS anon_users;
--- Drop helper functions (safe if unused elsewhere)
DROP FUNCTION IF EXISTS tg_soft_delete_reactions_on_comment_delete();
DROP FUNCTION IF EXISTS tg_check_reaction_target();
DROP FUNCTION IF EXISTS tg_check_reply_scope();
diff --git a/server/migrations/114_comments_reactions.up.sql b/server/migrations/114_comments_reactions.up.sql
index 9c79f86205..c59c01316d 100644
--- a/server/migrations/114_comments_reactions.up.sql
+++ b/server/migrations/114_comments_reactions.up.sql
@@ -1,9 +1,5 @@
--- Create comments and reactions tables with E2EE payloads, tombstones, and delta-sync indexes
--- Uses BIGINT microsecond timestamps via now_utc_micro_seconds()
-
-- App supplies nanoid strings for primary keys; no pgcrypto dependency.
--- Helper: null cipher when tombstoned
CREATE OR REPLACE FUNCTION tg_null_cipher_on_delete() RETURNS trigger AS $$
BEGIN
IF NEW.is_deleted THEN
@@ -13,7 +9,6 @@ BEGIN
RETURN NEW;
END; $$ LANGUAGE plpgsql;
--- Enforce replies stay within parent scope
CREATE OR REPLACE FUNCTION tg_check_reply_scope() RETURNS trigger AS $$
BEGIN
IF NEW.parent_comment_id IS NULL THEN
@@ -29,7 +24,6 @@ BEGIN
RETURN NEW;
END; $$ LANGUAGE plpgsql;
--- Enforce reaction target integrity (if comment reaction, collection must match)
CREATE OR REPLACE FUNCTION tg_check_reaction_target() RETURNS trigger AS $$
DECLARE
c_rec RECORD;
@@ -47,7 +41,6 @@ BEGIN
RETURN NEW;
END; $$ LANGUAGE plpgsql;
--- Anonymous users table storing encrypted profile metadata for public commenters
CREATE TABLE IF NOT EXISTS anon_users (
id TEXT PRIMARY KEY,
collection_id BIGINT NOT NULL,
@@ -64,7 +57,6 @@ CREATE TRIGGER update_anon_users_updated_at
BEFORE UPDATE ON anon_users
FOR EACH ROW EXECUTE PROCEDURE trigger_updated_at_microseconds_column();
--- Soft-delete all reactions for a comment when the comment is tombstoned
CREATE OR REPLACE FUNCTION tg_soft_delete_reactions_on_comment_delete() RETURNS trigger AS $$
BEGIN
IF NEW.is_deleted AND (OLD.is_deleted IS DISTINCT FROM NEW.is_deleted) THEN
@@ -79,7 +71,6 @@ BEGIN
RETURN NEW;
END; $$ LANGUAGE plpgsql;
--- Comments table
CREATE TABLE IF NOT EXISTS comments (
id TEXT PRIMARY KEY,
@@ -109,7 +100,6 @@ CREATE TABLE IF NOT EXISTS comments (
CONSTRAINT fk_comments_anon_user FOREIGN KEY (anon_user_id) REFERENCES anon_users (id)
);
--- Indexes for comments
CREATE INDEX IF NOT EXISTS idx_comments_scope
ON comments (collection_id, file_id)
WHERE is_deleted = FALSE;
@@ -126,11 +116,9 @@ CREATE INDEX IF NOT EXISTS idx_comments_anon
ON comments (anon_user_id)
WHERE is_deleted = FALSE;
--- Delta sync by collection and updated_at
CREATE INDEX IF NOT EXISTS idx_comments_collection_updated_at
ON comments (collection_id, updated_at);
--- Triggers for comments
CREATE TRIGGER comments_null_cipher_on_delete
BEFORE INSERT OR UPDATE ON comments
FOR EACH ROW EXECUTE PROCEDURE tg_null_cipher_on_delete();
@@ -148,7 +136,6 @@ CREATE TRIGGER soft_delete_reactions_on_comment_delete
FOR EACH ROW WHEN (NEW.is_deleted)
EXECUTE PROCEDURE tg_soft_delete_reactions_on_comment_delete();
--- Reactions table (multi-scope: collection, file, or comment)
CREATE TABLE IF NOT EXISTS reactions (
id TEXT PRIMARY KEY,
@@ -174,20 +161,17 @@ CREATE TABLE IF NOT EXISTS reactions (
created_at BIGINT NOT NULL DEFAULT now_utc_micro_seconds(),
updated_at BIGINT NOT NULL DEFAULT now_utc_micro_seconds(),
- -- Only one of: comment OR (collection[/file])
CONSTRAINT reactions_target_shape CHECK (
(comment_id IS NOT NULL AND file_id IS NULL)
OR
(comment_id IS NULL)
),
- -- Enforce payload nulling on tombstone
CONSTRAINT reactions_cipher_on_delete CHECK (
(is_deleted = FALSE AND cipher IS NOT NULL AND nonce IS NOT NULL) OR
(is_deleted = TRUE AND cipher IS NULL AND nonce IS NULL)
),
- -- Unified identity for target to enforce one-per-user-per-target
unique_key TEXT GENERATED ALWAYS AS (
CASE
WHEN comment_id IS NOT NULL THEN 'M:' || comment_id::TEXT
@@ -204,16 +188,13 @@ CREATE TABLE IF NOT EXISTS reactions (
CONSTRAINT fk_reactions_anon_user FOREIGN KEY (anon_user_id) REFERENCES anon_users (id)
);
--- Indexes for reactions
CREATE INDEX IF NOT EXISTS idx_reactions_scope
ON reactions (collection_id, file_id, comment_id)
WHERE is_deleted = FALSE;
--- Delta sync by collection and updated_at
CREATE INDEX IF NOT EXISTS idx_reactions_collection_updated_at
ON reactions (collection_id, updated_at);
--- Per-comment lookups
CREATE INDEX IF NOT EXISTS idx_reactions_comment
ON reactions (comment_id)
WHERE is_deleted = FALSE;
@@ -226,7 +207,6 @@ CREATE INDEX IF NOT EXISTS idx_reactions_anon
ON reactions (anon_user_id)
WHERE is_deleted = FALSE;
--- Triggers for reactions
CREATE TRIGGER reactions_null_cipher_on_delete
BEFORE INSERT OR UPDATE ON reactions
FOR EACH ROW EXECUTE PROCEDURE tg_null_cipher_on_delete();
diff --git a/server/migrations/119_create_memory_shares.up.sql b/server/migrations/119_create_memory_shares.up.sql
index 62b0eed1ad..161dd0b43d 100644
--- a/server/migrations/119_create_memory_shares.up.sql
+++ b/server/migrations/119_create_memory_shares.up.sql
@@ -1,4 +1,3 @@
--- Memory share table - stores shared memory metadata
CREATE TABLE IF NOT EXISTS memory_shares (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(user_id),
@@ -14,7 +13,6 @@ CREATE TABLE IF NOT EXISTS memory_shares (
updated_at BIGINT NOT NULL
);
--- Memory share files - tracks files in each memory share with their owners
CREATE TABLE IF NOT EXISTS memory_share_files (
id BIGSERIAL PRIMARY KEY,
memory_share_id BIGINT NOT NULL REFERENCES memory_shares(id) ON DELETE CASCADE,
diff --git a/server/migrations/22_add_location_tag_table.up.sql b/server/migrations/22_add_location_tag_table.up.sql
index 4f1075698c..fb0b9eed54 100644
--- a/server/migrations/22_add_location_tag_table.up.sql
+++ b/server/migrations/22_add_location_tag_table.up.sql
@@ -3,7 +3,6 @@ $$
SELECT CAST(extract(EPOCH from now() at time zone 'utc') * 1000000 as BIGINT) ;
$$ language sql;
--- We can reuse this func to create triggers in other tables.
CREATE OR REPLACE FUNCTION trigger_updated_at_microseconds_column()
RETURNS TRIGGER AS
$$
diff --git a/server/migrations/27_consolidate_files_table.up.sql b/server/migrations/27_consolidate_files_table.up.sql
index 9cdb937916..77285de814 100644
--- a/server/migrations/27_consolidate_files_table.up.sql
+++ b/server/migrations/27_consolidate_files_table.up.sql
@@ -24,7 +24,6 @@ CREATE TRIGGER update_object_keys_updated_at
EXECUTE PROCEDURE
trigger_updated_at_microseconds_column();
--- copy data from existing tables to this new table.
BEGIN;
INSERT INTO object_keys(file_id, o_type, object_key, size, datacenters)
SELECT file_id, 'file', object_key,size, datacenters FROM file_object_keys;
diff --git a/server/migrations/37_public_collection.up.sql b/server/migrations/37_public_collection.up.sql
index 66c911913b..fa544e357a 100644
--- a/server/migrations/37_public_collection.up.sql
+++ b/server/migrations/37_public_collection.up.sql
@@ -61,7 +61,6 @@ EXECUTE PROCEDURE
CREATE OR REPLACE FUNCTION fn_update_collections_updation_time_using_update_at() RETURNS TRIGGER AS $$
BEGIN
- --
IF (TG_OP = 'UPDATE' OR TG_OP = 'INSERT') THEN
UPDATE collections SET updation_time = NEW.updated_at where collection_id = new.collection_id and
updation_time < New.updated_at;
diff --git a/server/migrations/43_family_plan.up.sql b/server/migrations/43_family_plan.up.sql
index 896a89a198..f103b567a1 100644
--- a/server/migrations/43_family_plan.up.sql
+++ b/server/migrations/43_family_plan.up.sql
@@ -24,10 +24,8 @@ CREATE TABLE IF NOT EXISTS families
CREATE INDEX IF NOT EXISTS fk_families_admin_id ON families (admin_id);
--- check to ensure that the member is not part of or is admin of another family group
CREATE UNIQUE INDEX uidx_one_family_check on families (member_id, status) where status in ('ACCEPTED', 'SELF');
--- index to ensure that there's only one entry for admin and member.
CREATE UNIQUE INDEX uidx_families_member_mapping on families (admin_id, member_id);
ALTER TABLE families
@@ -41,4 +39,3 @@ CREATE TRIGGER update_families_updated_at
FOR EACH ROW
EXECUTE PROCEDURE
trigger_updated_at_microseconds_column();
-
diff --git a/server/migrations/52_authenticator.up.sql b/server/migrations/52_authenticator.up.sql
index 79f94180a6..71401efd82 100644
--- a/server/migrations/52_authenticator.up.sql
+++ b/server/migrations/52_authenticator.up.sql
@@ -36,10 +36,8 @@ EXECUTE PROCEDURE
trigger_updated_at_microseconds_column();
--- This function updates the authenticator_key updated_at if the relevant authenticator entry is changed
CREATE OR REPLACE FUNCTION fn_update_authenticator_key_updated_at_via_updated_at() RETURNS TRIGGER AS $$
BEGIN
- --
IF (TG_OP = 'UPDATE' OR TG_OP = 'INSERT') THEN
UPDATE authenticator_key SET updated_at = NEW.updated_at where user_id = new.user_id and
updated_at < New.updated_at;
@@ -54,4 +52,3 @@ CREATE TRIGGER trigger_authenticator_key_updated_time_on_authenticator_entity_up
FOR EACH ROW
EXECUTE PROCEDURE
fn_update_authenticator_key_updated_at_via_updated_at();
-
diff --git a/server/migrations/57_object_copies.up.sql b/server/migrations/57_object_copies.up.sql
index 4832bcb65c..bca27e0f88 100644
--- a/server/migrations/57_object_copies.up.sql
+++ b/server/migrations/57_object_copies.up.sql
@@ -20,7 +20,5 @@ ON object_copies (scw) WHERE scw IS NULL AND want_scw = true;
-- object_copies serves a queue for which all objects still need to be
-- replicated. However, the canonical source of truth for an object is still
-- maintained in the original object_keys table.
---
--- Add types for the new dcs that are introduced as part of replication v3.
ALTER TYPE s3region ADD VALUE 'wasabi-eu-central-2-v3';
ALTER TYPE s3region ADD VALUE 'scw-eu-fr-v3';
diff --git a/server/migrations/61_storage_bonus.up.sql b/server/migrations/61_storage_bonus.up.sql
index 42e7a32391..31ecbe44f6 100644
--- a/server/migrations/61_storage_bonus.up.sql
+++ b/server/migrations/61_storage_bonus.up.sql
@@ -6,7 +6,6 @@ CREATE TABLE IF NOT EXISTS referral_codes
created_at bigint NOT NULL DEFAULT now_utc_micro_seconds(),
PRIMARY KEY (code)
);
---- Ensure that only one active referral code is allowed per user
CREATE UNIQUE INDEX ON referral_codes (user_id, is_active) WHERE (referral_codes.is_active = TRUE);
CREATE TABLE IF NOT EXISTS referral_tracking
@@ -17,8 +16,6 @@ CREATE TABLE IF NOT EXISTS referral_tracking
invitee_on_paid_plan bool default false,
created_at bigint NOT NULL DEFAULT now_utc_micro_seconds()
);
---- Add unique index on invitor_id and invitee_id column in referral_tracking table to ensure only
--- one entry per invitee is allowed
CREATE UNIQUE INDEX IF NOT EXISTS referral_tracking_invitee_id_idx ON referral_tracking (invitee_id);
@@ -43,4 +40,3 @@ CREATE TABLE IF NOT EXISTS storage_bonus
CREATE INDEX IF NOT EXISTS storage_bonus_user_id_idx ON storage_bonus (user_id);
-
diff --git a/server/migrations/62_entity_store.up.sql b/server/migrations/62_entity_store.up.sql
index 3d9d4803d1..018e786f00 100644
--- a/server/migrations/62_entity_store.up.sql
+++ b/server/migrations/62_entity_store.up.sql
@@ -39,11 +39,9 @@ EXECUTE PROCEDURE
trigger_updated_at_microseconds_column();
--- This function updates the entity_key updated_at if the relevant entity_data is changed
CREATE OR REPLACE FUNCTION fn_update_entity_key_updated_at_via_updated_at() RETURNS TRIGGER AS
$$
BEGIN
- --
IF (TG_OP = 'UPDATE' OR TG_OP = 'INSERT') THEN
UPDATE entity_key
SET updated_at = NEW.updated_at
@@ -61,4 +59,3 @@ CREATE TRIGGER trigger_entity_key_on_entity_data_updation
FOR EACH ROW
EXECUTE PROCEDURE
fn_update_entity_key_updated_at_via_updated_at();
-
diff --git a/server/migrations/68_add_locker_changes.down.sql b/server/migrations/68_add_locker_changes.down.sql
index 8d66fb94b4..865832db8f 100644
--- a/server/migrations/68_add_locker_changes.down.sql
+++ b/server/migrations/68_add_locker_changes.down.sql
@@ -1,20 +1,10 @@
--- Drop the new unique index
-
DROP INDEX IF EXISTS collections_uncategorized_constraint_index_v2;
--- Re-create the old unique index
-
CREATE UNIQUE INDEX IF NOT EXISTS collections_uncategorized_constraint_index ON collections (owner_id, app)
WHERE (type = 'uncategorized');
--- Remove NOT NULL constraints
-
ALTER TABLE collections ALTER COLUMN app DROP NOT NULL;
--- Remove default values
-
ALTER TABLE collections ALTER COLUMN app DROP DEFAULT;
--- Update columns back to NULL
-
UPDATE collections SET app = NULL WHERE app = 'photos';
diff --git a/server/migrations/68_add_locker_changes.up.sql b/server/migrations/68_add_locker_changes.up.sql
index b836240a87..ec73201be9 100644
--- a/server/migrations/68_add_locker_changes.up.sql
+++ b/server/migrations/68_add_locker_changes.up.sql
@@ -1,22 +1,12 @@
ALTER TYPE app ADD VALUE 'locker';
--- Alter the column to make it non-null
-
ALTER TABLE collections ADD COLUMN app app DEFAULT 'photos';
--- Update the existing app that are null to default ("photos") and make it non null.
-
UPDATE collections SET app = 'photos' WHERE app IS NULL;
--- Alter the column to make it non-null
-
ALTER TABLE collections ALTER COLUMN app SET NOT NULL;
--- Create a new unique index for uncategorized collections
-
CREATE UNIQUE INDEX IF NOT EXISTS collections_uncategorized_constraint_index_v2 ON collections (owner_id, app)
WHERE (type = 'uncategorized');
--- Drop the older index if it exists
-
DROP INDEX IF EXISTS collections_uncategorized_constraint_index;
\ No newline at end of file
diff --git a/server/migrations/71_user_source_attr.down.sql b/server/migrations/71_user_source_attr.down.sql
index d0f42f7d20..c070026c27 100644
--- a/server/migrations/71_user_source_attr.down.sql
+++ b/server/migrations/71_user_source_attr.down.sql
@@ -1,6 +1,4 @@
--- DELETE source column if exists
ALTER TABLE users
DROP COLUMN IF EXISTS source;
--- DELETE delete_feedback column if exists
ALTER TABLE users
DROP COLUMN IF EXISTS delete_feedback;
diff --git a/server/migrations/71_user_source_attr.up.sql b/server/migrations/71_user_source_attr.up.sql
index 430abaa3a1..a833101e4d 100644
--- a/server/migrations/71_user_source_attr.up.sql
+++ b/server/migrations/71_user_source_attr.up.sql
@@ -1,5 +1,4 @@
ALTER TABLE users
ADD COLUMN IF NOT EXISTS source text;
--- Add JSON column to capture delete feedback
ALTER TABLE users
ADD COLUMN IF NOT EXISTS delete_feedback jsonb;
diff --git a/server/migrations/75_add_passkeys.up.sql b/server/migrations/75_add_passkeys.up.sql
index 92db268c20..e873f89122 100644
--- a/server/migrations/75_add_passkeys.up.sql
+++ b/server/migrations/75_add_passkeys.up.sql
@@ -15,8 +15,6 @@ CREATE TABLE
credential_id TEXT NOT NULL UNIQUE,
--- credential info
-
-- []byte data will be encoded in b64 before being inserted into the DB
-- fields that are are arrays will be comma separated strings
@@ -24,14 +22,10 @@ CREATE TABLE
-- structs will be encoded into JSON before being inserted into DB (they don't need to be queried anyway)
public_key TEXT NOT NULL,
--- binary data
attestation_type TEXT NOT NULL,
authenticator_transports TEXT NOT NULL,
--- array
credential_flags TEXT NOT NULL,
--- struct
authenticator TEXT NOT NULL,
--- struct
created_at bigint NOT NULL DEFAULT now_utc_micro_seconds(),
diff --git a/server/migrations/78_cast.up.sql b/server/migrations/78_cast.up.sql
index 602db3b9ac..df0f8f78db 100644
--- a/server/migrations/78_cast.up.sql
+++ b/server/migrations/78_cast.up.sql
@@ -12,5 +12,4 @@ CREATE TABLE IF NOT EXISTS casting
created_at BIGINT NOT NULL DEFAULT now_utc_micro_seconds(),
last_used_at BIGINT NOT NULL DEFAULT now_utc_micro_seconds()
);
--- create unique constraint on not deleted code
CREATE UNIQUE INDEX IF NOT EXISTS casting_code_unique_idx ON casting (code) WHERE is_deleted = FALSE;
diff --git a/server/migrations/79_queue_index.up.sql b/server/migrations/79_queue_index.up.sql
index 917e4f7a02..5b6b6d514e 100644
--- a/server/migrations/79_queue_index.up.sql
+++ b/server/migrations/79_queue_index.up.sql
@@ -1,3 +1,2 @@
--- create partial index on non-deleted queue items as we always query for non-deleted entries
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_queue_created_at_non_deleted ON queue (queue_name, created_at)
WHERE is_deleted = false;
diff --git a/server/migrations/84_add_cast_column.up.sql b/server/migrations/84_add_cast_column.up.sql
index 828c2e57c2..d01bdea4ce 100644
--- a/server/migrations/84_add_cast_column.up.sql
+++ b/server/migrations/84_add_cast_column.up.sql
@@ -1,4 +1,3 @@
---- Delete all rows from casting table and add a non-nullable column called ip
BEGIN;
DELETE FROM casting;
ALTER TABLE casting ADD COLUMN ip text NOT NULL;
diff --git a/server/migrations/86_add_dc_embedding.down.sql b/server/migrations/86_add_dc_embedding.down.sql
index b705b29b6e..d4f1dae990 100644
--- a/server/migrations/86_add_dc_embedding.down.sql
+++ b/server/migrations/86_add_dc_embedding.down.sql
@@ -1,4 +1,3 @@
--- Add types for the new dcs that are introduced for the derived data
ALTER TABLE embeddings DROP COLUMN IF EXISTS datacenters;
DO
diff --git a/server/migrations/86_add_dc_embedding.up.sql b/server/migrations/86_add_dc_embedding.up.sql
index 9d8e28ba77..fb08f9a693 100644
--- a/server/migrations/86_add_dc_embedding.up.sql
+++ b/server/migrations/86_add_dc_embedding.up.sql
@@ -1,4 +1,3 @@
--- Add types for the new dcs that are introduced for the derived data
ALTER TYPE s3region ADD VALUE 'wasabi-eu-central-2-derived';
DROP TRIGGER IF EXISTS update_embeddings_updated_at ON embeddings;
ALTER TABLE embeddings ADD COLUMN IF NOT EXISTS datacenters s3region[] default '{b2-eu-cen}';
diff --git a/server/migrations/87_passkey_login_token.down.sql b/server/migrations/87_passkey_login_token.down.sql
index 1af9da976c..90d8ae5ef7 100644
--- a/server/migrations/87_passkey_login_token.down.sql
+++ b/server/migrations/87_passkey_login_token.down.sql
@@ -1,5 +1,3 @@
--- Add types for the new dcs that are introduced for the derived data
-
ALTER TABLE passkey_login_sessions
DROP COLUMN IF EXISTS token_fetch_cnt,
DROP COLUMN IF EXISTS verified_at,
diff --git a/server/migrations/89_file_data_table.down.sql b/server/migrations/89_file_data_table.down.sql
index bdf2a8717b..6d0b7f9af3 100644
--- a/server/migrations/89_file_data_table.down.sql
+++ b/server/migrations/89_file_data_table.down.sql
@@ -6,5 +6,4 @@ DROP TABLE IF EXISTS file_data;
DROP TYPE IF EXISTS file_data_type;
--- Delete triggers
DROP TRIGGER IF EXISTS check_no_common_entries ON file_data;
\ No newline at end of file
diff --git a/server/migrations/89_file_data_table.up.sql b/server/migrations/89_file_data_table.up.sql
index 4ea314a997..39e4fb0d8d 100644
--- a/server/migrations/89_file_data_table.up.sql
+++ b/server/migrations/89_file_data_table.up.sql
@@ -2,7 +2,6 @@ ALTER TABLE temp_objects ADD COLUMN IF NOT EXISTS bucket_id s3region;
ALTER TYPE OBJECT_TYPE ADD VALUE 'mldata';
ALTER TYPE s3region ADD VALUE 'b5';
ALTER TYPE s3region ADD VALUE 'b6';
--- Create the file_data table
CREATE TABLE IF NOT EXISTS file_data
(
file_id BIGINT NOT NULL,
@@ -22,7 +21,6 @@ CREATE TABLE IF NOT EXISTS file_data
PRIMARY KEY (file_id, data_type)
);
--- Add index for user_id and data_type for efficient querying for size calculation
CREATE INDEX idx_file_data_user_type_deleted ON file_data (user_id, data_type, is_deleted) INCLUDE (size);
CREATE INDEX idx_file_data_pending_sync_locked_till ON file_data (is_deleted, sync_locked_till) where pending_sync = true;
@@ -33,18 +31,15 @@ DECLARE
all_buckets s3region[];
duplicate_buckets s3region[];
BEGIN
- -- Combine all bucket IDs into a single array
all_buckets := ARRAY [NEW.latest_bucket] || NEW.replicated_buckets || NEW.delete_from_buckets ||
NEW.inflight_rep_buckets;
- -- Find duplicate bucket IDs
SELECT ARRAY_AGG(DISTINCT bucket)
INTO duplicate_buckets
FROM unnest(all_buckets) bucket
GROUP BY bucket
HAVING COUNT(*) > 1;
- -- If duplicates exist, raise an exception with details
IF ARRAY_LENGTH(duplicate_buckets, 1) > 0 THEN
RAISE EXCEPTION 'Duplicate bucket IDs found: %. Latest: %, Replicated: %, To Delete: %, Inflight: %',
duplicate_buckets, NEW.latest_bucket, NEW.replicated_buckets, NEW.delete_from_buckets, NEW.inflight_rep_buckets;
@@ -59,4 +54,3 @@ CREATE TRIGGER check_no_common_entries
ON file_data
FOR EACH ROW
EXECUTE FUNCTION ensure_no_common_entries();
-
diff --git a/server/migrations/93_emergency_contact.up.sql b/server/migrations/93_emergency_contact.up.sql
index 9ad3d97984..43ef55e653 100644
--- a/server/migrations/93_emergency_contact.up.sql
+++ b/server/migrations/93_emergency_contact.up.sql
@@ -53,7 +53,6 @@ CREATE TABLE IF NOT EXISTS emergency_recovery (
ON DELETE CASCADE
);
--- unique constraint on user_id, emergency_contact_id and status where status is WAITING or READY
CREATE UNIQUE INDEX idx_emergency_recovery_limit_active_recovery ON emergency_recovery(user_id, emergency_contact_id, status)
WHERE status IN ('WAITING', 'READY');