change schema

This commit is contained in:
Ayrat Badykov 2022-08-20 18:52:33 +03:00
parent 691cba40d4
commit c24b92e349
No known key found for this signature in database
GPG key ID: EC1148A46811EFB5
5 changed files with 8 additions and 18 deletions

View file

@ -1,2 +0,0 @@
DROP TABLE fang_tasks;
DROP TYPE fang_task_state;

View file

@ -1 +0,0 @@
DROP TABLE fang_periodic_tasks;

View file

@ -1,11 +0,0 @@
CREATE TABLE fang_periodic_tasks (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
metadata jsonb NOT NULL,
period_in_millis BIGINT NOT NULL,
scheduled_at TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
CREATE INDEX fang_periodic_tasks_scheduled_at_index ON fang_periodic_tasks(scheduled_at);
CREATE INDEX fang_periodic_tasks_metadata_index ON fang_periodic_tasks(metadata);

View file

@ -0,0 +1 @@
-- This file should undo anything in `up.sql`

View file

@ -6,13 +6,16 @@ CREATE TABLE fang_tasks (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
metadata jsonb NOT NULL,
error_message TEXT,
state fang_task_state default 'new' NOT NULL,
task_type VARCHAR default 'common' NOT NULL,
state fang_task_state DEFAULT 'new' NOT NULL,
task_type VARCHAR DEFAULT 'common' NOT NULL,
periodic BOOLEAN DEFAULT FALSE,
uniq_hash CHAR(64),
scheduled_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
CREATE INDEX fang_tasks_state_index ON fang_tasks(state);
CREATE INDEX fang_tasks_type_index ON fang_tasks(task_type);
CREATE INDEX fang_tasks_created_at_index ON fang_tasks(created_at);
CREATE INDEX fang_tasks_metadata_index ON fang_tasks(metadata);
CREATE INDEX fang_tasks_scheduled_at_index ON fang_tasks(scheduled_at);
CREATE INDEX fang_tasks_uniq_hash ON fang_tasks(uniq_hash);