Skip to main content

Built-in Tables

In addition to custom tables you create, every project includes read-only built-in tables in the abstra schema. These tables give you SQL access to workflow data like tasks, users, roles, and executions.

Read-only access

Built-in tables are accessible via SQL SELECT queries only. All writes go through the Abstra API and Python SDK.

Querying built-in tables

Use the abstra schema prefix when querying:

import abstra.tables as at

tasks = at.run_sql("SELECT * FROM abstra.tasks WHERE status = 'pending' LIMIT 10")
users = at.run_sql("SELECT * FROM abstra.users")

Available tables

abstra.tasks

Stores all workflow tasks and their lifecycle data.

ColumnTypeDescription
iduuidTask ID
created_attimestampWhen the task was created
updated_attimestampLast update
deleted_attimestampSoft delete timestamp (null if active)
project_iduuidProject ID
typevarcharTask type label used for routing
payloadjsonbTask payload data
statustextpending, locked, or completed
target_stage_idvarcharDestination stage ID
created_by_stage_idvarcharStage that created this task
created_by_execution_iduuidExecution that created this task
completed_attimestampWhen the task was completed
completed_byuuidExecution that completed this task
locked_attimestampWhen the task was locked
locked_byuuidExecution that locked this task

abstra.executions

Records every stage execution in your workflow.

ColumnTypeDescription
iduuidExecution ID
created_attimestampWhen the execution started
updated_attimestampLast status change
statustextcreated, running, success, failure, etc.
contextjsonbExecution context (includes taskId if triggered by a task)
project_iduuidProject ID
build_iduuidBuild that ran this execution
stage_idtextStage identifier
stage_run_iduuidStage run ID (for forms threads)
worker_iduuidWorker that ran the execution
app_iduuidApp ID (if applicable)
pidtextProcess ID

abstra.users

Stores access control users for your project.

ColumnTypeDescription
iduuidUser ID
created_attimestampWhen the user was added
updated_attimestampLast update
deleted_attimestampSoft delete timestamp
emailvarcharUser email
project_iduuidProject ID

abstra.roles

Stores access control roles.

ColumnTypeDescription
iduuidRole ID
created_attimestampWhen the role was created
updated_attimestampLast update
deleted_attimestampSoft delete timestamp
project_iduuidProject ID
namevarcharRole name
descriptionvarcharRole description

abstra.users_roles

Junction table linking users to roles.

ColumnTypeDescription
iduuidAssociation ID
created_attimestampWhen the association was created
deleted_attimestampSoft delete timestamp
user_iduuidReferences abstra.users.id
role_iduuidReferences abstra.roles.id

abstra.signup_policy

Stores email pattern rules for user sign-up.

ColumnTypeDescription
iduuidPolicy ID
project_iduuidProject ID
email_patternsjsonbArray of allowed email patterns (e.g. ["@company.com"])

Example queries

Pending tasks by stage

import abstra.tables as at

pending = at.run_sql("""
SELECT target_stage_id, count(*) as pending_count
FROM abstra.tasks
WHERE status = 'pending' AND deleted_at IS NULL
GROUP BY target_stage_id
""")

Recent failed executions

import abstra.tables as at

failures = at.run_sql("""
SELECT id, stage_id, created_at, context
FROM abstra.executions
WHERE status = 'failure'
ORDER BY created_at DESC
LIMIT 20
""")

Users with their roles

import abstra.tables as at

users_with_roles = at.run_sql("""
SELECT u.email, array_agg(r.name) as roles
FROM abstra.users u
LEFT JOIN abstra.users_roles ur ON u.id = ur.user_id AND ur.deleted_at IS NULL
LEFT JOIN abstra.roles r ON ur.role_id = r.id AND r.deleted_at IS NULL
WHERE u.deleted_at IS NULL
GROUP BY u.email
""")