Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inaccurate used_stotrage migrations #1360

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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