Dev (#1860)
* refactor(chalice): changed logging * feat(DB): rollback scripts * feat(DB): init&delta scripts
This commit is contained in:
parent
16af8ee09f
commit
d6c9f466e5
8 changed files with 61 additions and 51 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
import uuid
|
||||
from os import environ
|
||||
|
||||
|
|
@ -7,6 +8,8 @@ from decouple import config
|
|||
from chalicelib.utils import helper
|
||||
from chalicelib.utils.TimeUTC import TimeUTC
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def __get_mid():
|
||||
return str(uuid.UUID(int=uuid.getnode()))
|
||||
|
|
@ -19,15 +22,16 @@ def get_license():
|
|||
def check():
|
||||
license = get_license()
|
||||
if license is None or len(license) == 0:
|
||||
print("!! license key not found, please provide a LICENSE_KEY env var")
|
||||
logger.warning("!! license key not found, please provide a LICENSE_KEY env var")
|
||||
environ["expiration"] = "-1"
|
||||
environ["numberOfSeats"] = "0"
|
||||
return
|
||||
print(f"validating: {helper.obfuscate(license)}")
|
||||
r = requests.post('https://api.openreplay.com/license/validate', json={"mid": __get_mid(), "license": get_license()})
|
||||
logger.info(f"validating: {helper.obfuscate(license)}")
|
||||
r = requests.post('https://api.openreplay.com/license/validate',
|
||||
json={"mid": __get_mid(), "license": get_license()})
|
||||
if r.status_code != 200 or "errors" in r.json() or not r.json()["data"].get("valid"):
|
||||
print("license validation failed")
|
||||
print(r.text)
|
||||
logger.warning("license validation failed")
|
||||
logger.warning(r.text)
|
||||
environ["expiration"] = "-1"
|
||||
else:
|
||||
environ["expiration"] = str(r.json()["data"].get("expiration"))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
CREATE OR REPLACE FUNCTION openreplay_version AS() -> 'v1.16.0-ee';
|
||||
CREATE OR REPLACE FUNCTION openreplay_version AS() -> 'v1.17.0-ee';
|
||||
CREATE DATABASE IF NOT EXISTS experimental;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS experimental.autocomplete
|
||||
|
|
|
|||
|
|
@ -43,23 +43,23 @@ CREATE TABLE IF NOT EXISTS public.projects_conditions
|
|||
|
||||
CREATE TABLE IF NOT EXISTS public.tags
|
||||
(
|
||||
tag_id serial NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
tag_id serial NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX tags_project_id_idx ON public.tags (project_id);
|
||||
CREATE INDEX IF NOT EXISTS tags_project_id_idx ON public.tags (project_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS events.tags
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
tag_id integer NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
tag_id integer NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS tags_session_id_idx ON events.tags (session_id);
|
||||
CREATE INDEX IF NOT EXISTS tags_timestamp_idx ON events.tags (timestamp);
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ $$
|
|||
button_url text NULL,
|
||||
image_url text NULL,
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
options jsonb NOT NULL DEFAULT'{}'::jsonb,
|
||||
options jsonb NOT NULL DEFAULT '{}'::jsonb,
|
||||
CONSTRAINT notification_tenant_xor_user CHECK ( tenant_id NOTNULL AND user_id ISNULL OR
|
||||
tenant_id ISNULL AND user_id NOTNULL )
|
||||
);
|
||||
|
|
@ -1172,13 +1172,13 @@ $$
|
|||
|
||||
CREATE TABLE public.tags
|
||||
(
|
||||
tag_id serial NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
tag_id serial NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX tags_project_id_idx ON public.tags (project_id);
|
||||
|
||||
|
|
@ -1187,7 +1187,7 @@ $$
|
|||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
tag_id integer NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
tag_id integer NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
CREATE INDEX tags_session_id_idx ON events.tags (session_id);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ $fn_def$, :'next_version')
|
|||
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS public.projects_conditions;
|
||||
DROP TABLE IF EXISTS events.tags;
|
||||
DROP TABLE IF EXISTS public.tags;
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,23 +43,23 @@ CREATE TABLE IF NOT EXISTS public.projects_conditions
|
|||
|
||||
CREATE TABLE IF NOT EXISTS public.tags
|
||||
(
|
||||
tag_id serial NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
tag_id serial NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX tags_project_id_idx ON public.tags (project_id);
|
||||
CREATE INDEX IF NOT EXISTS tags_project_id_idx ON public.tags (project_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS events.tags
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
tag_id integer NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
tag_id integer NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS tags_session_id_idx ON events.tags (session_id);
|
||||
CREATE INDEX IF NOT EXISTS tags_timestamp_idx ON events.tags (timestamp);
|
||||
|
|
|
|||
|
|
@ -1130,16 +1130,16 @@ $$
|
|||
CREATE INDEX swipes_label_gin_idx ON events_ios.swipes USING GIN (label gin_trgm_ops);
|
||||
CREATE INDEX swipes_timestamp_idx ON events_ios.swipes (timestamp);
|
||||
CREATE INDEX swipes_label_session_id_timestamp_idx ON events_ios.swipes (label, session_id, timestamp);
|
||||
|
||||
|
||||
CREATE TABLE public.tags
|
||||
(
|
||||
tag_id serial NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
tag_id serial NOT NULL PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
selector text NOT NULL,
|
||||
ignore_click_rage boolean NOT NULL,
|
||||
ignore_dead_click boolean NOT NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX tags_project_id_idx ON public.tags (project_id);
|
||||
|
||||
|
|
@ -1148,7 +1148,7 @@ $$
|
|||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
tag_id integer NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
tag_id integer NOT NULL REFERENCES public.tags (tag_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
CREATE INDEX tags_session_id_idx ON events.tags (session_id);
|
||||
|
|
@ -1218,7 +1218,7 @@ $$
|
|||
);
|
||||
CREATE INDEX canvas_recordings_session_id_idx ON events.canvas_recordings (session_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.projects_conditions
|
||||
CREATE TABLE public.projects_conditions
|
||||
(
|
||||
condition_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ $fn_def$, :'next_version')
|
|||
--
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS public.projects_conditions;
|
||||
DROP TABLE IF EXISTS events.tags;
|
||||
DROP TABLE IF EXISTS public.tags;
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue