feat: add base database management
This commit is contained in:
parent
1d5a517395
commit
1e3c235b78
11 changed files with 132 additions and 20 deletions
20
migrations/0001_jobs.sql
Normal file
20
migrations/0001_jobs.sql
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
create table jobs
|
||||
(
|
||||
id integer
|
||||
constraint jobs_pk
|
||||
primary key autoincrement,
|
||||
task_id integer not null
|
||||
constraint jobs_tasks_id_fk
|
||||
references tasks,
|
||||
status_id integer not null
|
||||
constraint jobs_statuses_id_fk
|
||||
references statuses,
|
||||
output TEXT,
|
||||
started_at TEXT default CURRENT_TIMESTAMP not null,
|
||||
finished_at TEXT,
|
||||
"order" integer not null
|
||||
);
|
||||
|
||||
create index jobs_task_id_order_index
|
||||
on jobs (task_id asc, "order" desc);
|
||||
|
||||
13
migrations/0002_statuses.sql
Normal file
13
migrations/0002_statuses.sql
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
create table statuses
|
||||
(
|
||||
id integer
|
||||
constraint task_statuses_pk
|
||||
primary key autoincrement,
|
||||
name TEXT not null
|
||||
);
|
||||
|
||||
insert into statuses (id, name)
|
||||
values (1, 'Pending'),
|
||||
(2, 'In progress'),
|
||||
(3, 'Completed'),
|
||||
(4, 'Failed');
|
||||
19
migrations/0003_tasks.sql
Normal file
19
migrations/0003_tasks.sql
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
create table tasks
|
||||
(
|
||||
id integer not null
|
||||
constraint tasks_pk
|
||||
primary key autoincrement,
|
||||
payload_key ANY not null
|
||||
constraint tasks_payload_key
|
||||
unique,
|
||||
payload TEXT not null,
|
||||
status_id integer not null
|
||||
constraint tasks_task_statuses_id_fk
|
||||
references statuses,
|
||||
created_at TEXT default CURRENT_TIMESTAMP not null,
|
||||
updated_at TEXT
|
||||
);
|
||||
|
||||
create unique index tasks_payload_key_uindex
|
||||
on tasks (payload_key);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue