Skip to content

Commit

Permalink
fix: inaccurate used_storage migrations (#1360)
Browse files Browse the repository at this point in the history
  • Loading branch information
flea89 authored May 26, 2022
1 parent 0b1eb09 commit 8f98d27
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/db/postgres/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@ BEGIN
END
$$;

CREATE TYPE used_storage AS (uploaded TEXT, psa_pinned TEXT, total TEXT);
CREATE TYPE stored_bytes AS (uploaded TEXT, psa_pinned TEXT, total TEXT);

CREATE OR REPLACE FUNCTION user_used_storage(query_user_id BIGINT)
RETURNS used_storage
RETURNS stored_bytes
LANGUAGE plpgsql
AS
$$
DECLARE
used_storage used_storage;
used_storage stored_bytes;
uploaded BIGINT;
psa_pinned BIGINT;
total BIGINT;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
ALTER TYPE used_storage ADD ATTRIBUTE total TEXT;

-- Because function return type has changed
DROP FUNCTION user_used_storage(bigint);
DROP FUNCTION IF EXISTS user_used_storage(bigint);

DROP TYPE IF EXISTS stored_bytes;
DROP TYPE IF EXISTS used_storage;

CREATE TYPE stored_bytes AS (uploaded TEXT, psa_pinned TEXT, total TEXT);



-- Get storage used for a specified user: uploaded, pinned and total
CREATE OR REPLACE FUNCTION user_used_storage(query_user_id BIGINT)
RETURNS used_storage
RETURNS stored_bytes
LANGUAGE plpgsql
AS
$$
DECLARE
used_storage used_storage;
used_storage stored_bytes;
uploaded BIGINT;
psa_pinned BIGINT;
total BIGINT;
Expand Down

0 comments on commit 8f98d27

Please sign in to comment.