get_charset_collate(); $prefix = $wpdb->prefix; // row_id -> wpwand_generated_post.id (the post row this job fills) // settings/outline/sections -> JSON working state // step -> 0 outline, 1..N sections, then assemble; status pending|processing|done|failed // claimed_at -> lock timestamp so concurrent ticks/drivers don't double-process $jobs = "CREATE TABLE {$prefix}wpwand_gen_jobs ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, row_id bigint(20) unsigned NOT NULL, title varchar(255) NOT NULL, settings longtext DEFAULT NULL, outline longtext DEFAULT NULL, sections longtext DEFAULT NULL, step int(11) NOT NULL DEFAULT 0, total_steps int(11) NOT NULL DEFAULT 0, status varchar(32) NOT NULL DEFAULT 'pending', attempts int(11) NOT NULL DEFAULT 0, error text DEFAULT NULL, claimed_at datetime DEFAULT NULL, created_at timestamp DEFAULT CURRENT_TIMESTAMP, updated_at datetime DEFAULT NULL, PRIMARY KEY (id), KEY row_id (row_id), KEY status (status) ) {$charset_collate};"; dbDelta($jobs); } }