Skip to content

Commit

Permalink
Changed ids from uuid to 12-char base64 strings
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhermeF03 committed May 12, 2024
1 parent 19d83f3 commit 2aaeae0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 9 additions & 9 deletions code/server/src/sql/create_tables.sql
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
begin;

create extension if not exists "uuid-ossp";
create extension if not exists "pgcrypto";

create type resource_type as enum ('D', 'F');

create table if not exists workspace (
id uuid primary key default uuid_generate_v4(),
create table if not exists workspaces (
id char(12) primary key default encode(gen_random_bytes(8), 'base64'),
name text not null,
created_at timestamp not null default now(),
updated_at timestamp not null default now()
);

create table if not exists resource (
id uuid primary key default uuid_generate_v4(),
workspace uuid not null references workspace(id) on delete cascade,
create table if not exists resources (
id char(12) primary key default encode(gen_random_bytes(8), 'base64'),
workspace varchar not null references workspaces(id) on delete cascade,
name text not null,
type resource_type not null,
children uuid[] not null default '{}',
created_at timestamp not null default now(),
updated_at timestamp not null default now()
);

create table if not exists resource_child (
parent uuid not null references resource(id) on delete cascade,
child uuid not null references resource(id) on delete cascade,
create table if not exists resources_children (
parent char(12) not null references resources(id) on delete cascade,
child char(12) not null references resources(id) on delete cascade,
primary key (parent, child)
);

Expand Down
2 changes: 2 additions & 0 deletions code/server/src/sql/drop_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ begin ;

drop table if exists workspaces cascade ;

drop table if exists resources_children cascade ;

drop type if exists resource_type cascade ;

commit ;

0 comments on commit 2aaeae0

Please sign in to comment.