Api v1.15.0 (#1483)
* feat(chalice): upgraded dependencies * feat(chalice): changed path analysis schema * feat(DB): click coordinate support * feat(chalice): changed path analysis issues schema feat(chalice): upgraded dependencies * fix(chalice): fixed pydantic issue * refactor(chalice): refresh token validator * feat(chalice): role restrictions * feat(chalice): EE path analysis changes * refactor(DB): changed creation queries refactor(DB): changed delte queries feat(DB): support new path analysis payload * feat(chalice): save path analysis card * feat(chalice): restrict access * feat(chalice): restrict access * feat(chalice): EE save new path analysis card
This commit is contained in:
parent
33f5d078dd
commit
0f2945fd3f
36 changed files with 664 additions and 618 deletions
|
|
@ -332,6 +332,14 @@ def get_issues(project_id: int, user_id: int, data: schemas.CardSchema):
|
|||
return supported.get(data.metric_type, not_supported)(project_id=project_id, data=data, user_id=user_id)
|
||||
|
||||
|
||||
def __get_path_analysis_card_info(data: schemas.CardPathAnalysis):
|
||||
r = {"start_point": [s.model_dump() for s in data.start_point],
|
||||
"start_type": data.start_type,
|
||||
"exclude": [e.model_dump() for e in data.exclude]}
|
||||
print(r)
|
||||
return r
|
||||
|
||||
|
||||
def create_card(project_id, user_id, data: schemas.CardSchema, dashboard=False):
|
||||
with pg_client.PostgresClient() as cur:
|
||||
session_data = None
|
||||
|
|
@ -349,12 +357,18 @@ def create_card(project_id, user_id, data: schemas.CardSchema, dashboard=False):
|
|||
series_len = len(data.series)
|
||||
params = {"user_id": user_id, "project_id": project_id, **data.model_dump(), **_data}
|
||||
params["default_config"] = json.dumps(data.default_config.model_dump())
|
||||
params["card_info"] = None
|
||||
if data.metric_type == schemas.MetricType.pathAnalysis:
|
||||
params["card_info"] = json.dumps(__get_path_analysis_card_info(data=data))
|
||||
|
||||
query = """INSERT INTO metrics (project_id, user_id, name, is_public,
|
||||
view_type, metric_type, metric_of, metric_value,
|
||||
metric_format, default_config, thumbnail, data)
|
||||
metric_format, default_config, thumbnail, data,
|
||||
card_info)
|
||||
VALUES (%(project_id)s, %(user_id)s, %(name)s, %(is_public)s,
|
||||
%(view_type)s, %(metric_type)s, %(metric_of)s, %(metric_value)s,
|
||||
%(metric_format)s, %(default_config)s, %(thumbnail)s, %(session_data)s)
|
||||
%(metric_format)s, %(default_config)s, %(thumbnail)s, %(session_data)s,
|
||||
%(card_info)s)
|
||||
RETURNING metric_id"""
|
||||
if len(data.series) > 0:
|
||||
query = f"""WITH m AS ({query})
|
||||
|
|
@ -535,12 +549,20 @@ def delete_card(project_id, metric_id, user_id):
|
|||
return {"state": "success"}
|
||||
|
||||
|
||||
def __get_path_analysis_attributes(row):
|
||||
card_info = row.pop("cardInfo")
|
||||
row["exclude"] = card_info.get("exclude", [])
|
||||
row["startPoint"] = card_info.get("startPoint", [])
|
||||
row["startType"] = card_info.get("startType", "start")
|
||||
return row
|
||||
|
||||
|
||||
def get_card(metric_id, project_id, user_id, flatten: bool = True, include_data: bool = False):
|
||||
with pg_client.PostgresClient() as cur:
|
||||
query = cur.mogrify(
|
||||
f"""SELECT metric_id, project_id, user_id, name, is_public, created_at, deleted_at, edited_at, metric_type,
|
||||
view_type, metric_of, metric_value, metric_format, is_pinned, default_config,
|
||||
default_config AS config,series, dashboards, owner_email
|
||||
default_config AS config,series, dashboards, owner_email, card_info
|
||||
{',data' if include_data else ''}
|
||||
FROM metrics
|
||||
LEFT JOIN LATERAL (SELECT COALESCE(jsonb_agg(metric_series.* ORDER BY index),'[]'::jsonb) AS series
|
||||
|
|
@ -577,7 +599,10 @@ def get_card(metric_id, project_id, user_id, flatten: bool = True, include_data:
|
|||
if flatten:
|
||||
for s in row["series"]:
|
||||
s["filter"] = helper.old_search_payload_to_flat(s["filter"])
|
||||
return helper.dict_to_camel_case(row)
|
||||
row = helper.dict_to_camel_case(row)
|
||||
if row["metricType"] == schemas.MetricType.pathAnalysis:
|
||||
row = __get_path_analysis_attributes(row=row)
|
||||
return row
|
||||
|
||||
|
||||
def get_series_for_alert(project_id, user_id):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ change_password_link=/reset-password?invitation=%s&&pass=%s
|
|||
invitation_link=/api/users/invitation?token=%s
|
||||
js_cache_bucket=sessions-assets
|
||||
jwt_algorithm=HS512
|
||||
JWT_EXPIRATION=1800
|
||||
JWT_EXPIRATION=86400
|
||||
JWT_REFRESH_EXPIRATION=604800
|
||||
JWT_ISSUER=openreplay-oss
|
||||
jwt_secret="SET A RANDOM STRING HERE"
|
||||
|
|
|
|||
|
|
@ -863,12 +863,6 @@ class ProductAnalyticsSelectedEventType(str, Enum):
|
|||
custom_event = EventType.custom.value
|
||||
|
||||
|
||||
class ProductAnalyticsFilterType(str, Enum):
|
||||
start_point = 'startPoint'
|
||||
end_point = 'endPoint'
|
||||
exclude = 'exclude'
|
||||
|
||||
|
||||
class PathAnalysisSubFilterSchema(BaseModel):
|
||||
is_event: Literal[True] = True
|
||||
value: List[str] = Field(...)
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
|||
from starlette import status
|
||||
from starlette.exceptions import HTTPException
|
||||
|
||||
from chalicelib.core import authorizers, users
|
||||
import schemas
|
||||
from chalicelib.core import authorizers, users
|
||||
|
||||
|
||||
def _get_current_auth_context(request: Request, jwt_payload: dict) -> schemas.CurrentContext:
|
||||
|
|
@ -21,6 +21,7 @@ def _get_current_auth_context(request: Request, jwt_payload: dict) -> schemas.Cu
|
|||
request.state.currentContext = schemas.CurrentContext(tenantId=jwt_payload.get("tenantId", -1),
|
||||
userId=jwt_payload.get("userId", -1),
|
||||
email=user["email"],
|
||||
role=user["role"],
|
||||
permissions=user["permissions"],
|
||||
serviceAccount=user["serviceAccount"])
|
||||
return request.state.currentContext
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ PIE_CHART_GROUP = 5
|
|||
# TODO: refactor this to split
|
||||
# timeseries /
|
||||
# table of errors / table of issues / table of browsers / table of devices / table of countries / table of URLs
|
||||
# remove "table of" calls from this function
|
||||
def __try_live(project_id, data: schemas.CardSchema):
|
||||
results = []
|
||||
for i, s in enumerate(data.series):
|
||||
|
|
@ -57,8 +58,13 @@ def __try_live(project_id, data: schemas.CardSchema):
|
|||
return results
|
||||
|
||||
|
||||
def __is_funnel_chart(data: schemas.CardSchema):
|
||||
return data.metric_type == schemas.MetricType.funnel
|
||||
def __get_table_of_series(project_id, data: schemas.CardSchema):
|
||||
results = []
|
||||
for i, s in enumerate(data.series):
|
||||
results.append(sessions.search2_table(data=s.filter, project_id=project_id, density=data.density,
|
||||
metric_of=data.metric_of, metric_value=data.metric_value))
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def __get_funnel_chart(project_id: int, data: schemas.CardFunnel, user_id: int = None):
|
||||
|
|
@ -70,11 +76,6 @@ def __get_funnel_chart(project_id: int, data: schemas.CardFunnel, user_id: int =
|
|||
return funnels.get_top_insights_on_the_fly_widget(project_id=project_id, data=data.series[0].filter)
|
||||
|
||||
|
||||
def __is_errors_list(data: schemas.CardSchema):
|
||||
return data.metric_type == schemas.MetricType.table \
|
||||
and data.metric_of == schemas.MetricOfTable.errors
|
||||
|
||||
|
||||
def __get_errors_list(project_id, user_id, data: schemas.CardSchema):
|
||||
if len(data.series) == 0:
|
||||
return {
|
||||
|
|
@ -84,11 +85,6 @@ def __get_errors_list(project_id, user_id, data: schemas.CardSchema):
|
|||
return errors.search(data.series[0].filter, project_id=project_id, user_id=user_id)
|
||||
|
||||
|
||||
def __is_sessions_list(data: schemas.CardSchema):
|
||||
return data.metric_type == schemas.MetricType.table \
|
||||
and data.metric_of == schemas.MetricOfTable.sessions
|
||||
|
||||
|
||||
def __get_sessions_list(project_id, user_id, data: schemas.CardSchema):
|
||||
if len(data.series) == 0:
|
||||
print("empty series")
|
||||
|
|
@ -99,10 +95,6 @@ def __get_sessions_list(project_id, user_id, data: schemas.CardSchema):
|
|||
return sessions.search_sessions(data=data.series[0].filter, project_id=project_id, user_id=user_id)
|
||||
|
||||
|
||||
def __is_predefined(data: schemas.CardSchema):
|
||||
return data.is_template
|
||||
|
||||
|
||||
def __is_click_map(data: schemas.CardSchema):
|
||||
return data.metric_type == schemas.MetricType.click_map
|
||||
|
||||
|
|
@ -137,12 +129,7 @@ def __get_path_analysis_chart(project_id: int, user_id: int, data: schemas.CardP
|
|||
elif not isinstance(data.series[0].filter, schemas.PathAnalysisSchema):
|
||||
data.series[0].filter = schemas.PathAnalysisSchema()
|
||||
|
||||
return product_analytics.path_analysis(project_id=project_id, data=data.series[0].filter, density=data.density,
|
||||
selected_event_type=data.metric_value, hide_minor_paths=data.hide_excess)
|
||||
|
||||
|
||||
def __is_path_analysis(data: schemas.CardSchema):
|
||||
return data.metric_type == schemas.MetricType.pathAnalysis
|
||||
return product_analytics.path_analysis(project_id=project_id, data=data)
|
||||
|
||||
|
||||
def __get_timeseries_chart(project_id: int, data: schemas.CardTimeSeries, user_id: int = None):
|
||||
|
|
@ -157,13 +144,12 @@ def __get_timeseries_chart(project_id: int, data: schemas.CardTimeSeries, user_i
|
|||
return results
|
||||
|
||||
|
||||
def empty(**args):
|
||||
def not_supported(**args):
|
||||
raise Exception("not supported")
|
||||
|
||||
|
||||
def __get_table_of_user_ids(project_id: int, data: schemas.CardTable, user_id: int = None):
|
||||
series_charts = __try_live(project_id=project_id, data=data)
|
||||
return series_charts
|
||||
return __get_table_of_series(project_id=project_id, data=data)
|
||||
|
||||
|
||||
def __get_table_of_sessions(project_id: int, data: schemas.CardTable, user_id):
|
||||
|
|
@ -175,23 +161,23 @@ def __get_table_of_errors(project_id: int, data: schemas.CardTable, user_id: int
|
|||
|
||||
|
||||
def __get_table_of_issues(project_id: int, data: schemas.CardTable, user_id: int = None):
|
||||
return __try_live(project_id=project_id, data=data)
|
||||
return __get_table_of_series(project_id=project_id, data=data)
|
||||
|
||||
|
||||
def __get_table_of_browsers(project_id: int, data: schemas.CardTable, user_id: int = None):
|
||||
return __try_live(project_id=project_id, data=data)
|
||||
return __get_table_of_series(project_id=project_id, data=data)
|
||||
|
||||
|
||||
def __get_table_of_devises(project_id: int, data: schemas.CardTable, user_id: int = None):
|
||||
return __try_live(project_id=project_id, data=data)
|
||||
return __get_table_of_series(project_id=project_id, data=data)
|
||||
|
||||
|
||||
def __get_table_of_countries(project_id: int, data: schemas.CardTable, user_id: int = None):
|
||||
return __try_live(project_id=project_id, data=data)
|
||||
return __get_table_of_series(project_id=project_id, data=data)
|
||||
|
||||
|
||||
def __get_table_of_urls(project_id: int, data: schemas.CardTable, user_id: int = None):
|
||||
return __try_live(project_id=project_id, data=data)
|
||||
return __get_table_of_series(project_id=project_id, data=data)
|
||||
|
||||
|
||||
def __get_table_chart(project_id: int, data: schemas.CardTable, user_id: int):
|
||||
|
|
@ -205,7 +191,7 @@ def __get_table_chart(project_id: int, data: schemas.CardTable, user_id: int):
|
|||
schemas.MetricOfTable.user_country: __get_table_of_countries,
|
||||
schemas.MetricOfTable.visited_url: __get_table_of_urls,
|
||||
}
|
||||
return supported.get(data.metric_of, empty)(project_id=project_id, data=data, user_id=user_id)
|
||||
return supported.get(data.metric_of, not_supported)(project_id=project_id, data=data, user_id=user_id)
|
||||
|
||||
|
||||
def get_chart(project_id: int, data: schemas.CardSchema, user_id: int):
|
||||
|
|
@ -220,48 +206,7 @@ def get_chart(project_id: int, data: schemas.CardSchema, user_id: int):
|
|||
schemas.MetricType.insights: __get_insights_chart,
|
||||
schemas.MetricType.pathAnalysis: __get_path_analysis_chart
|
||||
}
|
||||
return supported.get(data.metric_type, empty)(project_id=project_id, data=data, user_id=user_id)
|
||||
|
||||
|
||||
def merged_live(project_id, data: schemas.CardSchema, user_id=None):
|
||||
return get_chart(project_id=project_id, data=data, user_id=user_id)
|
||||
print("---1")
|
||||
if data.is_template:
|
||||
print("---2")
|
||||
return get_predefined_metric(key=data.metric_of, project_id=project_id, data=data.model_dump())
|
||||
elif __is_funnel_chart(data):
|
||||
print("---3")
|
||||
return __get_funnel_chart(project_id=project_id, data=data)
|
||||
elif __is_errors_list(data):
|
||||
print("---4")
|
||||
return __get_errors_list(project_id=project_id, user_id=user_id, data=data)
|
||||
elif __is_sessions_list(data):
|
||||
print("---5")
|
||||
return __get_sessions_list(project_id=project_id, user_id=user_id, data=data)
|
||||
elif __is_click_map(data):
|
||||
print("---6")
|
||||
return __get_click_map_chart(project_id=project_id, user_id=user_id, data=data)
|
||||
# EE only
|
||||
elif __is_insights(data):
|
||||
return __get_insights_chart(project_id=project_id, user_id=user_id, data=data)
|
||||
elif __is_path_analysis(data):
|
||||
print("---7")
|
||||
return __get_path_analysis_chart(project_id=project_id, data=data)
|
||||
elif len(data.series) == 0:
|
||||
print("---8")
|
||||
return []
|
||||
series_charts = __try_live(project_id=project_id, data=data)
|
||||
print("---9")
|
||||
if data.view_type == schemas.MetricTimeseriesViewType.progress or data.metric_type == schemas.MetricType.table:
|
||||
print("---10")
|
||||
return series_charts
|
||||
results = [{}] * len(series_charts[0])
|
||||
print("---11")
|
||||
for i in range(len(results)):
|
||||
for j, series_chart in enumerate(series_charts):
|
||||
results[i] = {**results[i], "timestamp": series_chart[i]["timestamp"],
|
||||
data.series[j].name if data.series[j].name else j + 1: series_chart[i]["count"]}
|
||||
return results
|
||||
return supported.get(data.metric_type, not_supported)(project_id=project_id, data=data, user_id=user_id)
|
||||
|
||||
|
||||
def __merge_metric_with_data(metric: schemas.CardSchema,
|
||||
|
|
@ -289,10 +234,10 @@ def make_chart(project_id, user_id, data: schemas.CardSessionsSchema, metric: sc
|
|||
return None
|
||||
metric: schemas.CardSchema = __merge_metric_with_data(metric=metric, data=data)
|
||||
|
||||
return merged_live(project_id=project_id, data=metric, user_id=user_id)
|
||||
return get_chart(project_id=project_id, data=metric, user_id=user_id)
|
||||
|
||||
|
||||
def get_sessions(project_id, user_id, metric_id, data: schemas.CardSessionsSchema):
|
||||
def get_sessions_by_card_id(project_id, user_id, metric_id, data: schemas.CardSessionsSchema):
|
||||
# raw_metric = get_card(metric_id=metric_id, project_id=project_id, user_id=user_id, flatten=False, include_data=True)
|
||||
raw_metric: dict = get_card(metric_id=metric_id, project_id=project_id, user_id=user_id, flatten=False)
|
||||
if raw_metric is None:
|
||||
|
|
@ -346,7 +291,7 @@ def get_errors_list(project_id, user_id, metric_id, data: schemas.CardSessionsSc
|
|||
**errors.search(data=s.filter, project_id=project_id, user_id=user_id)}
|
||||
|
||||
|
||||
def try_sessions(project_id, user_id, data: schemas.CardSessionsSchema):
|
||||
def get_sessions(project_id, user_id, data: schemas.CardSessionsSchema):
|
||||
results = []
|
||||
if len(data.series) == 0:
|
||||
return results
|
||||
|
|
@ -361,6 +306,66 @@ def try_sessions(project_id, user_id, data: schemas.CardSessionsSchema):
|
|||
return results
|
||||
|
||||
|
||||
def __get_funnel_issues(project_id: int, user_id: int, data: schemas.CardFunnel):
|
||||
if len(data.series) == 0:
|
||||
return {"data": []}
|
||||
data.series[0].filter.startTimestamp = data.startTimestamp
|
||||
data.series[0].filter.endTimestamp = data.endTimestamp
|
||||
data = funnels.get_issues_on_the_fly_widget(project_id=project_id, data=data.series[0].filter)
|
||||
return {"data": data}
|
||||
|
||||
|
||||
def __get_path_analysis_issues(project_id: int, user_id: int, data: schemas.CardPathAnalysis):
|
||||
if len(data.series) == 0:
|
||||
return {"data": []}
|
||||
card_table = schemas.CardTable(
|
||||
startTimestamp=data.startTimestamp,
|
||||
endTimestamp=data.endTimestamp,
|
||||
metricType=schemas.MetricType.table,
|
||||
metricOf=schemas.MetricOfTable.issues,
|
||||
viewType=schemas.MetricTableViewType.table,
|
||||
series=data.model_dump()["series"])
|
||||
for s in data.start_point:
|
||||
if data.start_type == "end":
|
||||
card_table.series[0].filter.filters.append(schemas.SessionSearchEventSchema2(type=s.type,
|
||||
operator=s.operator,
|
||||
value=s.value))
|
||||
else:
|
||||
card_table.series[0].filter.filters.insert(0, schemas.SessionSearchEventSchema2(type=s.type,
|
||||
operator=s.operator,
|
||||
value=s.value))
|
||||
for s in data.exclude:
|
||||
card_table.series[0].filter.filters.append(schemas.SessionSearchEventSchema2(type=s.type,
|
||||
operator=schemas.SearchEventOperator._not_on,
|
||||
value=s.value))
|
||||
|
||||
return __get_table_of_issues(project_id=project_id, user_id=user_id, data=card_table)
|
||||
|
||||
|
||||
def get_issues(project_id: int, user_id: int, data: schemas.CardSchema):
|
||||
if data.is_template:
|
||||
return not_supported()
|
||||
if data.metric_of == schemas.MetricOfTable.issues:
|
||||
return __get_table_of_issues(project_id=project_id, user_id=user_id, data=data)
|
||||
supported = {
|
||||
schemas.MetricType.timeseries: not_supported,
|
||||
schemas.MetricType.table: not_supported,
|
||||
schemas.MetricType.click_map: not_supported,
|
||||
schemas.MetricType.funnel: __get_funnel_issues,
|
||||
schemas.MetricType.insights: not_supported,
|
||||
schemas.MetricType.pathAnalysis: __get_path_analysis_issues,
|
||||
}
|
||||
return supported.get(data.metric_type, not_supported)(project_id=project_id, data=data, user_id=user_id)
|
||||
|
||||
|
||||
def __get_path_analysis_card_info(data: schemas.CardPathAnalysis):
|
||||
r = {"start_point": [s.model_dump() for s in data.start_point],
|
||||
"start_type": data.start_type,
|
||||
"exclude": [e.model_dump() for e in data.exclude]}
|
||||
print(r)
|
||||
return r
|
||||
|
||||
|
||||
def create_card(project_id, user_id, data: schemas.CardSchema, dashboard=False):
|
||||
with pg_client.PostgresClient() as cur:
|
||||
session_data = None
|
||||
|
|
@ -390,12 +395,18 @@ def create_card(project_id, user_id, data: schemas.CardSchema, dashboard=False):
|
|||
series_len = len(data.series)
|
||||
params = {"user_id": user_id, "project_id": project_id, **data.model_dump(), **_data}
|
||||
params["default_config"] = json.dumps(data.default_config.model_dump())
|
||||
params["card_info"] = None
|
||||
if data.metric_type == schemas.MetricType.pathAnalysis:
|
||||
params["card_info"] = json.dumps(__get_path_analysis_card_info(data=data))
|
||||
|
||||
query = """INSERT INTO metrics (project_id, user_id, name, is_public,
|
||||
view_type, metric_type, metric_of, metric_value,
|
||||
metric_format, default_config, thumbnail, data)
|
||||
metric_format, default_config, thumbnail, data,
|
||||
card_info)
|
||||
VALUES (%(project_id)s, %(user_id)s, %(name)s, %(is_public)s,
|
||||
%(view_type)s, %(metric_type)s, %(metric_of)s, %(metric_value)s,
|
||||
%(metric_format)s, %(default_config)s, %(thumbnail)s, %(session_data)s)
|
||||
%(metric_format)s, %(default_config)s, %(thumbnail)s, %(session_data)s,
|
||||
%(card_info)s)
|
||||
RETURNING metric_id"""
|
||||
if len(data.series) > 0:
|
||||
query = f"""WITH m AS ({query})
|
||||
|
|
@ -590,12 +601,20 @@ def delete_card(project_id, metric_id, user_id):
|
|||
return {"state": "success"}
|
||||
|
||||
|
||||
def __get_path_analysis_attributes(row):
|
||||
card_info = row.pop("cardInfo")
|
||||
row["exclude"] = card_info.get("exclude", [])
|
||||
row["startPoint"] = card_info.get("startPoint", [])
|
||||
row["startType"] = card_info.get("startType", "start")
|
||||
return row
|
||||
|
||||
|
||||
def get_card(metric_id, project_id, user_id, flatten: bool = True, include_data: bool = False):
|
||||
with pg_client.PostgresClient() as cur:
|
||||
query = cur.mogrify(
|
||||
f"""SELECT metric_id, project_id, user_id, name, is_public, created_at, deleted_at, edited_at, metric_type,
|
||||
view_type, metric_of, metric_value, metric_format, is_pinned, default_config,
|
||||
default_config AS config,series, dashboards, owner_email
|
||||
default_config AS config,series, dashboards, owner_email, card_info
|
||||
{',data' if include_data else ''}
|
||||
FROM metrics
|
||||
LEFT JOIN LATERAL (SELECT COALESCE(jsonb_agg(metric_series.* ORDER BY index),'[]'::jsonb) AS series
|
||||
|
|
@ -632,7 +651,10 @@ def get_card(metric_id, project_id, user_id, flatten: bool = True, include_data:
|
|||
if flatten:
|
||||
for s in row["series"]:
|
||||
s["filter"] = helper.old_search_payload_to_flat(s["filter"])
|
||||
return helper.dict_to_camel_case(row)
|
||||
row = helper.dict_to_camel_case(row)
|
||||
if row["metricType"] == schemas.MetricType.pathAnalysis:
|
||||
row = __get_path_analysis_attributes(row=row)
|
||||
return row
|
||||
|
||||
|
||||
def get_series_for_alert(project_id, user_id):
|
||||
|
|
|
|||
|
|
@ -64,17 +64,15 @@ JOURNEY_TYPES = {
|
|||
}
|
||||
|
||||
|
||||
def path_analysis(project_id: int, data: schemas.PathAnalysisSchema,
|
||||
selected_event_type: List[schemas.ProductAnalyticsSelectedEventType],
|
||||
density: int = 4, hide_minor_paths: bool = False):
|
||||
def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
|
||||
sub_events = []
|
||||
start_points_conditions = []
|
||||
if len(selected_event_type) == 0:
|
||||
selected_event_type.append(schemas.ProductAnalyticsSelectedEventType.location)
|
||||
if len(data.metric_value) == 0:
|
||||
data.metric_value.append(schemas.ProductAnalyticsSelectedEventType.location)
|
||||
sub_events.append({"column": JOURNEY_TYPES[schemas.ProductAnalyticsSelectedEventType.location]["column"],
|
||||
"eventType": schemas.ProductAnalyticsSelectedEventType.location.value})
|
||||
else:
|
||||
for v in selected_event_type:
|
||||
for v in data.metric_value:
|
||||
if JOURNEY_TYPES.get(v):
|
||||
sub_events.append({"column": JOURNEY_TYPES[v]["column"],
|
||||
"eventType": JOURNEY_TYPES[v]["eventType"]})
|
||||
|
|
@ -85,11 +83,29 @@ def path_analysis(project_id: int, data: schemas.PathAnalysisSchema,
|
|||
','.join([f"event_type='{s['eventType']}',{s['column']}" for s in sub_events[:-1]]),
|
||||
sub_events[-1]["column"])
|
||||
extra_values = {}
|
||||
sessions_conditions = []
|
||||
reverse = False
|
||||
meta_keys = None
|
||||
reverse = data.start_type == "end"
|
||||
for i, sf in enumerate(data.start_point):
|
||||
f_k = f"start_point_{i}"
|
||||
op = sh.get_sql_operator(sf.operator)
|
||||
is_not = sh.is_negation_operator(sf.operator)
|
||||
extra_values = {**extra_values, **sh.multi_values(sf.value, value_key=f_k)}
|
||||
start_points_conditions.append(f"(event_type='{JOURNEY_TYPES[sf.type]['eventType']}' AND " +
|
||||
sh.multi_conditions(f'e_value {op} %({f_k})s', sf.value, is_not=is_not,
|
||||
value_key=f_k)
|
||||
+ ")")
|
||||
|
||||
exclusions = {}
|
||||
for i, f in enumerate(data.filters):
|
||||
for i, sf in enumerate(data.exclude):
|
||||
if sf.type in data.metric_value:
|
||||
f_k = f"exclude_{i}"
|
||||
extra_values = {**extra_values, **sh.multi_values(sf.value, value_key=f_k)}
|
||||
exclusions[sf.type] = [
|
||||
sh.multi_conditions(f'{JOURNEY_TYPES[sf.type]["column"]} != %({f_k})s', sf.value, is_not=True,
|
||||
value_key=f_k)]
|
||||
|
||||
sessions_conditions = []
|
||||
meta_keys = None
|
||||
for i, f in enumerate(data.series[0].filter.filters):
|
||||
op = sh.get_sql_operator(f.operator)
|
||||
is_any = sh.isAny_opreator(f.operator)
|
||||
is_not = sh.is_negation_operator(f.operator)
|
||||
|
|
@ -97,23 +113,6 @@ def path_analysis(project_id: int, data: schemas.PathAnalysisSchema,
|
|||
f_k = f"f_value_{i}"
|
||||
extra_values = {**extra_values, **sh.multi_values(f.value, value_key=f_k)}
|
||||
|
||||
if f.type in [schemas.ProductAnalyticsFilterType.start_point, schemas.ProductAnalyticsFilterType.end_point]:
|
||||
for sf in f.filters:
|
||||
extra_values = {**extra_values, **sh.multi_values(sf.value, value_key=f_k)}
|
||||
start_points_conditions.append(f"(event_type='{JOURNEY_TYPES[sf.type]['eventType']}' AND " +
|
||||
sh.multi_conditions(f'e_value {op} %({f_k})s', sf.value, is_not=is_not,
|
||||
value_key=f_k)
|
||||
+ ")")
|
||||
|
||||
reverse = f.type == schemas.ProductAnalyticsFilterType.end_point
|
||||
elif f.type == schemas.ProductAnalyticsFilterType.exclude:
|
||||
for sf in f.filters:
|
||||
if sf.type in selected_event_type:
|
||||
extra_values = {**extra_values, **sh.multi_values(sf.value, value_key=f_k)}
|
||||
exclusions[sf.type] = [
|
||||
sh.multi_conditions(f'{JOURNEY_TYPES[sf.type]["column"]} != %({f_k})s', sf.value, is_not=True,
|
||||
value_key=f_k)]
|
||||
|
||||
# ---- meta-filters
|
||||
if f.type == schemas.FilterType.user_browser:
|
||||
if is_any:
|
||||
|
|
@ -270,7 +269,7 @@ def path_analysis(project_id: int, data: schemas.PathAnalysisSchema,
|
|||
# ch_sub_query = __get_basic_constraints(table_name="experimental.events", data=data.model_dump())
|
||||
ch_sub_query = __get_basic_constraints(table_name="events")
|
||||
selected_event_type_sub_query = []
|
||||
for s in selected_event_type:
|
||||
for s in data.metric_value:
|
||||
selected_event_type_sub_query.append(f"events.event_type = '{JOURNEY_TYPES[s]['eventType']}'")
|
||||
if s in exclusions:
|
||||
selected_event_type_sub_query[-1] += " AND (" + " AND ".join(exclusions[s]) + ")"
|
||||
|
|
@ -369,6 +368,7 @@ ORDER BY event_number_in_session, e_value, next_value;"""
|
|||
print("----------------------")
|
||||
print(print(ch.format(ch_query, params)))
|
||||
print("----------------------")
|
||||
|
||||
return __transform_journey2(rows=rows, reverse_path=reverse)
|
||||
|
||||
#
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ idp_x509cert=
|
|||
invitation_link=/api/users/invitation?token=%s
|
||||
js_cache_bucket=sessions-assets
|
||||
jwt_algorithm=HS512
|
||||
JWT_EXPIRATION=1800
|
||||
JWT_EXPIRATION=86400
|
||||
JWT_REFRESH_EXPIRATION=604800
|
||||
JWT_ISSUER=openreplay-oss
|
||||
jwt_secret="SET A RANDOM STRING HERE"
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ def OR_scope(*scopes):
|
|||
return Security(__check, scopes=list(scopes))
|
||||
|
||||
|
||||
def __check_role(required_roles: SecurityScopes, context: schemas_ee.CurrentContext = Depends(OR_context)):
|
||||
def __check_role(required_roles: SecurityScopes, context: schemas.CurrentContext = Depends(OR_context)):
|
||||
if len(required_roles.scopes) > 0:
|
||||
if context.role not in required_roles.scopes:
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ def edit_slack_integration(integrationId: int, data: schemas.EditCollaborationSc
|
|||
|
||||
|
||||
@app.post('/client/members', tags=["client"], dependencies=[OR_role("owner", "admin")])
|
||||
def add_member(background_tasks: BackgroundTasks, data: schemas_ee.CreateMemberSchema = Body(...),
|
||||
def add_member(background_tasks: BackgroundTasks, data: schemas.CreateMemberSchema = Body(...),
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
return users.create_member(tenant_id=context.tenant_id, user_id=context.user_id, data=data,
|
||||
background_tasks=background_tasks)
|
||||
|
|
@ -195,7 +195,7 @@ def change_password_by_invitation(data: schemas.EditPasswordByInvitationSchema =
|
|||
|
||||
|
||||
@app.put('/client/members/{memberId}', tags=["client"], dependencies=[OR_role("owner", "admin")])
|
||||
def edit_member(memberId: int, data: schemas_ee.EditMemberSchema,
|
||||
def edit_member(memberId: int, data: schemas.EditMemberSchema,
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
return users.edit_member(tenant_id=context.tenant_id, editor_id=context.user_id, changes=data,
|
||||
user_id_to_update=memberId)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from chalicelib.utils import assist_helper
|
|||
|
||||
unlock.check()
|
||||
|
||||
from or_dependencies import OR_context
|
||||
from or_dependencies import OR_context, OR_role
|
||||
from routers.base import get_routers
|
||||
import schemas
|
||||
from fastapi import Depends, Body
|
||||
|
|
@ -13,15 +13,15 @@ from fastapi import Depends, Body
|
|||
public_app, app, app_apikey = get_routers()
|
||||
|
||||
|
||||
@app.get('/client/roles', tags=["client", "roles"])
|
||||
@app.get('/client/roles', tags=["client", "roles"], dependencies=[OR_role("owner", "admin")])
|
||||
def get_roles(context: schemas.CurrentContext = Depends(OR_context)):
|
||||
return {
|
||||
'data': roles.get_roles(tenant_id=context.tenant_id)
|
||||
}
|
||||
|
||||
|
||||
@app.post('/client/roles', tags=["client", "roles"])
|
||||
@app.put('/client/roles', tags=["client", "roles"])
|
||||
@app.post('/client/roles', tags=["client", "roles"], dependencies=[OR_role("owner", "admin")])
|
||||
@app.put('/client/roles', tags=["client", "roles"], dependencies=[OR_role("owner", "admin")])
|
||||
def add_role(data: schemas.RolePayloadSchema = Body(...),
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
data = roles.create(tenant_id=context.tenant_id, user_id=context.user_id, data=data)
|
||||
|
|
@ -33,8 +33,8 @@ def add_role(data: schemas.RolePayloadSchema = Body(...),
|
|||
}
|
||||
|
||||
|
||||
@app.post('/client/roles/{roleId}', tags=["client", "roles"])
|
||||
@app.put('/client/roles/{roleId}', tags=["client", "roles"])
|
||||
@app.post('/client/roles/{roleId}', tags=["client", "roles"], dependencies=[OR_role("owner", "admin")])
|
||||
@app.put('/client/roles/{roleId}', tags=["client", "roles"], dependencies=[OR_role("owner", "admin")])
|
||||
def edit_role(roleId: int, data: schemas.RolePayloadSchema = Body(...),
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
data = roles.update(tenant_id=context.tenant_id, user_id=context.user_id, role_id=roleId, data=data)
|
||||
|
|
@ -46,7 +46,7 @@ def edit_role(roleId: int, data: schemas.RolePayloadSchema = Body(...),
|
|||
}
|
||||
|
||||
|
||||
@app.delete('/client/roles/{roleId}', tags=["client", "roles"])
|
||||
@app.delete('/client/roles/{roleId}', tags=["client", "roles"], dependencies=[OR_role("owner", "admin")])
|
||||
def delete_role(roleId: int, _=Body(None), context: schemas.CurrentContext = Depends(OR_context)):
|
||||
data = roles.delete(tenant_id=context.tenant_id, user_id=context.user_id, role_id=roleId)
|
||||
if "errors" in data:
|
||||
|
|
@ -62,7 +62,7 @@ def get_assist_credentials():
|
|||
return {"data": assist_helper.get_full_config()}
|
||||
|
||||
|
||||
@app.post('/trails', tags=["traces", "trails"])
|
||||
@app.post('/trails', tags=["traces", "trails"], dependencies=[OR_role("owner", "admin")])
|
||||
def get_trails(data: schemas.TrailSearchPayloadSchema = Body(...),
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
return {
|
||||
|
|
@ -70,7 +70,7 @@ def get_trails(data: schemas.TrailSearchPayloadSchema = Body(...),
|
|||
}
|
||||
|
||||
|
||||
@app.post('/trails/actions', tags=["traces", "trails"])
|
||||
@app.post('/trails/actions', tags=["traces", "trails"], dependencies=[OR_role("owner", "admin")])
|
||||
def get_available_trail_actions(context: schemas.CurrentContext = Depends(OR_context)):
|
||||
return {'data': traces.get_available_actions(tenant_id=context.tenant_id)}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ def remove_widget_from_dashboard(projectId: int, dashboardId: int, widgetId: int
|
|||
# @app.put('/{projectId}/custom_metrics/try', tags=["customMetrics"])
|
||||
def try_card(projectId: int, data: schemas.CardSchema = Body(...),
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
return {"data": custom_metrics.merged_live(project_id=projectId, data=data, user_id=context.user_id)}
|
||||
return {"data": custom_metrics.get_chart(project_id=projectId, data=data, user_id=context.user_id)}
|
||||
|
||||
|
||||
@app.post('/{projectId}/cards/try/sessions', tags=["cards"])
|
||||
|
|
@ -110,21 +110,16 @@ def try_card(projectId: int, data: schemas.CardSchema = Body(...),
|
|||
# @app.post('/{projectId}/custom_metrics/try/sessions', tags=["customMetrics"])
|
||||
def try_card_sessions(projectId: int, data: schemas.CardSessionsSchema = Body(...),
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
data = custom_metrics.try_sessions(project_id=projectId, user_id=context.user_id, data=data)
|
||||
data = custom_metrics.get_sessions(project_id=projectId, user_id=context.user_id, data=data)
|
||||
return {"data": data}
|
||||
|
||||
|
||||
@app.post('/{projectId}/cards/try/issues', tags=["cards"])
|
||||
# @app.post('/{projectId}/metrics/try/issues', tags=["dashboard"])
|
||||
# @app.post('/{projectId}/custom_metrics/try/issues', tags=["customMetrics"])
|
||||
def try_card_funnel_issues(projectId: int, data: schemas.CardSessionsSchema = Body(...),
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
if len(data.series) == 0:
|
||||
return {"data": []}
|
||||
data.series[0].filter.startTimestamp = data.startTimestamp
|
||||
data.series[0].filter.endTimestamp = data.endTimestamp
|
||||
data = funnels.get_issues_on_the_fly_widget(project_id=projectId, data=data.series[0].filter)
|
||||
return {"data": data}
|
||||
def try_card_issues(projectId: int, data: schemas.CardSchema = Body(...),
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
return {"data": custom_metrics.get_issues(project_id=projectId, user_id=context.user_id, data=data)}
|
||||
|
||||
|
||||
@app.get('/{projectId}/cards', tags=["cards"])
|
||||
|
|
@ -180,7 +175,8 @@ def get_card(projectId: int, metric_id: Union[int, str], context: schemas.Curren
|
|||
def get_card_sessions(projectId: int, metric_id: int,
|
||||
data: schemas.CardSessionsSchema = Body(...),
|
||||
context: schemas.CurrentContext = Depends(OR_context)):
|
||||
data = custom_metrics.get_sessions(project_id=projectId, user_id=context.user_id, metric_id=metric_id, data=data)
|
||||
data = custom_metrics.get_sessions_by_card_id(project_id=projectId, user_id=context.user_id, metric_id=metric_id,
|
||||
data=data)
|
||||
if data is None:
|
||||
return {"errors": ["custom metric not found"]}
|
||||
return {"data": data}
|
||||
|
|
|
|||
|
|
@ -160,10 +160,10 @@ $$
|
|||
END
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS frontend_signals
|
||||
CREATE TABLE IF NOT EXISTS public.frontend_signals
|
||||
(
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
action text NOT NULL,
|
||||
source text NOT NULL,
|
||||
|
|
@ -171,14 +171,14 @@ CREATE TABLE IF NOT EXISTS frontend_signals
|
|||
data jsonb,
|
||||
created_at timestamp DEFAULT timezone('utc'::text, now()) NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS frontend_signals_user_id_idx ON frontend_signals (user_id);
|
||||
CREATE INDEX IF NOT EXISTS frontend_signals_user_id_idx ON public.frontend_signals (user_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS assist_records
|
||||
CREATE TABLE IF NOT EXISTS public.assist_records
|
||||
(
|
||||
record_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE SET NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE SET NULL,
|
||||
created_at bigint NOT NULL DEFAULT (EXTRACT(EPOCH FROM now() at time zone 'utc') * 1000)::bigint,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ $fn_def$, :'next_version')
|
|||
--
|
||||
|
||||
ALTER TABLE IF EXISTS public.frontend_signals
|
||||
ADD COLUMN IF NOT EXISTS session_id integer NULL REFERENCES sessions (session_id) ON DELETE SET NULL;
|
||||
ADD COLUMN IF NOT EXISTS session_id integer NULL REFERENCES public.sessions (session_id) ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE IF EXISTS public.sessions
|
||||
ADD COLUMN IF NOT EXISTS user_city text,
|
||||
|
|
@ -28,8 +28,8 @@ ALTER TABLE IF EXISTS public.sessions
|
|||
|
||||
COMMIT;
|
||||
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_project_id_user_city_idx ON sessions (project_id, user_city);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_project_id_user_state_idx ON sessions (project_id, user_state);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_project_id_user_city_idx ON public.sessions (project_id, user_city);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_project_id_user_state_idx ON public.sessions (project_id, user_state);
|
||||
|
||||
\elif :is_next
|
||||
\echo new version detected :'next_version', nothing to do
|
||||
|
|
|
|||
|
|
@ -22,15 +22,15 @@ $fn_def$, :'next_version')
|
|||
CREATE TABLE IF NOT EXISTS public.feature_flags
|
||||
(
|
||||
feature_flag_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
flag_key text NOT NULL,
|
||||
description text DEFAULT NULL,
|
||||
payload jsonb DEFAULT NULL,
|
||||
flag_type text NOT NULL,
|
||||
is_persist boolean NOT NULL DEFAULT FALSE,
|
||||
is_active boolean NOT NULL DEFAULT FALSE,
|
||||
created_by integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
updated_by integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
created_by integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
updated_by integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
created_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
updated_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
|
|
@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS public.feature_flags_variants
|
|||
|
||||
CREATE TABLE IF NOT EXISTS public.sessions_feature_flags
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
condition_id integer NULL REFERENCES feature_flags_conditions (condition_id) ON DELETE SET NULL
|
||||
);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ ALTER TABLE IF EXISTS public.projects
|
|||
CREATE TABLE IF NOT EXISTS public.crashes_ios
|
||||
(
|
||||
crash_ios_id text NOT NULL PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
reason text NOT NULL,
|
||||
stacktrace text NOT NULL
|
||||
|
|
@ -41,7 +41,7 @@ CREATE INDEX IF NOT EXISTS crashes_ios_project_id_idx ON public.crashes_ios (pro
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_common.crashes
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
crash_ios_id text NULL REFERENCES public.crashes_ios (crash_ios_id) ON DELETE CASCADE,
|
||||
|
|
@ -55,7 +55,7 @@ CREATE SCHEMA IF NOT EXISTS events_ios;
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.views
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -64,7 +64,7 @@ CREATE TABLE IF NOT EXISTS events_ios.views
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.taps
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
@ -80,7 +80,7 @@ CREATE INDEX IF NOT EXISTS taps_session_id_timestamp_idx ON events_ios.taps (ses
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.inputs
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
@ -94,7 +94,7 @@ CREATE INDEX IF NOT EXISTS inputs_label_session_id_timestamp_idx ON events_ios.i
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.swipes
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
@ -116,6 +116,9 @@ ALTER TABLE IF EXISTS events.clicks
|
|||
ADD COLUMN IF NOT EXISTS x integer DEFAULT NULL,
|
||||
ADD COLUMN IF NOT EXISTS y integer DEFAULT NULL;
|
||||
|
||||
ALTER TABLE IF EXISTS public.metrics
|
||||
ADD COLUMN IF NOT EXISTS card_info jsonb NULL;
|
||||
|
||||
COMMIT;
|
||||
|
||||
\elif :is_next
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
BEGIN;
|
||||
CREATE INDEX sessions_session_id_project_id_start_ts_durationNN_idx ON sessions (session_id, project_id, start_ts) WHERE duration IS NOT NULL;
|
||||
CREATE INDEX sessions_session_id_project_id_start_ts_durationNN_idx ON public.sessions (session_id, project_id, start_ts) WHERE duration IS NOT NULL;
|
||||
CREATE INDEX clicks_label_session_id_timestamp_idx ON events.clicks (label, session_id, timestamp);
|
||||
CREATE INDEX pages_base_path_session_id_timestamp_idx ON events.pages (base_path, session_id, timestamp);
|
||||
CREATE INDEX ON assigned_sessions (session_id);
|
||||
CREATE INDEX ON public.assigned_sessions (session_id);
|
||||
CREATE INDEX inputs_label_session_id_timestamp_idx ON events.inputs (label, session_id, timestamp);
|
||||
|
||||
CREATE INDEX clicks_url_idx ON events.clicks (url);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
BEGIN;
|
||||
CREATE INDEX projects_tenant_id_idx ON projects (tenant_id);
|
||||
CREATE INDEX projects_tenant_id_idx ON public.projects (tenant_id);
|
||||
CREATE INDEX webhooks_tenant_id_idx ON webhooks (tenant_id);
|
||||
|
||||
CREATE INDEX pages_session_id_timestamp_idx ON events.pages (session_id, timestamp);
|
||||
|
||||
CREATE INDEX issues_project_id_idx ON issues (project_id);
|
||||
CREATE INDEX jobs_project_id_idx ON jobs (project_id);
|
||||
CREATE INDEX issues_project_id_idx ON public.issues (project_id);
|
||||
CREATE INDEX jobs_project_id_idx ON public.jons (project_id);
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
BEGIN;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS sessions_user_id_useridNN_idx ON sessions (user_id) WHERE user_id IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS sessions_uid_projectid_startts_sessionid_uidNN_durGTZ_idx ON sessions (user_id, project_id, start_ts, session_id) WHERE user_id IS NOT NULL AND duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_user_id_useridNN_idx ON public.sessions (user_id) WHERE user_id IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS sessions_uid_projectid_startts_sessionid_uidNN_durGTZ_idx ON public.sessions (user_id, project_id, start_ts, session_id) WHERE user_id IS NOT NULL AND duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS pages_base_path_base_pathLNGT2_idx ON events.pages (base_path) WHERE length(base_path) > 2;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS users_tenant_id_deleted_at_N_idx ON users (tenant_id) WHERE deleted_at ISNULL;
|
||||
CREATE INDEX IF NOT EXISTS users_tenant_id_deleted_at_N_idx ON public.users (tenant_id) WHERE deleted_at ISNULL;
|
||||
CREATE INDEX IF NOT EXISTS issues_issue_id_timestamp_idx ON events_common.issues (issue_id, timestamp);
|
||||
CREATE INDEX IF NOT EXISTS issues_timestamp_idx ON events_common.issues (timestamp);
|
||||
CREATE INDEX IF NOT EXISTS issues_project_id_issue_id_idx ON public.issues (project_id, issue_id);
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ $$
|
|||
SELECT 'v1.4.0-ee'
|
||||
$$ LANGUAGE sql IMMUTABLE;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS traces
|
||||
CREATE TABLE IF NOT EXISTS public.traces
|
||||
(
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
tenant_id integer NOT NULL REFERENCES tenants (tenant_id) ON DELETE CASCADE,
|
||||
user_id integer NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
tenant_id integer NOT NULL REFERENCES public.tenants (tenant_id) ON DELETE CASCADE,
|
||||
created_at bigint NOT NULL DEFAULT (EXTRACT(EPOCH FROM now() at time zone 'utc') * 1000)::bigint,
|
||||
auth text NULL,
|
||||
action text NOT NULL,
|
||||
|
|
@ -19,10 +19,10 @@ CREATE TABLE IF NOT EXISTS traces
|
|||
parameters jsonb NULL,
|
||||
status int NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS traces_user_id_idx ON traces (user_id);
|
||||
CREATE INDEX IF NOT EXISTS traces_tenant_id_idx ON traces (tenant_id);
|
||||
CREATE INDEX IF NOT EXISTS traces_user_id_idx ON public.traces (user_id);
|
||||
CREATE INDEX IF NOT EXISTS traces_tenant_id_idx ON public.traces (tenant_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON public.user_favorite_sessions (user_id, session_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pages_first_contentful_paint_time_idx ON events.pages (first_contentful_paint_time) WHERE first_contentful_paint_time > 0;
|
||||
CREATE INDEX IF NOT EXISTS pages_dom_content_loaded_time_idx ON events.pages (dom_content_loaded_time) WHERE dom_content_loaded_time > 0;
|
||||
|
|
@ -38,7 +38,7 @@ CREATE INDEX IF NOT EXISTS pages_timestamp_metgt0_idx ON events.pages (timestamp
|
|||
time_to_interactive > 0;
|
||||
CREATE INDEX IF NOT EXISTS pages_session_id_speed_indexgt0nn_idx ON events.pages (session_id, speed_index) WHERE speed_index > 0 AND speed_index IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS pages_session_id_timestamp_dom_building_timegt0nn_idx ON events.pages (session_id, timestamp, dom_building_time) WHERE dom_building_time > 0 AND dom_building_time IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS issues_project_id_idx ON issues (project_id);
|
||||
CREATE INDEX IF NOT EXISTS issues_project_id_idx ON public.issues (project_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS errors_project_id_error_id_js_exception_idx ON public.errors (project_id, error_id) WHERE source = 'js_exception';
|
||||
CREATE INDEX IF NOT EXISTS errors_project_id_error_id_idx ON public.errors (project_id, error_id);
|
||||
|
|
@ -46,10 +46,10 @@ CREATE INDEX IF NOT EXISTS errors_project_id_error_id_integration_idx ON public.
|
|||
|
||||
CREATE INDEX IF NOT EXISTS sessions_start_ts_idx ON public.sessions (start_ts) WHERE duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_idx ON public.sessions (project_id) WHERE duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_session_id_project_id_start_ts_idx ON sessions (session_id, project_id, start_ts) WHERE duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_session_id_project_id_start_ts_idx ON public.sessions (session_id, project_id, start_ts) WHERE duration > 0;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX IF NOT EXISTS jobs_project_id_idx ON jobs (project_id);
|
||||
CREATE INDEX IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON public.user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX IF NOT EXISTS jobs_project_id_idx ON public.jons (project_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_session_id_timestamp_error_id_idx ON events.errors (session_id, timestamp, error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_error_id_timestamp_idx ON events.errors (error_id, timestamp);
|
||||
CREATE INDEX IF NOT EXISTS errors_timestamp_error_id_session_id_idx ON events.errors (timestamp, error_id, session_id);
|
||||
|
|
@ -66,10 +66,10 @@ CREATE INDEX IF NOT EXISTS resources_session_id_timestamp_url_host_firstparty_id
|
|||
CREATE INDEX IF NOT EXISTS resources_session_id_timestamp_duration_durationgt0NN_img_idx ON events.resources (session_id, timestamp, duration) WHERE duration > 0 AND duration IS NOT NULL AND type = 'img';
|
||||
CREATE INDEX IF NOT EXISTS resources_timestamp_session_id_idx ON events.resources (timestamp, session_id);
|
||||
|
||||
DROP TRIGGER IF EXISTS on_insert_or_update ON projects;
|
||||
DROP TRIGGER IF EXISTS on_insert_or_update ON public.projects;
|
||||
CREATE TRIGGER on_insert_or_update
|
||||
AFTER INSERT OR UPDATE
|
||||
ON projects
|
||||
ON public.projects
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_project();
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ DROP INDEX IF EXISTS sessions_project_id_user_country_idx1;
|
|||
ALTER INDEX IF EXISTS platform_idx RENAME TO sessions_platform_idx;
|
||||
ALTER INDEX IF EXISTS events.resources_duration_idx RENAME TO resources_duration_durationgt0_idx;
|
||||
DROP INDEX IF EXISTS projects_project_key_idx1;
|
||||
CREATE INDEX IF NOT EXISTS errors_parent_error_id_idx ON errors (parent_error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_parent_error_id_idx ON public.errors (parent_error_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS performance_session_id_idx ON events.performance (session_id);
|
||||
CREATE INDEX IF NOT EXISTS performance_timestamp_idx ON events.performance (timestamp);
|
||||
|
|
@ -102,21 +102,21 @@ CREATE INDEX IF NOT EXISTS performance_session_id_timestamp_idx ON events.perfor
|
|||
CREATE INDEX IF NOT EXISTS performance_avg_cpu_gt0_idx ON events.performance (avg_cpu) WHERE avg_cpu > 0;
|
||||
CREATE INDEX IF NOT EXISTS performance_avg_used_js_heap_size_gt0_idx ON events.performance (avg_used_js_heap_size) WHERE avg_used_js_heap_size > 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS metrics
|
||||
CREATE TABLE IF NOT EXISTS public.metrics
|
||||
(
|
||||
metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT FALSE,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
deleted_at timestamp
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS metrics_user_id_is_public_idx ON public.metrics (user_id, is_public);
|
||||
CREATE TABLE IF NOT EXISTS metric_series
|
||||
CREATE TABLE IF NOT EXISTS public.metric_series
|
||||
(
|
||||
series_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
metric_id integer REFERENCES metrics (metric_id) ON DELETE CASCADE,
|
||||
metric_id integer REFERENCES public.metrics (metric_id) ON DELETE CASCADE,
|
||||
index integer NOT NULL,
|
||||
name text NULL,
|
||||
filter jsonb NOT NULL,
|
||||
|
|
@ -127,11 +127,11 @@ CREATE INDEX IF NOT EXISTS metric_series_metric_id_idx ON public.metric_series (
|
|||
CREATE INDEX IF NOT EXISTS funnels_project_id_idx ON public.funnels (project_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS searches
|
||||
CREATE TABLE IF NOT EXISTS public.searches
|
||||
(
|
||||
search_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
name text not null,
|
||||
filter jsonb not null,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
|
|
@ -144,7 +144,7 @@ CREATE INDEX IF NOT EXISTS searches_project_id_idx ON public.searches (project_i
|
|||
CREATE INDEX IF NOT EXISTS alerts_project_id_idx ON alerts (project_id);
|
||||
|
||||
ALTER TABLE alerts
|
||||
ADD COLUMN IF NOT EXISTS series_id integer NULL REFERENCES metric_series (series_id) ON DELETE CASCADE;
|
||||
ADD COLUMN IF NOT EXISTS series_id integer NULL REFERENCES public.metric_series (series_id) ON DELETE CASCADE;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS alerts_series_id_idx ON alerts (series_id);
|
||||
UPDATE alerts
|
||||
|
|
@ -155,13 +155,13 @@ WHERE detection_method = 'change'
|
|||
ALTER TABLE roles
|
||||
ADD COLUMN IF NOT EXISTS all_projects bool NOT NULL DEFAULT TRUE;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS roles_projects
|
||||
CREATE TABLE IF NOT EXISTS public.roles_projects
|
||||
(
|
||||
role_id integer NOT NULL REFERENCES roles (role_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
CONSTRAINT roles_projects_pkey PRIMARY KEY (role_id, project_id)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS roles_projects_role_id_idx ON roles_projects (role_id);
|
||||
CREATE INDEX IF NOT EXISTS roles_projects_project_id_idx ON roles_projects (project_id);
|
||||
CREATE INDEX IF NOT EXISTS roles_projects_role_id_idx ON public.roles_projects (role_id);
|
||||
CREATE INDEX IF NOT EXISTS roles_projects_project_id_idx ON public.roles_projects (project_id);
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -18,9 +18,9 @@ $fn_def$, :'next_version')
|
|||
\gexec
|
||||
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS traces
|
||||
CREATE TABLE IF NOT EXISTS public.traces
|
||||
(
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
user_id integer NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
tenant_id integer NOT NULL REFERENCES tenants (tenant_id) ON DELETE CASCADE,
|
||||
created_at bigint NOT NULL DEFAULT (EXTRACT(EPOCH FROM now() at time zone 'utc') * 1000)::bigint,
|
||||
auth text NULL,
|
||||
|
|
@ -33,10 +33,10 @@ CREATE TABLE IF NOT EXISTS traces
|
|||
status int NULL
|
||||
);
|
||||
|
||||
DROP TRIGGER IF EXISTS on_insert_or_update ON projects;
|
||||
DROP TRIGGER IF EXISTS on_insert_or_update ON public.projects;
|
||||
CREATE TRIGGER on_insert_or_update
|
||||
AFTER INSERT OR UPDATE
|
||||
ON projects
|
||||
ON public.projects
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_project();
|
||||
|
||||
|
|
@ -58,21 +58,21 @@ ALTER INDEX IF EXISTS platform_idx RENAME TO sessions_platform_idx;
|
|||
ALTER INDEX IF EXISTS events.resources_duration_idx RENAME TO resources_duration_durationgt0_idx;
|
||||
DROP INDEX IF EXISTS projects_project_key_idx1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS metrics
|
||||
CREATE TABLE IF NOT EXISTS public.metrics
|
||||
(
|
||||
metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT FALSE,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
deleted_at timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS metric_series
|
||||
CREATE TABLE IF NOT EXISTS public.metric_series
|
||||
(
|
||||
series_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
metric_id integer REFERENCES metrics (metric_id) ON DELETE CASCADE,
|
||||
metric_id integer REFERENCES public.metrics (metric_id) ON DELETE CASCADE,
|
||||
index integer NOT NULL,
|
||||
name text NULL,
|
||||
filter jsonb NOT NULL,
|
||||
|
|
@ -81,11 +81,11 @@ CREATE TABLE IF NOT EXISTS metric_series
|
|||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS searches
|
||||
CREATE TABLE IF NOT EXISTS public.searches
|
||||
(
|
||||
search_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
name text not null,
|
||||
filter jsonb not null,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
|
|
@ -94,7 +94,7 @@ CREATE TABLE IF NOT EXISTS searches
|
|||
);
|
||||
|
||||
ALTER TABLE alerts
|
||||
ADD COLUMN IF NOT EXISTS series_id integer NULL REFERENCES metric_series (series_id) ON DELETE CASCADE;
|
||||
ADD COLUMN IF NOT EXISTS series_id integer NULL REFERENCES public.metric_series (series_id) ON DELETE CASCADE;
|
||||
|
||||
UPDATE alerts
|
||||
SET options=jsonb_set(options, '{change}', '"change"')
|
||||
|
|
@ -104,10 +104,10 @@ WHERE detection_method = 'change'
|
|||
ALTER TABLE roles
|
||||
ADD COLUMN IF NOT EXISTS all_projects bool NOT NULL DEFAULT TRUE;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS roles_projects
|
||||
CREATE TABLE IF NOT EXISTS public.roles_projects
|
||||
(
|
||||
role_id integer NOT NULL REFERENCES roles (role_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
role_id integer NOT NULL REFERENCES public.roles (role_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
CONSTRAINT roles_projects_pkey PRIMARY KEY (role_id, project_id)
|
||||
);
|
||||
--
|
||||
|
|
@ -117,9 +117,9 @@ ALTER TABLE public.metrics
|
|||
COMMIT;
|
||||
ALTER TYPE public.error_source ADD VALUE IF NOT EXISTS 'elasticsearch'; -- cannot add new value inside a transaction block
|
||||
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS traces_user_id_idx ON traces (user_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS traces_tenant_id_idx ON traces (tenant_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS traces_user_id_idx ON public.traces (user_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS traces_tenant_id_idx ON public.traces (tenant_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON public.user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS pages_first_contentful_paint_time_idx ON events.pages (first_contentful_paint_time) WHERE first_contentful_paint_time > 0;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS pages_dom_content_loaded_time_idx ON events.pages (dom_content_loaded_time) WHERE dom_content_loaded_time > 0;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS pages_first_paint_time_idx ON events.pages (first_paint_time) WHERE first_paint_time > 0;
|
||||
|
|
@ -128,22 +128,22 @@ CREATE INDEX CONCURRENTLY IF NOT EXISTS pages_time_to_interactive_idx ON events.
|
|||
CREATE INDEX CONCURRENTLY IF NOT EXISTS pages_session_id_timestamp_loadgt0NN_idx ON events.pages (session_id, timestamp) WHERE load_time > 0 AND load_time IS NOT NULL;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS pages_session_id_timestamp_visualgt0nn_idx ON events.pages (session_id, timestamp) WHERE visually_complete > 0 AND visually_complete IS NOT NULL;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS pages_timestamp_metgt0_idx ON events.pages (timestamp) WHERE
|
||||
response_time > 0 OR
|
||||
first_paint_time > 0 OR
|
||||
dom_content_loaded_time > 0 OR
|
||||
ttfb > 0 OR
|
||||
time_to_interactive > 0;
|
||||
response_time > 0 OR
|
||||
first_paint_time > 0 OR
|
||||
dom_content_loaded_time > 0 OR
|
||||
ttfb > 0 OR
|
||||
time_to_interactive > 0;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS pages_session_id_speed_indexgt0nn_idx ON events.pages (session_id, speed_index) WHERE speed_index > 0 AND speed_index IS NOT NULL;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS pages_session_id_timestamp_dom_building_timegt0nn_idx ON events.pages (session_id, timestamp, dom_building_time) WHERE dom_building_time > 0 AND dom_building_time IS NOT NULL;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS issues_project_id_idx ON issues (project_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS issues_project_id_idx ON public.issues (project_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS errors_project_id_error_id_js_exception_idx ON public.errors (project_id, error_id) WHERE source = 'js_exception';
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS errors_project_id_error_id_idx ON public.errors (project_id, error_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS errors_project_id_error_id_integration_idx ON public.errors (project_id, error_id) WHERE source != 'js_exception';
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_start_ts_idx ON public.sessions (start_ts) WHERE duration > 0;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_project_id_idx ON public.sessions (project_id) WHERE duration > 0;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_session_id_project_id_start_ts_idx ON sessions (session_id, project_id, start_ts) WHERE duration > 0;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS jobs_project_id_idx ON jobs (project_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_session_id_project_id_start_ts_idx ON public.sessions (session_id, project_id, start_ts) WHERE duration > 0;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON public.user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS jobs_project_id_idx ON public.jobs (project_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS errors_session_id_timestamp_error_id_idx ON events.errors (session_id, timestamp, error_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS errors_error_id_timestamp_idx ON events.errors (error_id, timestamp);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS errors_timestamp_error_id_session_id_idx ON events.errors (timestamp, error_id, session_id);
|
||||
|
|
@ -163,7 +163,7 @@ CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_utm_source_gin_idx ON public.se
|
|||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_utm_medium_gin_idx ON public.sessions USING GIN (utm_medium gin_trgm_ops);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_utm_campaign_gin_idx ON public.sessions USING GIN (utm_campaign gin_trgm_ops);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS requests_timestamp_session_id_failed_idx ON events_common.requests (timestamp, session_id) WHERE success = FALSE;
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS errors_parent_error_id_idx ON errors (parent_error_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS errors_parent_error_id_idx ON public.errors (parent_error_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS performance_session_id_idx ON events.performance (session_id);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS performance_timestamp_idx ON events.performance (timestamp);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS performance_session_id_timestamp_idx ON events.performance (session_id, timestamp);
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ $fn_def$, :'next_version')
|
|||
--
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS dashboards
|
||||
CREATE TABLE IF NOT EXISTS public.dashboards
|
||||
(
|
||||
dashboard_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT TRUE,
|
||||
is_pinned boolean NOT NULL DEFAULT FALSE,
|
||||
|
|
@ -56,12 +56,12 @@ ALTER TABLE IF EXISTS metrics
|
|||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS dashboard_widgets
|
||||
CREATE TABLE IF NOT EXISTS public.dashboard_widgets
|
||||
(
|
||||
widget_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
dashboard_id integer NOT NULL REFERENCES dashboards (dashboard_id) ON DELETE CASCADE,
|
||||
metric_id integer NOT NULL REFERENCES metrics (metric_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
dashboard_id integer NOT NULL REFERENCES public.dashboards (dashboard_id) ON DELETE CASCADE,
|
||||
metric_id integer NOT NULL REFERENCES public.metrics (metric_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
config jsonb NOT NULL DEFAULT '{}'::jsonb
|
||||
);
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ ALTER TABLE IF EXISTS dashboards
|
|||
|
||||
|
||||
CREATE
|
||||
INDEX IF NOT EXISTS traces_created_at_idx ON traces (created_at);
|
||||
INDEX IF NOT EXISTS traces_created_at_idx ON public.traces (created_at);
|
||||
CREATE
|
||||
INDEX IF NOT EXISTS traces_action_idx ON traces (action);
|
||||
INDEX IF NOT EXISTS traces_action_idx ON public.traces (action);
|
||||
CREATE
|
||||
INDEX IF NOT EXISTS users_name_gin_idx ON users USING GIN (name gin_trgm_ops);
|
||||
INDEX IF NOT EXISTS users_name_gin_idx ON public.users USING GIN (name gin_trgm_ops);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,29 +28,29 @@ CREATE TABLE IF NOT EXISTS sessions_notes
|
|||
note_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
message text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
user_id integer NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
tag text NULL,
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
timestamp integer NOT NULL DEFAULT -1,
|
||||
is_public boolean NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS errors_tags
|
||||
CREATE TABLE IF NOT EXISTS public.errors_tags
|
||||
(
|
||||
key text NOT NULL,
|
||||
value text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES public.errors (error_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL,
|
||||
message_id bigint NOT NULL,
|
||||
FOREIGN KEY (session_id, message_id) REFERENCES events.errors (session_id, message_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON errors_tags (error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_session_id_idx ON errors_tags (session_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_message_id_idx ON errors_tags (message_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON public.errors_tags (error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_session_id_idx ON public.errors_tags (session_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_message_id_idx ON public.errors_tags (message_id);
|
||||
|
||||
UPDATE metrics
|
||||
SET default_config=default_config || '{"col":4}'
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ $$
|
|||
ELSE
|
||||
raise notice 'Some or all public schema tables are missing, creating missing tables';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tenants
|
||||
CREATE TABLE IF NOT EXISTS public.tenants
|
||||
(
|
||||
tenant_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
tenant_key text NOT NULL DEFAULT generate_api_key(20),
|
||||
|
|
@ -164,10 +164,10 @@ $$
|
|||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS roles
|
||||
CREATE TABLE IF NOT EXISTS public.roles
|
||||
(
|
||||
role_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
tenant_id integer NOT NULL REFERENCES tenants (tenant_id) ON DELETE CASCADE,
|
||||
tenant_id integer NOT NULL REFERENCES public.tenants (tenant_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
description text DEFAULT NULL,
|
||||
permissions text[] NOT NULL DEFAULT '{}',
|
||||
|
|
@ -185,10 +185,10 @@ $$
|
|||
END IF;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users
|
||||
CREATE TABLE IF NOT EXISTS public.users
|
||||
(
|
||||
user_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
tenant_id integer NOT NULL REFERENCES tenants (tenant_id) ON DELETE CASCADE,
|
||||
tenant_id integer NOT NULL REFERENCES public.tenants (tenant_id) ON DELETE CASCADE,
|
||||
email text NOT NULL UNIQUE,
|
||||
role user_role NOT NULL DEFAULT 'member',
|
||||
name text NOT NULL,
|
||||
|
|
@ -201,17 +201,17 @@ $$
|
|||
data jsonb NOT NULL DEFAULT'{}'::jsonb,
|
||||
weekly_report boolean NOT NULL DEFAULT TRUE,
|
||||
origin text NULL DEFAULT NULL,
|
||||
role_id integer REFERENCES roles (role_id) ON DELETE SET NULL,
|
||||
role_id integer REFERENCES public.roles (role_id) ON DELETE SET NULL,
|
||||
internal_id text NULL DEFAULT NULL,
|
||||
service_account bool NOT NULL DEFAULT FALSE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS users_tenant_id_deleted_at_N_idx ON users (tenant_id) WHERE deleted_at ISNULL;
|
||||
CREATE INDEX IF NOT EXISTS users_name_gin_idx ON users USING GIN (name gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS users_tenant_id_deleted_at_N_idx ON public.users (tenant_id) WHERE deleted_at ISNULL;
|
||||
CREATE INDEX IF NOT EXISTS users_name_gin_idx ON public.users USING GIN (name gin_trgm_ops);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS basic_authentication
|
||||
CREATE TABLE IF NOT EXISTS public.basic_authentication
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
password text DEFAULT NULL,
|
||||
invitation_token text NULL DEFAULT NULL,
|
||||
invited_at timestamp without time zone NULL DEFAULT NULL,
|
||||
|
|
@ -227,14 +227,14 @@ $$
|
|||
CREATE TYPE oauth_provider AS ENUM ('jira','github');
|
||||
END IF;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS oauth_authentication
|
||||
CREATE TABLE IF NOT EXISTS public.oauth_authentication
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
provider oauth_provider NOT NULL,
|
||||
provider_user_id text NOT NULL,
|
||||
token text NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS oauth_authentication_unique_user_id_provider_idx ON oauth_authentication (user_id, provider);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS oauth_authentication_unique_user_id_provider_idx ON public.oauth_authentication (user_id, provider);
|
||||
|
||||
IF NOT EXISTS(SELECT *
|
||||
FROM pg_type typ
|
||||
|
|
@ -242,11 +242,11 @@ $$
|
|||
CREATE TYPE platform AS ENUM ('web','ios','android');
|
||||
END IF;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS projects
|
||||
CREATE TABLE IF NOT EXISTS public.projects
|
||||
(
|
||||
project_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_key varchar(20) NOT NULL UNIQUE DEFAULT generate_api_key(20),
|
||||
tenant_id integer NOT NULL REFERENCES tenants (tenant_id) ON DELETE CASCADE,
|
||||
tenant_id integer NOT NULL REFERENCES public.tenants (tenant_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
platform platform NOT NULL DEFAULT 'web',
|
||||
active boolean NOT NULL,
|
||||
|
|
@ -280,21 +280,21 @@ $$
|
|||
CREATE INDEX IF NOT EXISTS projects_tenant_id_idx ON public.projects (tenant_id);
|
||||
CREATE INDEX IF NOT EXISTS projects_project_key_idx ON public.projects (project_key);
|
||||
CREATE INDEX IF NOT EXISTS projects_project_id_deleted_at_n_idx ON public.projects (project_id) WHERE deleted_at IS NULL;
|
||||
DROP TRIGGER IF EXISTS on_insert_or_update ON projects;
|
||||
DROP TRIGGER IF EXISTS on_insert_or_update ON public.projects;
|
||||
CREATE TRIGGER on_insert_or_update
|
||||
AFTER INSERT OR UPDATE
|
||||
ON projects
|
||||
ON public.projects
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_project();
|
||||
|
||||
CREATE TABLE IF NOT EXISTS roles_projects
|
||||
CREATE TABLE IF NOT EXISTS public.roles_projects
|
||||
(
|
||||
role_id integer NOT NULL REFERENCES roles (role_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
role_id integer NOT NULL REFERENCES public.roles (role_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
CONSTRAINT roles_projects_pkey PRIMARY KEY (role_id, project_id)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS roles_projects_role_id_idx ON roles_projects (role_id);
|
||||
CREATE INDEX IF NOT EXISTS roles_projects_project_id_idx ON roles_projects (project_id);
|
||||
CREATE INDEX IF NOT EXISTS roles_projects_role_id_idx ON public.roles_projects (role_id);
|
||||
CREATE INDEX IF NOT EXISTS roles_projects_project_id_idx ON public.roles_projects (project_id);
|
||||
|
||||
|
||||
IF NOT EXISTS(SELECT *
|
||||
|
|
@ -304,14 +304,14 @@ $$
|
|||
END IF;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS webhooks
|
||||
CREATE TABLE IF NOT EXISTS public.webhooks
|
||||
(
|
||||
webhook_id integer generated by DEFAULT as identity
|
||||
constraint webhooks_pkey
|
||||
primary key,
|
||||
tenant_id integer NOT NULL
|
||||
constraint webhooks_tenant_id_fkey
|
||||
references tenants
|
||||
REFERENCES public.tenants
|
||||
on delete cascade,
|
||||
endpoint text NOT NULL,
|
||||
created_at timestamp DEFAULT timezone('utc'::text, now()) NOT NULL,
|
||||
|
|
@ -323,11 +323,11 @@ $$
|
|||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS notifications
|
||||
CREATE TABLE IF NOT EXISTS public.notifications
|
||||
(
|
||||
notification_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
tenant_id integer REFERENCES tenants (tenant_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
tenant_id integer REFERENCES public.tenants (tenant_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
title text NOT NULL,
|
||||
description text NOT NULL,
|
||||
button_text varchar(80) NULL,
|
||||
|
|
@ -338,15 +338,15 @@ $$
|
|||
CONSTRAINT notification_tenant_xor_user CHECK ( tenant_id NOTNULL AND user_id ISNULL OR
|
||||
tenant_id ISNULL AND user_id NOTNULL )
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS notifications_user_id_index ON notifications (user_id);
|
||||
CREATE INDEX IF NOT EXISTS notifications_tenant_id_index ON notifications (tenant_id);
|
||||
CREATE INDEX IF NOT EXISTS notifications_created_at_index ON notifications (created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS notifications_created_at_epoch_idx ON notifications (CAST(EXTRACT(EPOCH FROM created_at) * 1000 AS BIGINT) DESC);
|
||||
CREATE INDEX IF NOT EXISTS notifications_user_id_index ON public.notifications (user_id);
|
||||
CREATE INDEX IF NOT EXISTS notifications_tenant_id_index ON public.notifications (tenant_id);
|
||||
CREATE INDEX IF NOT EXISTS notifications_created_at_index ON public.notifications (created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS notifications_created_at_epoch_idx ON public.notifications (CAST(EXTRACT(EPOCH FROM created_at) * 1000 AS BIGINT) DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_viewed_notifications
|
||||
CREATE TABLE IF NOT EXISTS public.user_viewed_notifications
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) on delete cascade,
|
||||
notification_id integer NOT NULL REFERENCES notifications (notification_id) on delete cascade,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) on delete cascade,
|
||||
notification_id integer NOT NULL REFERENCES public.notifications (notification_id) on delete cascade,
|
||||
constraint user_viewed_notifications_pkey primary key (user_id, notification_id)
|
||||
);
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ $$
|
|||
CREATE TYPE announcement_type AS ENUM ('notification','alert');
|
||||
END IF;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS announcements
|
||||
CREATE TABLE IF NOT EXISTS public.announcements
|
||||
(
|
||||
announcement_id serial NOT NULL
|
||||
constraint announcements_pk
|
||||
|
|
@ -377,31 +377,31 @@ $$
|
|||
CREATE TYPE integration_provider AS ENUM ('bugsnag','cloudwatch','datadog','newrelic','rollbar','sentry','stackdriver','sumologic','elasticsearch'); --,'jira','github');
|
||||
END IF;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS integrations
|
||||
CREATE TABLE IF NOT EXISTS public.integrations
|
||||
(
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
provider integration_provider NOT NULL,
|
||||
options jsonb NOT NULL,
|
||||
request_data jsonb NOT NULL DEFAULT'{}'::jsonb,
|
||||
PRIMARY KEY (project_id, provider)
|
||||
);
|
||||
|
||||
DROP TRIGGER IF EXISTS on_insert_or_update_or_delete ON integrations;
|
||||
DROP TRIGGER IF EXISTS on_insert_or_update_or_delete ON public.integrations;
|
||||
|
||||
CREATE TRIGGER on_insert_or_update_or_delete
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON integrations
|
||||
ON public.integrations
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_integration();
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS jira_cloud
|
||||
CREATE TABLE IF NOT EXISTS public.jira_cloud
|
||||
(
|
||||
user_id integer NOT NULL
|
||||
constraint jira_cloud_pk
|
||||
primary key
|
||||
constraint jira_cloud_users_fkey
|
||||
references users
|
||||
REFERENCES public.users
|
||||
on delete cascade,
|
||||
username text NOT NULL,
|
||||
token text NOT NULL,
|
||||
|
|
@ -437,17 +437,17 @@ $$
|
|||
);
|
||||
END IF;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS issues
|
||||
CREATE TABLE IF NOT EXISTS public.issues
|
||||
(
|
||||
issue_id text NOT NULL PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
type issue_type NOT NULL,
|
||||
context_string text NOT NULL,
|
||||
context jsonb DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS issues_issue_id_type_idx ON issues (issue_id, type);
|
||||
CREATE INDEX IF NOT EXISTS issues_issue_id_type_idx ON public.issues (issue_id, type);
|
||||
CREATE INDEX IF NOT EXISTS issues_project_id_issue_id_idx ON public.issues (project_id, issue_id);
|
||||
CREATE INDEX IF NOT EXISTS issues_project_id_idx ON issues (project_id);
|
||||
CREATE INDEX IF NOT EXISTS issues_project_id_idx ON public.issues (project_id);
|
||||
|
||||
IF NOT EXISTS(SELECT *
|
||||
FROM pg_type typ
|
||||
|
|
@ -461,20 +461,20 @@ $$
|
|||
CREATE TYPE error_status AS ENUM ('unresolved','resolved','ignored');
|
||||
END IF;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS errors
|
||||
CREATE TABLE IF NOT EXISTS public.errors
|
||||
(
|
||||
error_id text NOT NULL PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
source error_source NOT NULL,
|
||||
name text DEFAULT NULL,
|
||||
message text NOT NULL,
|
||||
payload jsonb NOT NULL,
|
||||
status error_status NOT NULL DEFAULT 'unresolved',
|
||||
parent_error_id text DEFAULT NULL REFERENCES errors (error_id) ON DELETE SET NULL,
|
||||
parent_error_id text DEFAULT NULL REFERENCES public.errors (error_id) ON DELETE SET NULL,
|
||||
stacktrace jsonb, --to save the stacktrace and not query S3 another time
|
||||
stacktrace_parsed_at timestamp
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS errors_project_id_source_idx ON errors (project_id, source);
|
||||
CREATE INDEX IF NOT EXISTS errors_project_id_source_idx ON public.errors (project_id, source);
|
||||
CREATE INDEX IF NOT EXISTS errors_message_gin_idx ON public.errors USING GIN (message gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS errors_name_gin_idx ON public.errors USING GIN (name gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS errors_project_id_idx ON public.errors (project_id);
|
||||
|
|
@ -482,20 +482,20 @@ $$
|
|||
CREATE INDEX IF NOT EXISTS errors_project_id_error_id_js_exception_idx ON public.errors (project_id, error_id) WHERE source = 'js_exception';
|
||||
CREATE INDEX IF NOT EXISTS errors_project_id_error_id_idx ON public.errors (project_id, error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_project_id_error_id_integration_idx ON public.errors (project_id, error_id) WHERE source != 'js_exception';
|
||||
CREATE INDEX IF NOT EXISTS errors_error_id_idx ON errors (error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_parent_error_id_idx ON errors (parent_error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_error_id_idx ON public.errors (error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_parent_error_id_idx ON public.errors (parent_error_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_favorite_errors
|
||||
CREATE TABLE IF NOT EXISTS public.user_favorite_errors
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES public.errors (error_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (user_id, error_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_viewed_errors
|
||||
CREATE TABLE IF NOT EXISTS public.user_viewed_errors
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES public.errors (error_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (user_id, error_id)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS user_viewed_errors_user_id_idx ON public.user_viewed_errors (user_id);
|
||||
|
|
@ -514,10 +514,10 @@ $$
|
|||
CREATE TYPE country AS ENUM ('UN','RW','SO','YE','IQ','SA','IR','CY','TZ','SY','AM','KE','CD','DJ','UG','CF','SC','JO','LB','KW','OM','QA','BH','AE','IL','TR','ET','ER','EG','SD','GR','BI','EE','LV','AZ','LT','SJ','GE','MD','BY','FI','AX','UA','MK','HU','BG','AL','PL','RO','XK','ZW','ZM','KM','MW','LS','BW','MU','SZ','RE','ZA','YT','MZ','MG','AF','PK','BD','TM','TJ','LK','BT','IN','MV','IO','NP','MM','UZ','KZ','KG','TF','HM','CC','PW','VN','TH','ID','LA','TW','PH','MY','CN','HK','BN','MO','KH','KR','JP','KP','SG','CK','TL','RU','MN','AU','CX','MH','FM','PG','SB','TV','NR','VU','NC','NF','NZ','FJ','LY','CM','SN','CG','PT','LR','CI','GH','GQ','NG','BF','TG','GW','MR','BJ','GA','SL','ST','GI','GM','GN','TD','NE','ML','EH','TN','ES','MA','MT','DZ','FO','DK','IS','GB','CH','SE','NL','AT','BE','DE','LU','IE','MC','FR','AD','LI','JE','IM','GG','SK','CZ','NO','VA','SM','IT','SI','ME','HR','BA','AO','NA','SH','BV','BB','CV','GY','GF','SR','PM','GL','PY','UY','BR','FK','GS','JM','DO','CU','MQ','BS','BM','AI','TT','KN','DM','AG','LC','TC','AW','VG','VC','MS','MF','BL','GP','GD','KY','BZ','SV','GT','HN','NI','CR','VE','EC','CO','PA','HT','AR','CL','BO','PE','MX','PF','PN','KI','TK','TO','WF','WS','NU','MP','GU','PR','VI','UM','AS','CA','US','PS','RS','AQ','SX','CW','BQ','SS','AC','AN','BU','CP','CS','CT','DD','DG','DY','EA','FQ','FX','HV','IC','JT','MI','NH','NQ','NT','PC','PU','PZ','RH','SU','TA','TP','VD','WK','YD','YU','ZR');
|
||||
END IF;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sessions
|
||||
CREATE TABLE IF NOT EXISTS public.sessions
|
||||
(
|
||||
session_id bigint PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
tracker_version text NOT NULL,
|
||||
start_ts bigint NOT NULL,
|
||||
timezone text NULL,
|
||||
|
|
@ -563,25 +563,25 @@ $$
|
|||
metadata_9 text DEFAULT NULL,
|
||||
metadata_10 text DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_start_ts_idx ON sessions (project_id, start_ts);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_id_idx ON sessions (project_id, user_id);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_anonymous_id_idx ON sessions (project_id, user_anonymous_id);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_device_idx ON sessions (project_id, user_device);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_country_idx ON sessions (project_id, user_country);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_city_idx ON sessions (project_id, user_city);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_state_idx ON sessions (project_id, user_state);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_browser_idx ON sessions (project_id, user_browser);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_1_idx ON sessions (project_id, metadata_1);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_2_idx ON sessions (project_id, metadata_2);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_3_idx ON sessions (project_id, metadata_3);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_4_idx ON sessions (project_id, metadata_4);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_5_idx ON sessions (project_id, metadata_5);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_6_idx ON sessions (project_id, metadata_6);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_7_idx ON sessions (project_id, metadata_7);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_8_idx ON sessions (project_id, metadata_8);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_9_idx ON sessions (project_id, metadata_9);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_10_idx ON sessions (project_id, metadata_10);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_watchdogs_score_idx ON sessions (project_id, watchdogs_score DESC);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_start_ts_idx ON public.sessions (project_id, start_ts);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_id_idx ON public.sessions (project_id, user_id);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_anonymous_id_idx ON public.sessions (project_id, user_anonymous_id);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_device_idx ON public.sessions (project_id, user_device);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_country_idx ON public.sessions (project_id, user_country);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_city_idx ON public.sessions (project_id, user_city);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_state_idx ON public.sessions (project_id, user_state);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_user_browser_idx ON public.sessions (project_id, user_browser);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_1_idx ON public.sessions (project_id, metadata_1);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_2_idx ON public.sessions (project_id, metadata_2);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_3_idx ON public.sessions (project_id, metadata_3);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_4_idx ON public.sessions (project_id, metadata_4);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_5_idx ON public.sessions (project_id, metadata_5);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_6_idx ON public.sessions (project_id, metadata_6);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_7_idx ON public.sessions (project_id, metadata_7);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_8_idx ON public.sessions (project_id, metadata_8);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_9_idx ON public.sessions (project_id, metadata_9);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_metadata_10_idx ON public.sessions (project_id, metadata_10);
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_watchdogs_score_idx ON public.sessions (project_id, watchdogs_score DESC);
|
||||
CREATE INDEX IF NOT EXISTS sessions_platform_idx ON public.sessions (platform);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS sessions_metadata1_gin_idx ON public.sessions USING GIN (metadata_1 gin_trgm_ops);
|
||||
|
|
@ -599,10 +599,10 @@ $$
|
|||
CREATE INDEX IF NOT EXISTS sessions_user_anonymous_id_gin_idx ON public.sessions USING GIN (user_anonymous_id gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS sessions_start_ts_idx ON public.sessions (start_ts) WHERE duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_project_id_idx ON public.sessions (project_id) WHERE duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_session_id_project_id_start_ts_idx ON sessions (session_id, project_id, start_ts) WHERE duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_session_id_project_id_start_ts_durationNN_idx ON sessions (session_id, project_id, start_ts) WHERE duration IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS sessions_user_id_useridNN_idx ON sessions (user_id) WHERE user_id IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS sessions_uid_projectid_startts_sessionid_uidNN_durGTZ_idx ON sessions (user_id, project_id, start_ts, session_id) WHERE user_id IS NOT NULL AND duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_session_id_project_id_start_ts_idx ON public.sessions (session_id, project_id, start_ts) WHERE duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_session_id_project_id_start_ts_durationNN_idx ON public.sessions (session_id, project_id, start_ts) WHERE duration IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS sessions_user_id_useridNN_idx ON public.sessions (user_id) WHERE user_id IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS sessions_uid_projectid_startts_sessionid_uidNN_durGTZ_idx ON public.sessions (user_id, project_id, start_ts, session_id) WHERE user_id IS NOT NULL AND duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_utm_source_gin_idx ON public.sessions USING GIN (utm_source gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS sessions_utm_medium_gin_idx ON public.sessions USING GIN (utm_medium gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS sessions_utm_campaign_gin_idx ON public.sessions USING GIN (utm_campaign gin_trgm_ops);
|
||||
|
|
@ -630,58 +630,58 @@ $$
|
|||
EXCEPTION
|
||||
WHEN duplicate_object THEN RAISE NOTICE 'Table constraint already exists';
|
||||
END;
|
||||
CREATE TABLE IF NOT EXISTS user_viewed_sessions
|
||||
CREATE TABLE IF NOT EXISTS public.user_viewed_sessions
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (user_id, session_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_favorite_sessions
|
||||
CREATE TABLE IF NOT EXISTS public.user_favorite_sessions
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (user_id, session_id)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON public.user_favorite_sessions (user_id, session_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS frontend_signals
|
||||
CREATE TABLE IF NOT EXISTS public.frontend_signals
|
||||
(
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
action text NOT NULL,
|
||||
source text NOT NULL,
|
||||
category text NOT NULL,
|
||||
data jsonb NULL,
|
||||
session_id integer NULL REFERENCES sessions (session_id) ON DELETE SET NULL,
|
||||
session_id integer NULL REFERENCES public.sessions (session_id) ON DELETE SET NULL,
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now())
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS frontend_signals_user_id_idx ON frontend_signals (user_id);
|
||||
CREATE INDEX IF NOT EXISTS frontend_signals_user_id_idx ON public.frontend_signals (user_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS assigned_sessions
|
||||
CREATE TABLE IF NOT EXISTS public.assigned_sessions
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
issue_id text NOT NULL,
|
||||
provider oauth_provider NOT NULL,
|
||||
created_by integer NOT NULL,
|
||||
created_at timestamp DEFAULT timezone('utc'::text, now()) NOT NULL,
|
||||
provider_data jsonb DEFAULT'{}'::jsonb NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS assigned_sessions_session_id_idx ON assigned_sessions (session_id);
|
||||
CREATE INDEX IF NOT EXISTS assigned_sessions_session_id_idx ON public.assigned_sessions (session_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS autocomplete
|
||||
CREATE TABLE IF NOT EXISTS public.autocomplete
|
||||
(
|
||||
value text NOT NULL,
|
||||
type text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS autocomplete_unique_project_id_md5value_type_idx ON autocomplete (project_id, md5(value), type);
|
||||
CREATE INDEX IF NOT EXISTS autocomplete_project_id_idx ON autocomplete (project_id);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS autocomplete_unique_project_id_md5value_type_idx ON public.autocomplete (project_id, md5(value), type);
|
||||
CREATE INDEX IF NOT EXISTS autocomplete_project_id_idx ON public.autocomplete (project_id);
|
||||
CREATE INDEX IF NOT EXISTS autocomplete_type_idx ON public.autocomplete (type);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS autocomplete_value_clickonly_gin_idx ON public.autocomplete USING GIN (value gin_trgm_ops) WHERE type = 'CLICK';
|
||||
|
|
@ -713,12 +713,12 @@ $$
|
|||
CREATE TYPE job_action AS ENUM ('delete_user_data');
|
||||
END IF;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS jobs
|
||||
CREATE TABLE IF NOT EXISTS public.jobs
|
||||
(
|
||||
job_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
description text NOT NULL,
|
||||
status job_status NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
action job_action NOT NULL,
|
||||
reference_id text NOT NULL,
|
||||
created_at timestamp DEFAULT timezone('utc'::text, now()) NOT NULL,
|
||||
|
|
@ -726,15 +726,15 @@ $$
|
|||
start_at timestamp NOT NULL,
|
||||
errors text NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS jobs_status_idx ON jobs (status);
|
||||
CREATE INDEX IF NOT EXISTS jobs_start_at_idx ON jobs (start_at);
|
||||
CREATE INDEX IF NOT EXISTS jobs_project_id_idx ON jobs (project_id);
|
||||
CREATE INDEX IF NOT EXISTS jobs_status_idx ON public.jobs (status);
|
||||
CREATE INDEX IF NOT EXISTS jobs_start_at_idx ON public.jobs (start_at);
|
||||
CREATE INDEX IF NOT EXISTS jobs_project_id_idx ON public.jobs (project_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS traces
|
||||
CREATE TABLE IF NOT EXISTS public.traces
|
||||
(
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
tenant_id integer NOT NULL REFERENCES tenants (tenant_id) ON DELETE CASCADE,
|
||||
user_id integer NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
tenant_id integer NOT NULL REFERENCES public.tenants (tenant_id) ON DELETE CASCADE,
|
||||
created_at bigint NOT NULL DEFAULT (EXTRACT(EPOCH FROM now() at time zone 'utc') * 1000)::bigint,
|
||||
auth text NULL,
|
||||
action text NOT NULL,
|
||||
|
|
@ -745,16 +745,16 @@ $$
|
|||
parameters jsonb NULL,
|
||||
status int NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS traces_user_id_idx ON traces (user_id);
|
||||
CREATE INDEX IF NOT EXISTS traces_tenant_id_idx ON traces (tenant_id);
|
||||
CREATE INDEX IF NOT EXISTS traces_created_at_idx ON traces (created_at);
|
||||
CREATE INDEX IF NOT EXISTS traces_action_idx ON traces (action);
|
||||
CREATE INDEX IF NOT EXISTS traces_user_id_idx ON public.traces (user_id);
|
||||
CREATE INDEX IF NOT EXISTS traces_tenant_id_idx ON public.traces (tenant_id);
|
||||
CREATE INDEX IF NOT EXISTS traces_created_at_idx ON public.traces (created_at);
|
||||
CREATE INDEX IF NOT EXISTS traces_action_idx ON public.traces (action);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS metrics
|
||||
CREATE TABLE IF NOT EXISTS public.metrics
|
||||
(
|
||||
metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
project_id integer NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT TRUE,
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
|
|
@ -772,13 +772,14 @@ $$
|
|||
"row": 2,
|
||||
"position": 0
|
||||
}'::jsonb,
|
||||
data jsonb NULL
|
||||
data jsonb NULL,
|
||||
card_info jsonb NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS metrics_user_id_is_public_idx ON public.metrics (user_id, is_public);
|
||||
CREATE TABLE IF NOT EXISTS metric_series
|
||||
CREATE TABLE IF NOT EXISTS public.metric_series
|
||||
(
|
||||
series_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
metric_id integer REFERENCES metrics (metric_id) ON DELETE CASCADE,
|
||||
metric_id integer REFERENCES public.metrics (metric_id) ON DELETE CASCADE,
|
||||
index integer NOT NULL,
|
||||
name text NULL,
|
||||
filter jsonb NOT NULL,
|
||||
|
|
@ -791,8 +792,8 @@ $$
|
|||
CREATE TABLE dashboards
|
||||
(
|
||||
dashboard_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
description text NOT NULL DEFAULT '',
|
||||
is_public boolean NOT NULL DEFAULT TRUE,
|
||||
|
|
@ -804,19 +805,19 @@ $$
|
|||
CREATE TABLE dashboard_widgets
|
||||
(
|
||||
widget_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
dashboard_id integer NOT NULL REFERENCES dashboards (dashboard_id) ON DELETE CASCADE,
|
||||
metric_id integer NOT NULL REFERENCES metrics (metric_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
dashboard_id integer NOT NULL REFERENCES public.dashboards (dashboard_id) ON DELETE CASCADE,
|
||||
metric_id integer NOT NULL REFERENCES public.metrics (metric_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
config jsonb NOT NULL DEFAULT '{}'::jsonb
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS searches
|
||||
CREATE TABLE IF NOT EXISTS public.searches
|
||||
(
|
||||
search_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
filter jsonb NOT NULL,
|
||||
created_at timestamp DEFAULT timezone('utc'::text, now()) NOT NULL,
|
||||
|
|
@ -839,11 +840,11 @@ $$
|
|||
CREATE TYPE alert_change_type AS ENUM ('percent', 'change');
|
||||
END IF;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS alerts
|
||||
CREATE TABLE IF NOT EXISTS public.alerts
|
||||
(
|
||||
alert_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
series_id integer NULL REFERENCES metric_series (series_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
series_id integer NULL REFERENCES public.metric_series (series_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
description text NULL DEFAULT NULL,
|
||||
active boolean NOT NULL DEFAULT TRUE,
|
||||
|
|
@ -856,27 +857,27 @@ $$
|
|||
"renotifyInterval": 1440
|
||||
}'::jsonb
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS alerts_project_id_idx ON alerts (project_id);
|
||||
CREATE INDEX IF NOT EXISTS alerts_series_id_idx ON alerts (series_id);
|
||||
CREATE INDEX IF NOT EXISTS alerts_project_id_idx ON public.alerts (project_id);
|
||||
CREATE INDEX IF NOT EXISTS alerts_series_id_idx ON public.alerts (series_id);
|
||||
|
||||
DROP TRIGGER IF EXISTS on_insert_or_update_or_delete ON alerts;
|
||||
DROP TRIGGER IF EXISTS on_insert_or_update_or_delete ON public.alerts;
|
||||
|
||||
CREATE TRIGGER on_insert_or_update_or_delete
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON alerts
|
||||
ON public.alerts
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_alert();
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sessions_notes
|
||||
CREATE TABLE IF NOT EXISTS public.sessions_notes
|
||||
(
|
||||
note_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
message text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL DEFAULT (now() at time zone 'utc'),
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
user_id integer NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
tag text NULL,
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
timestamp integer NOT NULL DEFAULT -1,
|
||||
is_public boolean NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
|
@ -884,9 +885,9 @@ $$
|
|||
CREATE TABLE IF NOT EXISTS public.assist_records
|
||||
(
|
||||
record_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE SET NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE SET NULL,
|
||||
created_at bigint NOT NULL DEFAULT (EXTRACT(EPOCH FROM now() at time zone 'utc') * 1000)::bigint,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -909,15 +910,15 @@ $$
|
|||
CREATE TABLE IF NOT EXISTS public.feature_flags
|
||||
(
|
||||
feature_flag_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
flag_key text NOT NULL,
|
||||
description text DEFAULT NULL,
|
||||
payload jsonb DEFAULT NULL,
|
||||
flag_type text NOT NULL,
|
||||
is_persist boolean NOT NULL DEFAULT FALSE,
|
||||
is_active boolean NOT NULL DEFAULT FALSE,
|
||||
created_by integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
updated_by integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
created_by integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
updated_by integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
created_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
updated_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
|
|
@ -931,7 +932,7 @@ $$
|
|||
CREATE TABLE IF NOT EXISTS public.feature_flags_conditions
|
||||
(
|
||||
condition_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
feature_flag_id integer NOT NULL REFERENCES public.feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
rollout_percentage integer NOT NULL,
|
||||
filters jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
|
|
@ -940,7 +941,7 @@ $$
|
|||
CREATE TABLE IF NOT EXISTS public.feature_flags_variants
|
||||
(
|
||||
variant_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
feature_flag_id integer NOT NULL REFERENCES public.feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
value text NOT NULL,
|
||||
description text DEFAULT NULL,
|
||||
payload jsonb DEFAULT NULL,
|
||||
|
|
@ -949,15 +950,15 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS public.sessions_feature_flags
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
condition_id integer NULL REFERENCES feature_flags_conditions (condition_id) ON DELETE SET NULL
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
feature_flag_id integer NOT NULL REFERENCES public.feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
condition_id integer NULL REFERENCES public.feature_flags_conditions (condition_id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.crashes_ios
|
||||
(
|
||||
crash_ios_id text NOT NULL PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
reason text NOT NULL,
|
||||
stacktrace text NOT NULL
|
||||
|
|
@ -993,7 +994,7 @@ $$
|
|||
ELSE
|
||||
CREATE TABLE IF NOT EXISTS events.pages
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
host text NOT NULL,
|
||||
|
|
@ -1051,7 +1052,7 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events.clicks
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
label text DEFAULT NULL,
|
||||
|
|
@ -1078,7 +1079,7 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events.inputs
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
label text DEFAULT NULL,
|
||||
|
|
@ -1094,10 +1095,10 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events.errors
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES public.errors (error_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, message_id)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS errors_session_id_idx ON events.errors (session_id);
|
||||
|
|
@ -1113,15 +1114,15 @@ $$
|
|||
key text NOT NULL,
|
||||
value text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES public.errors (error_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL,
|
||||
message_id bigint NOT NULL,
|
||||
FOREIGN KEY (session_id, message_id) REFERENCES events.errors (session_id, message_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON errors_tags (error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_session_id_idx ON errors_tags (session_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_message_id_idx ON errors_tags (message_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON public.errors_tags (error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_session_id_idx ON public.errors_tags (session_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_message_id_idx ON public.errors_tags (message_id);
|
||||
|
||||
IF NOT EXISTS(SELECT *
|
||||
FROM pg_type typ
|
||||
|
|
@ -1130,7 +1131,7 @@ $$
|
|||
END IF;
|
||||
CREATE TABLE IF NOT EXISTS events.graphql
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -1149,7 +1150,7 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events.state_actions
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -1170,7 +1171,7 @@ $$
|
|||
END IF;
|
||||
CREATE TABLE IF NOT EXISTS events.resources
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
duration bigint NULL,
|
||||
|
|
@ -1206,7 +1207,7 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events.performance
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
message_id bigint NOT NULL,
|
||||
host text NULL DEFAULT NULL,
|
||||
|
|
@ -1258,7 +1259,7 @@ $$
|
|||
END IF;
|
||||
CREATE TABLE IF NOT EXISTS events_common.customs
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -1273,10 +1274,10 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_common.issues
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
issue_id text NOT NULL REFERENCES issues (issue_id) ON DELETE CASCADE,
|
||||
issue_id text NOT NULL REFERENCES public.issues (issue_id) ON DELETE CASCADE,
|
||||
payload jsonb DEFAULT NULL,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
|
|
@ -1290,7 +1291,7 @@ $$
|
|||
END IF;
|
||||
CREATE TABLE IF NOT EXISTS events_common.requests
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
url text NOT NULL,
|
||||
|
|
@ -1322,7 +1323,7 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_common.crashes
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
crash_ios_id text NULL REFERENCES public.crashes_ios (crash_ios_id) ON DELETE CASCADE,
|
||||
|
|
@ -1352,7 +1353,7 @@ $$
|
|||
ELSE
|
||||
CREATE TABLE IF NOT EXISTS events_ios.views
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -1361,7 +1362,7 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.taps
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
@ -1377,7 +1378,7 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.inputs
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
@ -1390,7 +1391,7 @@ $$
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.swipes
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ ALTER TABLE IF EXISTS public.sessions
|
|||
|
||||
COMMIT;
|
||||
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_project_id_user_city_idx ON sessions (project_id, user_city);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_project_id_user_state_idx ON sessions (project_id, user_state);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_project_id_user_city_idx ON public.sessions (project_id, user_city);
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS sessions_project_id_user_state_idx ON public.sessions (project_id, user_state);
|
||||
|
||||
\elif :is_next
|
||||
\echo new version detected :'next_version', nothing to do
|
||||
|
|
|
|||
|
|
@ -22,15 +22,15 @@ $fn_def$, :'next_version')
|
|||
CREATE TABLE IF NOT EXISTS public.feature_flags
|
||||
(
|
||||
feature_flag_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
flag_key text NOT NULL,
|
||||
description text DEFAULT NULL,
|
||||
payload jsonb DEFAULT NULL,
|
||||
flag_type text NOT NULL,
|
||||
is_persist boolean NOT NULL DEFAULT FALSE,
|
||||
is_active boolean NOT NULL DEFAULT FALSE,
|
||||
created_by integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
updated_by integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
created_by integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
updated_by integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
created_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
updated_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
|
|
@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS public.feature_flags_variants
|
|||
|
||||
CREATE TABLE IF NOT EXISTS public.sessions_feature_flags
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
condition_id integer NULL REFERENCES feature_flags_conditions (condition_id) ON DELETE SET NULL
|
||||
);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ ALTER TABLE IF EXISTS public.projects
|
|||
CREATE TABLE IF NOT EXISTS public.crashes_ios
|
||||
(
|
||||
crash_ios_id text NOT NULL PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
reason text NOT NULL,
|
||||
stacktrace text NOT NULL
|
||||
|
|
@ -40,7 +40,7 @@ CREATE INDEX IF NOT EXISTS crashes_ios_project_id_idx ON public.crashes_ios (pro
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_common.crashes
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
crash_ios_id text NULL REFERENCES public.crashes_ios (crash_ios_id) ON DELETE CASCADE,
|
||||
|
|
@ -54,7 +54,7 @@ CREATE SCHEMA IF NOT EXISTS events_ios;
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.views
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -63,7 +63,7 @@ CREATE TABLE IF NOT EXISTS events_ios.views
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.taps
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
@ -79,7 +79,7 @@ CREATE INDEX IF NOT EXISTS taps_session_id_timestamp_idx ON events_ios.taps (ses
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.inputs
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
@ -93,7 +93,7 @@ CREATE INDEX IF NOT EXISTS inputs_label_session_id_timestamp_idx ON events_ios.i
|
|||
|
||||
CREATE TABLE IF NOT EXISTS events_ios.swipes
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
@ -115,6 +115,9 @@ ALTER TABLE IF EXISTS events.clicks
|
|||
ADD COLUMN IF NOT EXISTS x integer DEFAULT NULL,
|
||||
ADD COLUMN IF NOT EXISTS y integer DEFAULT NULL;
|
||||
|
||||
ALTER TABLE IF EXISTS public.metrics
|
||||
ADD COLUMN IF NOT EXISTS card_info jsonb NULL;
|
||||
|
||||
COMMIT;
|
||||
|
||||
\elif :is_next
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ CREATE INDEX pages_dom_content_loaded_time_idx ON events.pages (dom_content_load
|
|||
CREATE INDEX pages_first_paint_time_idx ON events.pages (first_paint_time) WHERE first_paint_time > 0;
|
||||
CREATE INDEX pages_ttfb_idx ON events.pages (ttfb) WHERE ttfb > 0;
|
||||
CREATE INDEX pages_time_to_interactive_idx ON events.pages (time_to_interactive) WHERE time_to_interactive > 0;
|
||||
CREATE INDEX sessions_session_id_project_id_start_ts_idx ON sessions (session_id, project_id, start_ts) WHERE duration > 0;
|
||||
CREATE INDEX sessions_session_id_project_id_start_ts_idx ON public.sessions (session_id, project_id, start_ts) WHERE duration > 0;
|
||||
CREATE INDEX pages_session_id_timestamp_loadgt0NN_idx ON events.pages (session_id, timestamp) WHERE load_time > 0 AND load_time IS NOT NULL;
|
||||
DROP INDEX events.resources_type_idx;
|
||||
CREATE INDEX resources_timestamp_type_durationgt0NN_idx ON events.resources (timestamp, type) WHERE duration > 0 AND duration IS NOT NULL;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
BEGIN;
|
||||
CREATE INDEX sessions_session_id_project_id_start_ts_durationNN_idx ON sessions (session_id, project_id, start_ts) WHERE duration IS NOT NULL;
|
||||
CREATE INDEX sessions_session_id_project_id_start_ts_durationNN_idx ON public.sessions (session_id, project_id, start_ts) WHERE duration IS NOT NULL;
|
||||
CREATE INDEX clicks_label_session_id_timestamp_idx ON events.clicks (label, session_id, timestamp);
|
||||
CREATE INDEX pages_base_path_session_id_timestamp_idx ON events.pages (base_path, session_id, timestamp);
|
||||
CREATE INDEX ON assigned_sessions (session_id);
|
||||
CREATE INDEX ON public.assigned_sessions (session_id);
|
||||
CREATE INDEX inputs_label_session_id_timestamp_idx ON events.inputs (label, session_id, timestamp);
|
||||
|
||||
ALTER TABLE events.clicks
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
BEGIN;
|
||||
CREATE INDEX pages_session_id_timestamp_idx ON events.pages (session_id, timestamp);
|
||||
|
||||
CREATE INDEX issues_project_id_idx ON issues (project_id);
|
||||
CREATE INDEX jobs_project_id_idx ON jobs (project_id);
|
||||
CREATE INDEX issues_project_id_idx ON public.issues (project_id);
|
||||
CREATE INDEX jobs_project_id_idx ON public.jons (project_id);
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
BEGIN;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS sessions_user_id_useridNN_idx ON sessions (user_id) WHERE user_id IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS sessions_uid_projectid_startts_sessionid_uidNN_durGTZ_idx ON sessions (user_id, project_id, start_ts, session_id) WHERE user_id IS NOT NULL AND duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS sessions_user_id_useridNN_idx ON public.sessions (user_id) WHERE user_id IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS sessions_uid_projectid_startts_sessionid_uidNN_durGTZ_idx ON public.sessions (user_id, project_id, start_ts, session_id) WHERE user_id IS NOT NULL AND duration > 0;
|
||||
CREATE INDEX IF NOT EXISTS pages_base_path_base_pathLNGT2_idx ON events.pages (base_path) WHERE length(base_path) > 2;
|
||||
|
||||
|
||||
CREATE INDEX IF NOT EXISTS clicks_session_id_timestamp_idx ON events.clicks (session_id, timestamp);
|
||||
CREATE INDEX IF NOT EXISTS errors_error_id_idx ON errors (error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_error_id_idx ON public.errors (error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_error_id_idx ON events.errors (error_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS issues_issue_id_timestamp_idx ON events_common.issues(issue_id,timestamp);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ $$
|
|||
SELECT 'v1.4.0'
|
||||
$$ LANGUAGE sql IMMUTABLE;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON public.user_favorite_sessions (user_id, session_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pages_session_id_timestamp_idx ON events.pages (session_id, timestamp);
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ DROP INDEX IF EXISTS sessions_project_id_user_country_idx1;
|
|||
ALTER INDEX IF EXISTS platform_idx RENAME TO sessions_platform_idx;
|
||||
ALTER INDEX IF EXISTS events.resources_duration_idx RENAME TO resources_duration_durationgt0_idx;
|
||||
DROP INDEX IF EXISTS projects_project_key_idx1;
|
||||
CREATE INDEX IF NOT EXISTS errors_parent_error_id_idx ON errors (parent_error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_parent_error_id_idx ON public.errors (parent_error_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS performance_session_id_idx ON events.performance (session_id);
|
||||
CREATE INDEX IF NOT EXISTS performance_timestamp_idx ON events.performance (timestamp);
|
||||
|
|
@ -36,21 +36,21 @@ CREATE INDEX IF NOT EXISTS performance_session_id_timestamp_idx ON events.perfor
|
|||
CREATE INDEX IF NOT EXISTS performance_avg_cpu_gt0_idx ON events.performance (avg_cpu) WHERE avg_cpu > 0;
|
||||
CREATE INDEX IF NOT EXISTS performance_avg_used_js_heap_size_gt0_idx ON events.performance (avg_used_js_heap_size) WHERE avg_used_js_heap_size > 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS metrics
|
||||
CREATE TABLE IF NOT EXISTS public.metrics
|
||||
(
|
||||
metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT FALSE,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
deleted_at timestamp
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS metrics_user_id_is_public_idx ON public.metrics (user_id, is_public);
|
||||
CREATE TABLE IF NOT EXISTS metric_series
|
||||
CREATE TABLE IF NOT EXISTS public.metric_series
|
||||
(
|
||||
series_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
metric_id integer REFERENCES metrics (metric_id) ON DELETE CASCADE,
|
||||
metric_id integer REFERENCES public.metrics (metric_id) ON DELETE CASCADE,
|
||||
index integer NOT NULL,
|
||||
name text NULL,
|
||||
filter jsonb NOT NULL,
|
||||
|
|
@ -62,11 +62,11 @@ CREATE INDEX IF NOT EXISTS metric_series_metric_id_idx ON public.metric_series (
|
|||
CREATE INDEX IF NOT EXISTS funnels_project_id_idx ON public.funnels (project_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS searches
|
||||
CREATE TABLE IF NOT EXISTS public.searches
|
||||
(
|
||||
search_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
name text not null,
|
||||
filter jsonb not null,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
|
|
@ -79,7 +79,7 @@ CREATE INDEX IF NOT EXISTS searches_project_id_idx ON public.searches (project_i
|
|||
CREATE INDEX IF NOT EXISTS alerts_project_id_idx ON alerts (project_id);
|
||||
|
||||
ALTER TABLE alerts
|
||||
ADD COLUMN IF NOT EXISTS series_id integer NULL REFERENCES metric_series (series_id) ON DELETE CASCADE;
|
||||
ADD COLUMN IF NOT EXISTS series_id integer NULL REFERENCES public.metric_series (series_id) ON DELETE CASCADE;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS alerts_series_id_idx ON alerts (series_id);
|
||||
UPDATE alerts
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ $fn_def$, :'next_version')
|
|||
\gexec
|
||||
|
||||
--
|
||||
CREATE INDEX IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX IF NOT EXISTS user_favorite_sessions_user_id_session_id_idx ON public.user_favorite_sessions (user_id, session_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pages_session_id_timestamp_idx ON events.pages (session_id, timestamp);
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ DROP INDEX IF EXISTS sessions_project_id_user_country_idx1;
|
|||
ALTER INDEX IF EXISTS platform_idx RENAME TO sessions_platform_idx;
|
||||
ALTER INDEX IF EXISTS events.resources_duration_idx RENAME TO resources_duration_durationgt0_idx;
|
||||
DROP INDEX IF EXISTS projects_project_key_idx1;
|
||||
CREATE INDEX IF NOT EXISTS errors_parent_error_id_idx ON errors (parent_error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_parent_error_id_idx ON public.errors (parent_error_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS performance_session_id_idx ON events.performance (session_id);
|
||||
CREATE INDEX IF NOT EXISTS performance_timestamp_idx ON events.performance (timestamp);
|
||||
|
|
@ -49,21 +49,21 @@ CREATE INDEX IF NOT EXISTS performance_session_id_timestamp_idx ON events.perfor
|
|||
CREATE INDEX IF NOT EXISTS performance_avg_cpu_gt0_idx ON events.performance (avg_cpu) WHERE avg_cpu > 0;
|
||||
CREATE INDEX IF NOT EXISTS performance_avg_used_js_heap_size_gt0_idx ON events.performance (avg_used_js_heap_size) WHERE avg_used_js_heap_size > 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS metrics
|
||||
CREATE TABLE IF NOT EXISTS public.metrics
|
||||
(
|
||||
metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT FALSE,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
deleted_at timestamp
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS metrics_user_id_is_public_idx ON public.metrics (user_id, is_public);
|
||||
CREATE TABLE IF NOT EXISTS metric_series
|
||||
CREATE TABLE IF NOT EXISTS public.metric_series
|
||||
(
|
||||
series_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
metric_id integer REFERENCES metrics (metric_id) ON DELETE CASCADE,
|
||||
metric_id integer REFERENCES public.metrics (metric_id) ON DELETE CASCADE,
|
||||
index integer NOT NULL,
|
||||
name text NULL,
|
||||
filter jsonb NOT NULL,
|
||||
|
|
@ -75,11 +75,11 @@ CREATE INDEX IF NOT EXISTS metric_series_metric_id_idx ON public.metric_series (
|
|||
CREATE INDEX IF NOT EXISTS funnels_project_id_idx ON public.funnels (project_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS searches
|
||||
CREATE TABLE IF NOT EXISTS public.searches
|
||||
(
|
||||
search_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
name text not null,
|
||||
filter jsonb not null,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
|
|
@ -92,7 +92,7 @@ CREATE INDEX IF NOT EXISTS searches_project_id_idx ON public.searches (project_i
|
|||
CREATE INDEX IF NOT EXISTS alerts_project_id_idx ON alerts (project_id);
|
||||
|
||||
ALTER TABLE alerts
|
||||
ADD COLUMN IF NOT EXISTS series_id integer NULL REFERENCES metric_series (series_id) ON DELETE CASCADE;
|
||||
ADD COLUMN IF NOT EXISTS series_id integer NULL REFERENCES public.metric_series (series_id) ON DELETE CASCADE;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS alerts_series_id_idx ON alerts (series_id);
|
||||
UPDATE alerts
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ $fn_def$, :'next_version')
|
|||
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS dashboards
|
||||
CREATE TABLE IF NOT EXISTS public.dashboards
|
||||
(
|
||||
dashboard_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT TRUE,
|
||||
is_pinned boolean NOT NULL DEFAULT FALSE,
|
||||
|
|
@ -55,12 +55,12 @@ ALTER TABLE IF EXISTS metrics
|
|||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS dashboard_widgets
|
||||
CREATE TABLE IF NOT EXISTS public.dashboard_widgets
|
||||
(
|
||||
widget_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
dashboard_id integer NOT NULL REFERENCES dashboards (dashboard_id) ON DELETE CASCADE,
|
||||
metric_id integer NOT NULL REFERENCES metrics (metric_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
dashboard_id integer NOT NULL REFERENCES public.dashboards (dashboard_id) ON DELETE CASCADE,
|
||||
metric_id integer NOT NULL REFERENCES public.metrics (metric_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
config jsonb NOT NULL DEFAULT '{}'::jsonb
|
||||
);
|
||||
|
|
|
|||
|
|
@ -23,34 +23,34 @@ ALTER TABLE IF EXISTS public.tenants
|
|||
ADD COLUMN IF NOT EXISTS last_telemetry bigint NOT NULL DEFAULT CAST(EXTRACT(epoch FROM date_trunc('day', now())) * 1000 AS BIGINT),
|
||||
DROP COLUMN IF EXISTS version_number;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sessions_notes
|
||||
CREATE TABLE IF NOT EXISTS public.sessions_notes
|
||||
(
|
||||
note_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
message text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
user_id integer NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
tag text NULL,
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
timestamp integer NOT NULL DEFAULT -1,
|
||||
is_public boolean NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS errors_tags
|
||||
CREATE TABLE IF NOT EXISTS public.errors_tags
|
||||
(
|
||||
key text NOT NULL,
|
||||
value text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES public.errors (error_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL,
|
||||
message_id bigint NOT NULL,
|
||||
FOREIGN KEY (session_id, message_id) REFERENCES events.errors (session_id, message_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON errors_tags (error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_session_id_idx ON errors_tags (session_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_message_id_idx ON errors_tags (message_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON public.errors_tags (error_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_session_id_idx ON public.errors_tags (session_id);
|
||||
CREATE INDEX IF NOT EXISTS errors_tags_message_id_idx ON public.errors_tags (message_id);
|
||||
|
||||
UPDATE metrics
|
||||
SET default_config=default_config || '{"col":4}'
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ $$
|
|||
raise notice 'Creating DB';
|
||||
|
||||
|
||||
CREATE TABLE tenants
|
||||
CREATE TABLE public.tenants
|
||||
(
|
||||
tenant_id integer NOT NULL DEFAULT 1,
|
||||
tenant_key text NOT NULL DEFAULT generate_api_key(20),
|
||||
|
|
@ -128,7 +128,7 @@ $$
|
|||
|
||||
CREATE TYPE user_role AS ENUM ('owner', 'admin', 'member');
|
||||
|
||||
CREATE TABLE users
|
||||
CREATE TABLE public.users
|
||||
(
|
||||
user_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
email text NOT NULL UNIQUE,
|
||||
|
|
@ -144,9 +144,9 @@ $$
|
|||
weekly_report boolean NOT NULL DEFAULT TRUE
|
||||
);
|
||||
|
||||
CREATE TABLE basic_authentication
|
||||
CREATE TABLE public.basic_authentication
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
password text DEFAULT NULL,
|
||||
invitation_token text NULL DEFAULT NULL,
|
||||
invited_at timestamp without time zone NULL DEFAULT NULL,
|
||||
|
|
@ -157,18 +157,18 @@ $$
|
|||
);
|
||||
|
||||
CREATE TYPE oauth_provider AS ENUM ('jira', 'github');
|
||||
CREATE TABLE oauth_authentication
|
||||
CREATE TABLE public.oauth_authentication
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
provider oauth_provider NOT NULL,
|
||||
provider_user_id text NOT NULL,
|
||||
token text NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX oauth_authentication_unique_user_id_provider_idx ON oauth_authentication (user_id, provider);
|
||||
CREATE UNIQUE INDEX oauth_authentication_unique_user_id_provider_idx ON public.oauth_authentication (user_id, provider);
|
||||
|
||||
CREATE TYPE platform AS ENUM ('web','ios','android');
|
||||
|
||||
CREATE TABLE projects
|
||||
CREATE TABLE public.projects
|
||||
(
|
||||
project_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_key varchar(20) NOT NULL UNIQUE DEFAULT generate_api_key(20),
|
||||
|
|
@ -206,14 +206,14 @@ $$
|
|||
|
||||
CREATE TRIGGER on_insert_or_update
|
||||
AFTER INSERT OR UPDATE
|
||||
ON projects
|
||||
ON public.projects
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_project();
|
||||
|
||||
|
||||
CREATE TYPE webhook_type AS ENUM ('webhook', 'slack', 'email', 'msteams');
|
||||
|
||||
CREATE TABLE webhooks
|
||||
CREATE TABLE public.webhooks
|
||||
(
|
||||
webhook_id integer generated by DEFAULT as identity
|
||||
constraint webhooks_pkey
|
||||
|
|
@ -228,10 +228,10 @@ $$
|
|||
);
|
||||
|
||||
|
||||
CREATE TABLE notifications
|
||||
CREATE TABLE public.notifications
|
||||
(
|
||||
notification_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
title text NOT NULL,
|
||||
description text NOT NULL,
|
||||
button_text varchar(80) NULL,
|
||||
|
|
@ -241,21 +241,21 @@ $$
|
|||
options jsonb NOT NULL DEFAULT '{}'::jsonb
|
||||
);
|
||||
|
||||
CREATE INDEX notifications_user_id_index ON notifications (user_id);
|
||||
CREATE INDEX notifications_created_at_index ON notifications (created_at DESC);
|
||||
CREATE INDEX notifications_created_at_epoch_idx ON notifications (CAST(EXTRACT(EPOCH FROM created_at) * 1000 AS BIGINT) DESC);
|
||||
CREATE INDEX notifications_user_id_index ON public.notifications (user_id);
|
||||
CREATE INDEX notifications_created_at_index ON public.notifications (created_at DESC);
|
||||
CREATE INDEX notifications_created_at_epoch_idx ON public.notifications (CAST(EXTRACT(EPOCH FROM created_at) * 1000 AS BIGINT) DESC);
|
||||
|
||||
CREATE TABLE user_viewed_notifications
|
||||
CREATE TABLE public.user_viewed_notifications
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) on delete cascade,
|
||||
notification_id integer NOT NULL REFERENCES notifications (notification_id) on delete cascade,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) on delete cascade,
|
||||
notification_id integer NOT NULL REFERENCES public.notifications (notification_id) on delete cascade,
|
||||
constraint user_viewed_notifications_pkey primary key (user_id, notification_id)
|
||||
);
|
||||
|
||||
|
||||
CREATE TYPE announcement_type AS ENUM ('notification', 'alert');
|
||||
|
||||
CREATE TABLE announcements
|
||||
CREATE TABLE public.announcements
|
||||
(
|
||||
announcement_id serial NOT NULL
|
||||
constraint announcements_pk
|
||||
|
|
@ -271,9 +271,9 @@ $$
|
|||
|
||||
|
||||
CREATE TYPE integration_provider AS ENUM ('bugsnag', 'cloudwatch', 'datadog', 'newrelic', 'rollbar', 'sentry', 'stackdriver', 'sumologic', 'elasticsearch'); --, 'jira', 'github');
|
||||
CREATE TABLE integrations
|
||||
CREATE TABLE public.integrations
|
||||
(
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
provider integration_provider NOT NULL,
|
||||
options jsonb NOT NULL,
|
||||
request_data jsonb NOT NULL DEFAULT '{}'::jsonb,
|
||||
|
|
@ -282,18 +282,18 @@ $$
|
|||
|
||||
CREATE TRIGGER on_insert_or_update_or_delete
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON integrations
|
||||
ON public.integrations
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_integration();
|
||||
|
||||
|
||||
CREATE TABLE jira_cloud
|
||||
CREATE TABLE public.jira_cloud
|
||||
(
|
||||
user_id integer NOT NULL
|
||||
constraint jira_cloud_pk
|
||||
primary key
|
||||
constraint jira_cloud_users_fkey
|
||||
references users
|
||||
REFERENCES public.users
|
||||
on delete cascade,
|
||||
username text NOT NULL,
|
||||
token text NOT NULL,
|
||||
|
|
@ -326,35 +326,35 @@ $$
|
|||
'app_crash'
|
||||
);
|
||||
|
||||
CREATE TABLE issues
|
||||
CREATE TABLE public.issues
|
||||
(
|
||||
issue_id text NOT NULL PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
type issue_type NOT NULL,
|
||||
context_string text NOT NULL,
|
||||
context jsonb DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX issues_issue_id_type_idx ON issues (issue_id, type);
|
||||
CREATE INDEX issues_issue_id_type_idx ON public.issues (issue_id, type);
|
||||
CREATE INDEX issues_project_id_issue_id_idx ON public.issues (project_id, issue_id);
|
||||
CREATE INDEX issues_project_id_idx ON issues (project_id);
|
||||
CREATE INDEX issues_project_id_idx ON public.issues (project_id);
|
||||
|
||||
|
||||
CREATE TYPE error_source AS ENUM ('js_exception', 'bugsnag', 'cloudwatch', 'datadog', 'newrelic', 'rollbar', 'sentry', 'stackdriver', 'sumologic', 'elasticsearch');
|
||||
CREATE TYPE error_status AS ENUM ('unresolved', 'resolved', 'ignored');
|
||||
CREATE TABLE errors
|
||||
CREATE TABLE public.errors
|
||||
(
|
||||
error_id text NOT NULL PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
source error_source NOT NULL,
|
||||
name text DEFAULT NULL,
|
||||
message text NOT NULL,
|
||||
payload jsonb NOT NULL,
|
||||
status error_status NOT NULL DEFAULT 'unresolved',
|
||||
parent_error_id text DEFAULT NULL REFERENCES errors (error_id) ON DELETE SET NULL,
|
||||
parent_error_id text DEFAULT NULL REFERENCES public.errors (error_id) ON DELETE SET NULL,
|
||||
stacktrace jsonb, --to save the stacktrace and not query S3 another time
|
||||
stacktrace_parsed_at timestamp
|
||||
);
|
||||
CREATE INDEX errors_project_id_source_idx ON errors (project_id, source);
|
||||
CREATE INDEX errors_project_id_source_idx ON public.errors (project_id, source);
|
||||
CREATE INDEX errors_message_gin_idx ON public.errors USING GIN (message gin_trgm_ops);
|
||||
CREATE INDEX errors_name_gin_idx ON public.errors USING GIN (name gin_trgm_ops);
|
||||
CREATE INDEX errors_project_id_idx ON public.errors (project_id);
|
||||
|
|
@ -362,47 +362,47 @@ $$
|
|||
CREATE INDEX errors_project_id_error_id_js_exception_idx ON public.errors (project_id, error_id) WHERE source = 'js_exception';
|
||||
CREATE INDEX errors_project_id_error_id_idx ON public.errors (project_id, error_id);
|
||||
CREATE INDEX errors_project_id_error_id_integration_idx ON public.errors (project_id, error_id) WHERE source != 'js_exception';
|
||||
CREATE INDEX errors_error_id_idx ON errors (error_id);
|
||||
CREATE INDEX errors_parent_error_id_idx ON errors (parent_error_id);
|
||||
CREATE INDEX errors_error_id_idx ON public.errors (error_id);
|
||||
CREATE INDEX errors_parent_error_id_idx ON public.errors (parent_error_id);
|
||||
|
||||
CREATE TABLE user_favorite_errors
|
||||
CREATE TABLE public.user_favorite_errors
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES public.errors (error_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (user_id, error_id)
|
||||
);
|
||||
|
||||
CREATE TABLE user_viewed_errors
|
||||
CREATE TABLE public.user_viewed_errors
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES public.errors (error_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (user_id, error_id)
|
||||
);
|
||||
CREATE INDEX user_viewed_errors_user_id_idx ON public.user_viewed_errors (user_id);
|
||||
CREATE INDEX user_viewed_errors_error_id_idx ON public.user_viewed_errors (error_id);
|
||||
|
||||
CREATE TABLE errors_tags
|
||||
CREATE TABLE public.errors_tags
|
||||
(
|
||||
key text NOT NULL,
|
||||
value text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES public.errors (error_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL,
|
||||
message_id bigint NOT NULL,
|
||||
FOREIGN KEY (session_id, message_id) REFERENCES events.errors (session_id, message_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX errors_tags_error_id_idx ON errors_tags (error_id);
|
||||
CREATE INDEX errors_tags_session_id_idx ON errors_tags (session_id);
|
||||
CREATE INDEX errors_tags_message_id_idx ON errors_tags (message_id);
|
||||
CREATE INDEX errors_tags_error_id_idx ON public.errors_tags (error_id);
|
||||
CREATE INDEX errors_tags_session_id_idx ON public.errors_tags (session_id);
|
||||
CREATE INDEX errors_tags_message_id_idx ON public.errors_tags (message_id);
|
||||
|
||||
CREATE TYPE device_type AS ENUM ('desktop', 'tablet', 'mobile', 'other');
|
||||
CREATE TYPE country AS ENUM ('UN', 'RW', 'SO', 'YE', 'IQ', 'SA', 'IR', 'CY', 'TZ', 'SY', 'AM', 'KE', 'CD', 'DJ', 'UG', 'CF', 'SC', 'JO', 'LB', 'KW', 'OM', 'QA', 'BH', 'AE', 'IL', 'TR', 'ET', 'ER', 'EG', 'SD', 'GR', 'BI', 'EE', 'LV', 'AZ', 'LT', 'SJ', 'GE', 'MD', 'BY', 'FI', 'AX', 'UA', 'MK', 'HU', 'BG', 'AL', 'PL', 'RO', 'XK', 'ZW', 'ZM', 'KM', 'MW', 'LS', 'BW', 'MU', 'SZ', 'RE', 'ZA', 'YT', 'MZ', 'MG', 'AF', 'PK', 'BD', 'TM', 'TJ', 'LK', 'BT', 'IN', 'MV', 'IO', 'NP', 'MM', 'UZ', 'KZ', 'KG', 'TF', 'HM', 'CC', 'PW', 'VN', 'TH', 'ID', 'LA', 'TW', 'PH', 'MY', 'CN', 'HK', 'BN', 'MO', 'KH', 'KR', 'JP', 'KP', 'SG', 'CK', 'TL', 'RU', 'MN', 'AU', 'CX', 'MH', 'FM', 'PG', 'SB', 'TV', 'NR', 'VU', 'NC', 'NF', 'NZ', 'FJ', 'LY', 'CM', 'SN', 'CG', 'PT', 'LR', 'CI', 'GH', 'GQ', 'NG', 'BF', 'TG', 'GW', 'MR', 'BJ', 'GA', 'SL', 'ST', 'GI', 'GM', 'GN', 'TD', 'NE', 'ML', 'EH', 'TN', 'ES', 'MA', 'MT', 'DZ', 'FO', 'DK', 'IS', 'GB', 'CH', 'SE', 'NL', 'AT', 'BE', 'DE', 'LU', 'IE', 'MC', 'FR', 'AD', 'LI', 'JE', 'IM', 'GG', 'SK', 'CZ', 'NO', 'VA', 'SM', 'IT', 'SI', 'ME', 'HR', 'BA', 'AO', 'NA', 'SH', 'BV', 'BB', 'CV', 'GY', 'GF', 'SR', 'PM', 'GL', 'PY', 'UY', 'BR', 'FK', 'GS', 'JM', 'DO', 'CU', 'MQ', 'BS', 'BM', 'AI', 'TT', 'KN', 'DM', 'AG', 'LC', 'TC', 'AW', 'VG', 'VC', 'MS', 'MF', 'BL', 'GP', 'GD', 'KY', 'BZ', 'SV', 'GT', 'HN', 'NI', 'CR', 'VE', 'EC', 'CO', 'PA', 'HT', 'AR', 'CL', 'BO', 'PE', 'MX', 'PF', 'PN', 'KI', 'TK', 'TO', 'WF', 'WS', 'NU', 'MP', 'GU', 'PR', 'VI', 'UM', 'AS', 'CA', 'US', 'PS', 'RS', 'AQ', 'SX', 'CW', 'BQ', 'SS','AC','AN','BU','CP','CS','CT','DD','DG','DY','EA','FQ','FX','HV','IC','JT','MI','NH','NQ','NT','PC','PU','PZ','RH','SU','TA','TP','VD','WK','YD','YU','ZR');
|
||||
|
||||
CREATE TABLE sessions
|
||||
CREATE TABLE public.sessions
|
||||
(
|
||||
session_id bigint PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
tracker_version text NOT NULL,
|
||||
start_ts bigint NOT NULL,
|
||||
timezone text NULL,
|
||||
|
|
@ -447,25 +447,25 @@ $$
|
|||
metadata_9 text DEFAULT NULL,
|
||||
metadata_10 text DEFAULT NULL
|
||||
);
|
||||
CREATE INDEX sessions_project_id_start_ts_idx ON sessions (project_id, start_ts);
|
||||
CREATE INDEX sessions_project_id_user_id_idx ON sessions (project_id, user_id);
|
||||
CREATE INDEX sessions_project_id_user_anonymous_id_idx ON sessions (project_id, user_anonymous_id);
|
||||
CREATE INDEX sessions_project_id_user_device_idx ON sessions (project_id, user_device);
|
||||
CREATE INDEX sessions_project_id_user_country_idx ON sessions (project_id, user_country);
|
||||
CREATE INDEX sessions_project_id_user_city_idx ON sessions (project_id, user_city);
|
||||
CREATE INDEX sessions_project_id_user_state_idx ON sessions (project_id, user_state);
|
||||
CREATE INDEX sessions_project_id_user_browser_idx ON sessions (project_id, user_browser);
|
||||
CREATE INDEX sessions_project_id_metadata_1_idx ON sessions (project_id, metadata_1);
|
||||
CREATE INDEX sessions_project_id_metadata_2_idx ON sessions (project_id, metadata_2);
|
||||
CREATE INDEX sessions_project_id_metadata_3_idx ON sessions (project_id, metadata_3);
|
||||
CREATE INDEX sessions_project_id_metadata_4_idx ON sessions (project_id, metadata_4);
|
||||
CREATE INDEX sessions_project_id_metadata_5_idx ON sessions (project_id, metadata_5);
|
||||
CREATE INDEX sessions_project_id_metadata_6_idx ON sessions (project_id, metadata_6);
|
||||
CREATE INDEX sessions_project_id_metadata_7_idx ON sessions (project_id, metadata_7);
|
||||
CREATE INDEX sessions_project_id_metadata_8_idx ON sessions (project_id, metadata_8);
|
||||
CREATE INDEX sessions_project_id_metadata_9_idx ON sessions (project_id, metadata_9);
|
||||
CREATE INDEX sessions_project_id_metadata_10_idx ON sessions (project_id, metadata_10);
|
||||
CREATE INDEX sessions_project_id_watchdogs_score_idx ON sessions (project_id, watchdogs_score DESC);
|
||||
CREATE INDEX sessions_project_id_start_ts_idx ON public.sessions (project_id, start_ts);
|
||||
CREATE INDEX sessions_project_id_user_id_idx ON public.sessions (project_id, user_id);
|
||||
CREATE INDEX sessions_project_id_user_anonymous_id_idx ON public.sessions (project_id, user_anonymous_id);
|
||||
CREATE INDEX sessions_project_id_user_device_idx ON public.sessions (project_id, user_device);
|
||||
CREATE INDEX sessions_project_id_user_country_idx ON public.sessions (project_id, user_country);
|
||||
CREATE INDEX sessions_project_id_user_city_idx ON public.sessions (project_id, user_city);
|
||||
CREATE INDEX sessions_project_id_user_state_idx ON public.sessions (project_id, user_state);
|
||||
CREATE INDEX sessions_project_id_user_browser_idx ON public.sessions (project_id, user_browser);
|
||||
CREATE INDEX sessions_project_id_metadata_1_idx ON public.sessions (project_id, metadata_1);
|
||||
CREATE INDEX sessions_project_id_metadata_2_idx ON public.sessions (project_id, metadata_2);
|
||||
CREATE INDEX sessions_project_id_metadata_3_idx ON public.sessions (project_id, metadata_3);
|
||||
CREATE INDEX sessions_project_id_metadata_4_idx ON public.sessions (project_id, metadata_4);
|
||||
CREATE INDEX sessions_project_id_metadata_5_idx ON public.sessions (project_id, metadata_5);
|
||||
CREATE INDEX sessions_project_id_metadata_6_idx ON public.sessions (project_id, metadata_6);
|
||||
CREATE INDEX sessions_project_id_metadata_7_idx ON public.sessions (project_id, metadata_7);
|
||||
CREATE INDEX sessions_project_id_metadata_8_idx ON public.sessions (project_id, metadata_8);
|
||||
CREATE INDEX sessions_project_id_metadata_9_idx ON public.sessions (project_id, metadata_9);
|
||||
CREATE INDEX sessions_project_id_metadata_10_idx ON public.sessions (project_id, metadata_10);
|
||||
CREATE INDEX sessions_project_id_watchdogs_score_idx ON public.sessions (project_id, watchdogs_score DESC);
|
||||
CREATE INDEX sessions_platform_idx ON public.sessions (platform);
|
||||
|
||||
CREATE INDEX sessions_metadata1_gin_idx ON public.sessions USING GIN (metadata_1 gin_trgm_ops);
|
||||
|
|
@ -483,10 +483,10 @@ $$
|
|||
CREATE INDEX sessions_user_anonymous_id_gin_idx ON public.sessions USING GIN (user_anonymous_id gin_trgm_ops);
|
||||
CREATE INDEX sessions_start_ts_idx ON public.sessions (start_ts) WHERE duration > 0;
|
||||
CREATE INDEX sessions_project_id_idx ON public.sessions (project_id) WHERE duration > 0;
|
||||
CREATE INDEX sessions_session_id_project_id_start_ts_idx ON sessions (session_id, project_id, start_ts) WHERE duration > 0;
|
||||
CREATE INDEX sessions_session_id_project_id_start_ts_durationNN_idx ON sessions (session_id, project_id, start_ts) WHERE duration IS NOT NULL;
|
||||
CREATE INDEX sessions_user_id_useridNN_idx ON sessions (user_id) WHERE user_id IS NOT NULL;
|
||||
CREATE INDEX sessions_uid_projectid_startts_sessionid_uidNN_durGTZ_idx ON sessions (user_id, project_id, start_ts, session_id) WHERE user_id IS NOT NULL AND duration > 0;
|
||||
CREATE INDEX sessions_session_id_project_id_start_ts_idx ON public.sessions (session_id, project_id, start_ts) WHERE duration > 0;
|
||||
CREATE INDEX sessions_session_id_project_id_start_ts_durationNN_idx ON public.sessions (session_id, project_id, start_ts) WHERE duration IS NOT NULL;
|
||||
CREATE INDEX sessions_user_id_useridNN_idx ON public.sessions (user_id) WHERE user_id IS NOT NULL;
|
||||
CREATE INDEX sessions_uid_projectid_startts_sessionid_uidNN_durGTZ_idx ON public.sessions (user_id, project_id, start_ts, session_id) WHERE user_id IS NOT NULL AND duration > 0;
|
||||
CREATE INDEX sessions_utm_source_gin_idx ON public.sessions USING GIN (utm_source gin_trgm_ops);
|
||||
CREATE INDEX sessions_utm_medium_gin_idx ON public.sessions USING GIN (utm_medium gin_trgm_ops);
|
||||
CREATE INDEX sessions_utm_campaign_gin_idx ON public.sessions USING GIN (utm_campaign gin_trgm_ops);
|
||||
|
|
@ -507,39 +507,39 @@ $$
|
|||
(sessions.platform != 'web' AND sessions.user_agent ISNULL));
|
||||
|
||||
|
||||
CREATE TABLE user_viewed_sessions
|
||||
CREATE TABLE public.user_viewed_sessions
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (user_id, session_id)
|
||||
);
|
||||
|
||||
CREATE TABLE user_favorite_sessions
|
||||
CREATE TABLE public.user_favorite_sessions
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (user_id, session_id)
|
||||
);
|
||||
CREATE INDEX user_favorite_sessions_user_id_session_id_idx ON user_favorite_sessions (user_id, session_id);
|
||||
CREATE INDEX user_favorite_sessions_user_id_session_id_idx ON public.user_favorite_sessions (user_id, session_id);
|
||||
|
||||
|
||||
CREATE TABLE assigned_sessions
|
||||
CREATE TABLE public.assigned_sessions
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
issue_id text NOT NULL,
|
||||
provider oauth_provider NOT NULL,
|
||||
created_by integer NOT NULL,
|
||||
created_at timestamp DEFAULT timezone('utc'::text, now()) NOT NULL,
|
||||
provider_data jsonb DEFAULT '{}'::jsonb NOT NULL
|
||||
);
|
||||
CREATE INDEX assigned_sessions_session_id_idx ON assigned_sessions (session_id);
|
||||
CREATE INDEX assigned_sessions_session_id_idx ON public.assigned_sessions (session_id);
|
||||
|
||||
|
||||
CREATE TYPE events_common.custom_level AS ENUM ('info','error');
|
||||
|
||||
CREATE TABLE events_common.customs
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -554,10 +554,10 @@ $$
|
|||
|
||||
CREATE TABLE events_common.issues
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
issue_id text NOT NULL REFERENCES issues (issue_id) ON DELETE CASCADE,
|
||||
issue_id text NOT NULL REFERENCES public.issues (issue_id) ON DELETE CASCADE,
|
||||
payload jsonb DEFAULT NULL,
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
|
|
@ -567,7 +567,7 @@ $$
|
|||
CREATE TYPE http_method AS ENUM ('GET','HEAD','POST','PUT','DELETE','CONNECT','OPTIONS','TRACE','PATCH');
|
||||
CREATE TABLE events_common.requests
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
url text NOT NULL,
|
||||
|
|
@ -599,7 +599,7 @@ $$
|
|||
|
||||
CREATE TABLE events.pages
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
host text NOT NULL,
|
||||
|
|
@ -654,7 +654,7 @@ $$
|
|||
|
||||
CREATE TABLE events.clicks
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
label text DEFAULT NULL,
|
||||
|
|
@ -680,7 +680,7 @@ $$
|
|||
|
||||
CREATE TABLE events.inputs
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
label text DEFAULT NULL,
|
||||
|
|
@ -696,10 +696,10 @@ $$
|
|||
|
||||
CREATE TABLE events.errors
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE,
|
||||
error_id text NOT NULL REFERENCES public.errors (error_id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (session_id, message_id)
|
||||
);
|
||||
CREATE INDEX errors_session_id_idx ON events.errors (session_id);
|
||||
|
|
@ -713,7 +713,7 @@ $$
|
|||
|
||||
CREATE TABLE events.graphql
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -732,7 +732,7 @@ $$
|
|||
|
||||
CREATE TABLE events.state_actions
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -745,7 +745,7 @@ $$
|
|||
CREATE TYPE events.resource_method AS ENUM ('GET' , 'HEAD' , 'POST' , 'PUT' , 'DELETE' , 'CONNECT' , 'OPTIONS' , 'TRACE' , 'PATCH' );
|
||||
CREATE TABLE events.resources
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
message_id bigint NOT NULL,
|
||||
timestamp bigint NOT NULL,
|
||||
duration bigint NULL,
|
||||
|
|
@ -781,7 +781,7 @@ $$
|
|||
|
||||
CREATE TABLE events.performance
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
message_id bigint NOT NULL,
|
||||
host text NULL DEFAULT NULL,
|
||||
|
|
@ -808,15 +808,15 @@ $$
|
|||
CREATE INDEX performance_avg_used_js_heap_size_gt0_idx ON events.performance (avg_used_js_heap_size) WHERE avg_used_js_heap_size > 0;
|
||||
|
||||
|
||||
CREATE TABLE autocomplete
|
||||
CREATE TABLE public.autocomplete
|
||||
(
|
||||
value text NOT NULL,
|
||||
type text NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX autocomplete_unique_project_id_md5value_type_idx ON autocomplete (project_id, md5(value), type);
|
||||
CREATE index autocomplete_project_id_idx ON autocomplete (project_id);
|
||||
CREATE UNIQUE INDEX autocomplete_unique_project_id_md5value_type_idx ON public.autocomplete (project_id, md5(value), type);
|
||||
CREATE index autocomplete_project_id_idx ON public.autocomplete (project_id);
|
||||
CREATE INDEX autocomplete_type_idx ON public.autocomplete (type);
|
||||
|
||||
CREATE INDEX autocomplete_value_clickonly_gin_idx ON public.autocomplete USING GIN (value gin_trgm_ops) WHERE type = 'CLICK';
|
||||
|
|
@ -838,12 +838,12 @@ $$
|
|||
|
||||
CREATE TYPE job_status AS ENUM ('scheduled','running','cancelled','failed','completed');
|
||||
CREATE TYPE job_action AS ENUM ('delete_user_data');
|
||||
CREATE TABLE jobs
|
||||
CREATE TABLE public.jobs
|
||||
(
|
||||
job_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
description text NOT NULL,
|
||||
status job_status NOT NULL,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
action job_action NOT NULL,
|
||||
reference_id text NOT NULL,
|
||||
created_at timestamp DEFAULT timezone('utc'::text, now()) NOT NULL,
|
||||
|
|
@ -851,15 +851,15 @@ $$
|
|||
start_at timestamp NOT NULL,
|
||||
errors text NULL
|
||||
);
|
||||
CREATE INDEX jobs_status_idx ON jobs (status);
|
||||
CREATE INDEX jobs_start_at_idx ON jobs (start_at);
|
||||
CREATE INDEX jobs_project_id_idx ON jobs (project_id);
|
||||
CREATE INDEX jobs_status_idx ON public.jobs (status);
|
||||
CREATE INDEX jobs_start_at_idx ON public.jobs (start_at);
|
||||
CREATE INDEX jobs_project_id_idx ON public.jobs (project_id);
|
||||
|
||||
CREATE TABLE metrics
|
||||
CREATE TABLE public.metrics
|
||||
(
|
||||
metric_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
project_id integer NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
is_public boolean NOT NULL DEFAULT TRUE,
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
|
|
@ -877,14 +877,15 @@ $$
|
|||
"row": 2,
|
||||
"position": 0
|
||||
}'::jsonb,
|
||||
data jsonb NULL
|
||||
data jsonb NULL,
|
||||
card_info jsonb NULL
|
||||
);
|
||||
|
||||
CREATE INDEX metrics_user_id_is_public_idx ON public.metrics (user_id, is_public);
|
||||
CREATE TABLE metric_series
|
||||
CREATE TABLE public.metric_series
|
||||
(
|
||||
series_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
metric_id integer REFERENCES metrics (metric_id) ON DELETE CASCADE,
|
||||
metric_id integer REFERENCES public.metrics (metric_id) ON DELETE CASCADE,
|
||||
index integer NOT NULL,
|
||||
name text NULL,
|
||||
filter jsonb NOT NULL,
|
||||
|
|
@ -893,11 +894,11 @@ $$
|
|||
);
|
||||
CREATE INDEX metric_series_metric_id_idx ON public.metric_series (metric_id);
|
||||
|
||||
CREATE TABLE dashboards
|
||||
CREATE TABLE public.dashboards
|
||||
(
|
||||
dashboard_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
name text NOT NULL,
|
||||
description text NOT NULL DEFAULT '',
|
||||
is_public boolean NOT NULL DEFAULT TRUE,
|
||||
|
|
@ -906,22 +907,22 @@ $$
|
|||
deleted_at timestamp NULL DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE dashboard_widgets
|
||||
CREATE TABLE public.dashboard_widgets
|
||||
(
|
||||
widget_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
dashboard_id integer NOT NULL REFERENCES dashboards (dashboard_id) ON DELETE CASCADE,
|
||||
metric_id integer NOT NULL REFERENCES metrics (metric_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
dashboard_id integer NOT NULL REFERENCES public.dashboards (dashboard_id) ON DELETE CASCADE,
|
||||
metric_id integer NOT NULL REFERENCES public.metrics (metric_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
config jsonb NOT NULL DEFAULT '{}'::jsonb
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE searches
|
||||
CREATE TABLE public.searches
|
||||
(
|
||||
search_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
user_id integer NOT NULL REFERENCES public.users (user_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
filter jsonb NOT NULL,
|
||||
created_at timestamp DEFAULT timezone('utc'::text, now()) NOT NULL,
|
||||
|
|
@ -935,11 +936,11 @@ $$
|
|||
CREATE TYPE alert_detection_method AS ENUM ('threshold', 'change');
|
||||
CREATE TYPE alert_change_type AS ENUM ('percent', 'change');
|
||||
|
||||
CREATE TABLE alerts
|
||||
CREATE TABLE public.alerts
|
||||
(
|
||||
alert_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
series_id integer NULL REFERENCES metric_series (series_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
series_id integer NULL REFERENCES public.metric_series (series_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
description text NULL DEFAULT NULL,
|
||||
active boolean NOT NULL DEFAULT TRUE,
|
||||
|
|
@ -952,24 +953,24 @@ $$
|
|||
"renotifyInterval": 1440
|
||||
}'::jsonb
|
||||
);
|
||||
CREATE INDEX alerts_project_id_idx ON alerts (project_id);
|
||||
CREATE INDEX alerts_series_id_idx ON alerts (series_id);
|
||||
CREATE INDEX alerts_project_id_idx ON public.alerts (project_id);
|
||||
CREATE INDEX alerts_series_id_idx ON public.alerts (series_id);
|
||||
CREATE TRIGGER on_insert_or_update_or_delete
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON alerts
|
||||
ON public.alerts
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_alert();
|
||||
|
||||
CREATE TABLE sessions_notes
|
||||
CREATE TABLE public.sessions_notes
|
||||
(
|
||||
note_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
message text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL DEFAULT (now() at time zone 'utc'),
|
||||
user_id integer NULL REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
user_id integer NULL REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
tag text NULL,
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
timestamp integer NOT NULL DEFAULT -1,
|
||||
is_public boolean NOT NULL DEFAULT FALSE
|
||||
);
|
||||
|
|
@ -989,15 +990,15 @@ $$
|
|||
CREATE TABLE public.feature_flags
|
||||
(
|
||||
feature_flag_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
flag_key text NOT NULL,
|
||||
description text DEFAULT NULL,
|
||||
payload jsonb DEFAULT NULL,
|
||||
flag_type text NOT NULL,
|
||||
is_persist boolean NOT NULL DEFAULT FALSE,
|
||||
is_active boolean NOT NULL DEFAULT FALSE,
|
||||
created_by integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
updated_by integer REFERENCES users (user_id) ON DELETE SET NULL,
|
||||
created_by integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
updated_by integer REFERENCES public.users (user_id) ON DELETE SET NULL,
|
||||
created_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
updated_at timestamp without time zone NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL
|
||||
|
|
@ -1011,7 +1012,7 @@ $$
|
|||
CREATE TABLE public.feature_flags_conditions
|
||||
(
|
||||
condition_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
feature_flag_id integer NOT NULL REFERENCES public.feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
rollout_percentage integer NOT NULL,
|
||||
filters jsonb NOT NULL DEFAULT '[]'::jsonb
|
||||
|
|
@ -1020,7 +1021,7 @@ $$
|
|||
CREATE TABLE public.feature_flags_variants
|
||||
(
|
||||
variant_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
feature_flag_id integer NOT NULL REFERENCES public.feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
value text NOT NULL,
|
||||
description text DEFAULT NULL,
|
||||
payload jsonb DEFAULT NULL,
|
||||
|
|
@ -1029,15 +1030,15 @@ $$
|
|||
|
||||
CREATE TABLE public.sessions_feature_flags
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
condition_id integer NULL REFERENCES feature_flags_conditions (condition_id) ON DELETE SET NULL
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
feature_flag_id integer NOT NULL REFERENCES public.feature_flags (feature_flag_id) ON DELETE CASCADE,
|
||||
condition_id integer NULL REFERENCES public.feature_flags_conditions (condition_id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE events_ios.views
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
|
@ -1046,7 +1047,7 @@ $$
|
|||
|
||||
CREATE TABLE events_ios.taps
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
@ -1062,7 +1063,7 @@ $$
|
|||
|
||||
CREATE TABLE events_ios.inputs
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
@ -1077,7 +1078,7 @@ $$
|
|||
CREATE TABLE public.crashes_ios
|
||||
(
|
||||
crash_ios_id text NOT NULL PRIMARY KEY,
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
project_id integer NOT NULL REFERENCES public.projects (project_id) ON DELETE CASCADE,
|
||||
name text NOT NULL,
|
||||
reason text NOT NULL,
|
||||
stacktrace text NOT NULL
|
||||
|
|
@ -1087,7 +1088,7 @@ $$
|
|||
|
||||
CREATE TABLE events_common.crashes
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
crash_ios_id text NULL REFERENCES public.crashes_ios (crash_ios_id) ON DELETE CASCADE,
|
||||
|
|
@ -1099,7 +1100,7 @@ $$
|
|||
|
||||
CREATE TABLE events_ios.swipes
|
||||
(
|
||||
session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE,
|
||||
session_id bigint NOT NULL REFERENCES public.sessions (session_id) ON DELETE CASCADE,
|
||||
timestamp bigint NOT NULL,
|
||||
seq_index integer NOT NULL,
|
||||
label text NOT NULL,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue