Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhermeF03 committed Jun 26, 2024
1 parent d294384 commit c0cd272
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
4 changes: 2 additions & 2 deletions code/client/src/domain/editor/fugue/FugueTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class FugueTree<T> {
// create node
const node: Node<T> = treeNode(id, value, parent, side, 0, styles as InlineStyle[]);
if (value === '\n') {
this._root.value.splice(line, 0, node); // TODO: check if this is correct
this._root.value.splice(line, 0, node);
}
this._addNode(node);
}
Expand Down Expand Up @@ -85,7 +85,7 @@ export class FugueTree<T> {
if (!node.isDeleted) node.isDeleted = true;
if (node.value === '\n') {
const idx = this._root.value.findIndex(n => n.id === id);
this._root.value.splice(idx, 1); // TODO: check if this is correct
this._root.value.splice(idx, 1);
}
}

Expand Down
15 changes: 14 additions & 1 deletion code/server/sql/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ begin;
members text[] not null default '{}'::text[] -- references "user"(email)
);

create table if not exists resource (
create table if not exists resource(
id char(16) primary key default encode(gen_random_bytes(8), 'hex'),
workspace char(16) not null references workspace(id) on delete cascade,
name text not null,
Expand All @@ -30,4 +30,17 @@ begin;
created_at timestamp not null default now()
);

-- Triggers
create or replace trigger on_workspace_insert_trigger
after insert on workspace
for each row execute function add_root_resource();

create or replace trigger on_resource_delete_trigger
after delete on resource
for each row execute function on_child_removed();

create or replace trigger on_resource_update_trigger
after update on resource
for each row execute function on_child_updated();

commit;
5 changes: 0 additions & 5 deletions code/server/sql/triggers/resource_delete.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@ begin;
return old;
end;
$$ language plpgsql;

create or replace trigger on_resource_delete_trigger
after delete on resource
for each row execute function on_child_removed();

commit;
4 changes: 0 additions & 4 deletions code/server/sql/triggers/resource_insert.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,4 @@ begin;
end if;
end;
$$ language plpgsql;

create or replace trigger on_resource_insert_trigger
after insert on resource
for each row execute function on_new_resource_created();
commit;
4 changes: 0 additions & 4 deletions code/server/sql/triggers/resource_update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,4 @@ begin;
return new;
end;
$$ language plpgsql;

create or replace trigger on_resource_update_trigger
after update on resource
for each row execute function on_child_updated();
commit ;
5 changes: 0 additions & 5 deletions code/server/sql/triggers/workspace_insert.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,4 @@ begin;
return new;
end;
$$ language plpgsql;

create or replace trigger on_workspace_insert_trigger
after insert on workspace
for each row execute function add_root_resource();

commit;

0 comments on commit c0cd272

Please sign in to comment.