-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0602fc0
commit c0e01dd
Showing
5 changed files
with
23 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
CREATE SCHEMA IF NOT EXISTS public; | ||
CREATE SCHEMA IF NOT EXISTS public; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
CREATE TYPE public.provider AS ENUM ('fcm', 'apns', 'noop'); | ||
|
||
CREATE TABLE IF NOT EXISTS public.clients | ||
( | ||
id varchar(255) primary key default gen_random_uuid(), | ||
CREATE TABLE public.clients ( | ||
id varchar(255) PRIMARY KEY DEFAULT gen_random_uuid(), | ||
|
||
push_type public.provider not null, | ||
device_token text not null, | ||
push_type public.provider NOT NULL, | ||
device_token text NOT NULL, | ||
|
||
created_at timestamptz not null default now() | ||
); | ||
created_at timestamptz NOT NULL DEFAULT now() | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
CREATE TABLE IF NOT EXISTS public.notifications | ||
( | ||
id varchar(255) primary key, | ||
client_id varchar(255) not null, | ||
CREATE TABLE public.notifications ( | ||
id varchar(255) PRIMARY KEY, | ||
client_id varchar(255) NOT NULL, | ||
|
||
last_payload jsonb not null default '{}'::jsonb, | ||
previous_payloads jsonb[] not null default array []::jsonb[], | ||
last_payload jsonb NOT NULL DEFAULT '{}'::jsonb, | ||
previous_payloads jsonb[] NOT NULL DEFAULT ARRAY[]::jsonb[], | ||
|
||
last_received_at timestamptz not null default now(), | ||
created_at timestamptz not null default now(), | ||
last_received_at timestamptz NOT NULL DEFAULT now(), | ||
created_at timestamptz NOT NULL DEFAULT now(), | ||
|
||
CONSTRAINT fk_notifications_client_id FOREIGN KEY (client_id) | ||
REFERENCES public.clients (id) | ||
); | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
alter table public.clients | ||
add tenant_id varchar(255) not null default '0000-0000-0000-0000'; | ||
ALTER TABLE public.clients | ||
ADD tenant_id varchar(255) NOT NULL DEFAULT '0000-0000-0000-0000'; | ||
|
||
alter table public.notifications | ||
add tenant_id varchar(255) not null default '0000-0000-0000-0000'; | ||
ALTER table public.notifications | ||
ADD tenant_id varchar(255) NOT NULL DEFAULT '0000-0000-0000-0000'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
DELETE FROM public.clients | ||
WHERE (device_token, created_at) NOT IN | ||
( | ||
WHERE (device_token, created_at) NOT IN ( | ||
SELECT device_token, MAX(created_at) | ||
FROM public.clients | ||
GROUP BY device_token | ||
); | ||
ALTER TABLE public.clients | ||
ADD CONSTRAINT device_token_unique UNIQUE(device_token); | ||
|
||
ALTER TABLE public.clients | ||
ADD CONSTRAINT device_token_unique UNIQUE (device_token); |