Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
31 changes: 3 additions & 28 deletions src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,34 +281,9 @@ impl TaskStore {
sqlx::raw_sql(include_str!("../../migrations/004_task_tags.sql"))
.execute(&self.pool)
.await?;

// 010: paused_groups table + pause_reasons column on tasks.
// The CREATE TABLE is idempotent, but ALTER TABLE ADD COLUMN will
// fail if the column already exists (fresh databases include it in
// 001_tasks.sql). Run each statement individually and tolerate the
// "duplicate column" error from the ALTER.
sqlx::raw_sql(
"CREATE TABLE IF NOT EXISTS paused_groups (
group_key TEXT NOT NULL PRIMARY KEY,
paused_at INTEGER NOT NULL,
resume_at INTEGER
);",
)
.execute(&self.pool)
.await?;

// ALTER TABLE ADD COLUMN is not idempotent — tolerate failure.
let _ =
sqlx::raw_sql("ALTER TABLE tasks ADD COLUMN pause_reasons INTEGER NOT NULL DEFAULT 0;")
.execute(&self.pool)
.await;

// Backfill: existing paused tasks get PREEMPTION bit.
sqlx::raw_sql(
"UPDATE tasks SET pause_reasons = 1 WHERE status = 'paused' AND pause_reasons = 0;",
)
.execute(&self.pool)
.await?;
sqlx::raw_sql(include_str!("../../migrations/005_paused_groups.sql"))
.execute(&self.pool)
.await?;

Ok(())
}
Expand Down
Loading