Skip to content

Commit 64e0dac

Browse files
authored
Add tasks table (#8)
1 parent 68b7001 commit 64e0dac

5 files changed

Lines changed: 29 additions & 0 deletions

File tree

pending.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alter table items alter column hash_code drop default;
2+
drop index items_organization_id_object_id_key;

scripts/20190906-193722.sql

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
drop table if exists public.tasks;
2+
3+
set search_path to public;
4+
5+
create table tasks (
6+
id text primary key check(util.non_empty_trimmed_string(id)),
7+
data text not null check(util.non_empty_trimmed_string(data)),
8+
priority bigint not null check(priority >= 0),
9+
num_attempts bigint not null check(num_attempts >= 0),
10+
processed_at timestamptz,
11+
created_at timestamptz not null default now(),
12+
updated_at timestamptz not null default now(),
13+
updated_by_user_id text not null check(util.non_empty_trimmed_string(updated_by_user_id)),
14+
hash_code bigint not null
15+
);
16+
17+
create index tasks_num_attempts_processed_at_idx on tasks(num_attempts, processed_at);
18+
19+
select schema_evolution_manager.create_updated_at_trigger('public', 'tasks');

scripts/20190906-225730.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
create index on tasks(data) where processed_at is null;

scripts/20190909-173126.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
alter table items add updated_at timestamptz not null default now();
2+
update items set updated_at = created_at;
3+
alter table items add hash_code bigint not null default 0;
4+
select schema_evolution_manager.create_updated_at_trigger('public', 'items');

scripts/20190909-175225.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
create unique index items_object_id_idx on items(object_id);
2+
create index items_organization_id_idx on items(organization_id);
3+

0 commit comments

Comments
 (0)