Skip to content

Commit 31d2f26

Browse files
authored
✨ feat(database): extended async task with metadata and parent id, added index (#11712)
1 parent 464e560 commit 31d2f26

File tree

5 files changed

+10749
-2
lines changed

5 files changed

+10749
-2
lines changed

docs/development/database-schema.dbml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,17 @@ table async_tasks {
174174
error jsonb
175175
user_id text [not null]
176176
duration integer
177+
parent_id uuid
178+
metadata jsonb [not null, default: '{}']
177179
accessed_at "timestamp with time zone" [not null, default: `now()`]
178180
created_at "timestamp with time zone" [not null, default: `now()`]
179181
updated_at "timestamp with time zone" [not null, default: `now()`]
180182

181183
indexes {
182184
user_id [name: 'async_tasks_user_id_idx']
185+
parent_id [name: 'async_tasks_parent_id_idx']
186+
(type, status) [name: 'async_tasks_type_status_idx']
187+
metadata [name: 'async_tasks_metadata_idx']
183188
}
184189
}
185190

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE "async_tasks" ADD COLUMN IF NOT EXISTS "parent_id" uuid;--> statement-breakpoint
2+
ALTER TABLE "async_tasks" ADD COLUMN IF NOT EXISTS "metadata" jsonb DEFAULT '{}' NOT NULL;--> statement-breakpoint
3+
CREATE INDEX IF NOT EXISTS "async_tasks_parent_id_idx" ON "async_tasks" USING btree ("parent_id");--> statement-breakpoint
4+
CREATE INDEX IF NOT EXISTS "async_tasks_type_status_idx" ON "async_tasks" USING btree ("type","status");--> statement-breakpoint
5+
CREATE INDEX IF NOT EXISTS "async_tasks_metadata_idx" ON "async_tasks" USING gin ("metadata");

0 commit comments

Comments
 (0)