CREATE TABLE IF NOT EXISTS federated_execution_profiles_v019 (id varchar(36) PRIMARY KEY,name varchar(180) UNIQUE NOT NULL,subject_type varchar(30) NOT NULL,subject_value varchar(180) NOT NULL,strategy varchar(40) NOT NULL,parallel_sources boolean NOT NULL,memory_limit_mb integer NOT NULL,sort_merge_threshold_rows integer NOT NULL,pushdown_enabled boolean NOT NULL,source_timeout_seconds integer NOT NULL,enabled boolean NOT NULL,created_by varchar(36) NOT NULL REFERENCES users(id),created_at timestamptz NOT NULL);
CREATE INDEX IF NOT EXISTS ix_fed_profiles_subject_v019 ON federated_execution_profiles_v019(subject_value);
CREATE TABLE IF NOT EXISTS federated_source_executions_v019 (id varchar(36) PRIMARY KEY,worker_run_id varchar(36) NOT NULL REFERENCES federated_worker_runs_v018(id) ON DELETE CASCADE,side varchar(20) NOT NULL,status varchar(30) NOT NULL,source_name varchar(180) NOT NULL,cancel_token varchar(180) NOT NULL,row_count integer NOT NULL,duration_ms integer NOT NULL,error text NOT NULL,started_at timestamptz,finished_at timestamptz,created_at timestamptz NOT NULL);
CREATE INDEX IF NOT EXISTS ix_fed_source_run_v019 ON federated_source_executions_v019(worker_run_id);
CREATE TABLE IF NOT EXISTS object_storage_artifacts_v019 (id varchar(36) PRIMARY KEY,owner_id varchar(36) NOT NULL REFERENCES users(id),job_id varchar(36) REFERENCES federated_query_jobs_v017(id) ON DELETE SET NULL,artifact_type varchar(40) NOT NULL,provider varchar(30) NOT NULL,bucket varchar(180) NOT NULL,object_key varchar(1000) NOT NULL,content_type varchar(120) NOT NULL,checksum varchar(128) NOT NULL,size_bytes bigint NOT NULL,encrypted boolean NOT NULL,expires_at timestamptz,created_at timestamptz NOT NULL);
CREATE INDEX IF NOT EXISTS ix_artifacts_owner_v019 ON object_storage_artifacts_v019(owner_id);
