Skip to content

Commit

Permalink
fix: migrations (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored Jun 10, 2024
1 parent 87c8c98 commit 0a25c51
Show file tree
Hide file tree
Showing 12 changed files with 480 additions and 908 deletions.
2 changes: 1 addition & 1 deletion ops
Submodule ops updated from 10f197 to ba3468
1,198 changes: 407 additions & 791 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@playwright/test": "^1.42.1",
"@types/node": "^20.11.25",
"dotenv": "^16.4.5",
"prettier": "^3.2.5",
"prettier": "^3.3.1",
"tsup": "^8.0.1",
"tsx": "^4.7.0",
"typescript": "^5.3.3"
Expand Down
10 changes: 1 addition & 9 deletions packages/backend/src/api/v1/external-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,7 @@ users.get("/:id", checkAccess("users", "read"), async (ctx: Context) => {
users.delete("/:id", checkAccess("users", "delete"), async (ctx: Context) => {
const { id } = ctx.params

// Delete associated runs
await sql`
delete from run where external_user_id = ${id}
`

// Delete the user
await sql`
delete from external_user where id = ${id}
`
await sql`delete from external_user where id = ${id}`

ctx.status = 204
})
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/utils/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const sql = postgres(process.env.DATABASE_URL!, {
connection: {
application_name: `backend-${isProduction ? "production" : "development"}-${new Date().getTime()}`,
},
debug: process.env.DEBUG ? debugFn : () => {},
// debug: process.env.DEBUG ? debugFn : () => {},
// onnotice: process.env.DEUG ? console.log : () => {},
})

Expand Down
2 changes: 0 additions & 2 deletions packages/db/0014.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
begin;
lock radar_result;
delete from radar_result where run_id is null;
alter table radar_result alter column run_id set not null;
commit;
4 changes: 1 addition & 3 deletions packages/db/0017.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
-- [ ] INDEX run tsvector
create index on run((error is not null));
-- [ ] final tables evaluators
create index on run((error is not null));
28 changes: 28 additions & 0 deletions packages/db/0018.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
create table evaluator (
id uuid not null default uuid_generate_v4(),
created_at timestamptz default now(),
updated_at timestamptz default now(),
project_id uuid not null,
owner_id uuid,
name varchar not null,
slug varchar not null,
type varchar not null,
mode varchar,
description text,
params jsonb,
filters jsonb,
constraint evaluator_owner_id_fkey foreign key (owner_id) references account(id) on delete set null,
constraint evaluator_project_id_fkey foreign key (project_id) references project(id) on delete cascade,
primary key (id)
);

create table evaluation_result_v2 (
run_id uuid not null,
evaluator_id uuid not null,
created_at timestamptz default now(),
updated_at timestamptz default now(),
result jsonb NOT NULL,
constraint evaluation_result_evaluator_id_fkey foreign key (evaluator_id) references evaluator(id) on delete cascade,
constraint evaluation_result_run_id_fkey foreign key (run_id) references run(id) on delete cascade,
primary key(run_id, evaluator_id)
);
3 changes: 3 additions & 0 deletions packages/db/0019.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lock table run;
alter table run drop constraint run_external_user_id_fkey;
alter table run add constraint run_external_user_id_fkey foreign key (external_user_id) references external_user(id) on delete cascade on update cascade;
60 changes: 0 additions & 60 deletions packages/frontend/pages/evaluations/realtime.tsx

This file was deleted.

75 changes: 36 additions & 39 deletions packages/frontend/pages/evaluations/realtime/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,45 +42,42 @@ export default function RealtimeEvaluators() {
return <Loader />
}

// TODO:
// if (false) {
// return (
// <Paywall
// plan="enterprise"
// feature="Realtime Evaluations"
// Icon={IconActivityHeartbeat}
// p="xl"
// enabled={!org.license.realtimeEvalsEnabled}
// description="Run evaluations on your production data in real-time."
// list={FEATURE_LIST}
// >
// <Container>
// <Stack>
// <Group align="center" justify="space-between">
// <Group align="center">
// <Title>Realtime Evaluations</Title>
// <Badge variant="teal" color="violet">
// Enteprise
// </Badge>
// </Group>

// <Group>
// <Button variant="default" leftSection={<IconPlus size={12} />}>
// New
// </Button>
// </Group>
// </Group>

// <Text size="lg" mb="md">
// Run evaluations on your production data in real-time. They can be
// used to enrich your data with additional information, such as
// sentiment analysis, topic recognition, and more.
// </Text>
// </Stack>
// </Container>
// </Paywall>
// )
// }
return (
<Paywall
plan="enterprise"
feature="Realtime Evaluations"
Icon={IconActivityHeartbeat}
p="xl"
enabled={!org.license.realtimeEvalsEnabled}
description="Run evaluations on your production data in real-time."
list={FEATURE_LIST}
>
<Container>
<Stack>
<Group align="center" justify="space-between">
<Group align="center">
<Title>Realtime Evaluations</Title>
<Badge variant="teal" color="violet">
Enteprise
</Badge>
</Group>

<Group>
<Button variant="default" leftSection={<IconPlus size={12} />}>
New
</Button>
</Group>
</Group>

<Text size="lg" mb="md">
Run evaluations on your production data in real-time. They can be
used to enrich your data with additional information, such as
sentiment analysis, topic recognition, and more.
</Text>
</Stack>
</Container>
</Paywall>
)

return (
<Container>
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/pages/users/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function UserDetails({}) {
loadMore,
} = useProjectInfiniteSWR(`/runs?users=${id}`)

const confirmDelete = () => {
function confirmDelete() {
modals.openConfirmModal({
title: "Please confirm your action",
confirmProps: { color: "red", "data-testid": "confirm" },
Expand Down

0 comments on commit 0a25c51

Please sign in to comment.