Skip to content

Commit

Permalink
fix: backup should not have unique url
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Oct 29, 2021
1 parent dc1ce24 commit 954b109
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/db/postgres/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ BEGIN
inserted_at)
values (inserted_upload_id,
backup_url,
(data ->> 'inserted_at')::timestamptz)
ON CONFLICT ( url ) DO NOTHING;
(data ->> 'inserted_at')::timestamptz);
end loop;

return inserted_upload_id;
Expand Down
9 changes: 4 additions & 5 deletions packages/db/postgres/tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ CREATE TABLE IF NOT EXISTS upload
name TEXT,
inserted_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL,
deleted_at TIMESTAMP WITH TIME ZONE,
-- deleted_at TIMESTAMP WITH TIME ZONE, do we want?
UNIQUE (user_id, source_cid)
deleted_at TIMESTAMP WITH TIME ZONE
-- UNIQUE (user_id, source_cid)
);

CREATE INDEX IF NOT EXISTS upload_updated_at_idx ON upload (updated_at);
Expand All @@ -152,7 +151,7 @@ CREATE TABLE IF NOT EXISTS backup
-- Upload that resulted in this backup.
upload_id BIGINT NOT NULL REFERENCES upload (id) ON DELETE CASCADE,
-- Backup url location.
url TEXT NOT NULL UNIQUE,
url TEXT NOT NULL,
inserted_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL
);

Expand All @@ -172,7 +171,7 @@ CREATE TABLE IF NOT EXISTS pin_sync_request
(
id BIGSERIAL PRIMARY KEY,
-- Identifier for the pin to keep in sync.
pin_id BIGINT NOT NULL UNIQUE REFERENCES pin (id),
pin_id BIGINT NOT NULL REFERENCES pin (id),
inserted_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL
);

Expand Down

0 comments on commit 954b109

Please sign in to comment.