Skip to content

Commit f73a3d9

Browse files
CodingAnarchyclaude
andcommitted
fix: Separate PostgreSQL ALTER statements in all migrations for compatibility v1.7.1
- Fixed PostgreSQL migration compatibility by separating comma-separated ALTER TABLE statements - Resolved "cannot insert multiple commands into a prepared statement" error - Updated migrations 003-011 to use individual ALTER TABLE statements for PostgreSQL - Added IF NOT EXISTS to MySQL migration 011 to prevent duplicate column errors - Fixed clippy warnings in encryption module with appropriate allow directives - Bumped version to 1.7.1 with changelog entry 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent a4bab65 commit f73a3d9

14 files changed

+141
-74
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.7.1] - 2025-07-04
9+
10+
### Fixed
11+
- **🐛 PostgreSQL Migration Compatibility**
12+
- Fixed PostgreSQL migration 011_add_encryption to separate multiple ALTER TABLE statements
13+
- Resolved "cannot insert multiple commands into a prepared statement" error
14+
- Each ADD COLUMN statement now executed individually for PostgreSQL compatibility
15+
816
## [1.7.0] - 2025-07-03
917

1018
### Added

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ members = [
99
resolver = "2"
1010

1111
[workspace.package]
12-
version = "1.7.0"
12+
version = "1.7.1"
1313
edition = "2024"
1414
license = "MIT"
1515
repository = "https://github.com/CodingAnarchy/hammerwork"
@@ -19,7 +19,7 @@ documentation = "https://docs.rs/hammerwork"
1919
rust-version = "1.86"
2020

2121
[workspace.dependencies]
22-
hammerwork = { version = "1.7.0", path = "." }
22+
hammerwork = { version = "1.7.1", path = "." }
2323
tokio = { version = "1.0", features = ["full"] }
2424
sqlx = { version = "0.8", features = ["runtime-tokio-rustls", "chrono", "uuid", "json"] }
2525
chrono = { version = "0.4", features = ["serde"] }

src/encryption/engine.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ impl EncryptionEngine {
644644
}
645645

646646
#[cfg(feature = "encryption")]
647+
#[allow(clippy::type_complexity)]
647648
fn encrypt_data(&self, data: &[u8]) -> Result<(Vec<u8>, Vec<u8>, Vec<u8>), EncryptionError> {
648649
let default_key_id = "default".to_string();
649650
let key_id = self.config.key_id.as_ref().unwrap_or(&default_key_id);
@@ -778,6 +779,7 @@ impl EncryptionEngine {
778779
hex::encode(hasher.finalize())
779780
}
780781

782+
#[allow(clippy::only_used_in_recursion)]
781783
fn scan_object_for_pii(
782784
&self,
783785
value: &Value,

src/encryption/key_manager.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,15 @@ pub struct KeyManagerStats {
284284
}
285285

286286
/// Main key management system
287+
type KeyCacheEntry = (Vec<u8>, DateTime<Utc>); // (decrypted_material, cached_at)
288+
type KeyCache = Arc<Mutex<HashMap<String, KeyCacheEntry>>>;
289+
287290
pub struct KeyManager<DB: Database> {
288291
config: KeyManagerConfig,
292+
#[allow(dead_code)]
289293
pool: Pool<DB>,
290294
master_key: Arc<Mutex<Option<Vec<u8>>>>,
291-
key_cache: Arc<Mutex<HashMap<String, (Vec<u8>, DateTime<Utc>)>>>, // key_id -> (decrypted_material, cached_at)
295+
key_cache: KeyCache,
292296
stats: Arc<Mutex<KeyManagerStats>>,
293297
}
294298

@@ -902,7 +906,6 @@ impl Default for KeyManagerStats {
902906
#[cfg(test)]
903907
mod tests {
904908
use super::*;
905-
use crate::encryption::EncryptionAlgorithm;
906909

907910
#[tokio::test]
908911
async fn test_key_manager_config_creation() {

src/migrations/003_add_timeouts.postgres.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33

44
-- Add timeout fields
55
ALTER TABLE hammerwork_jobs
6-
ADD COLUMN IF NOT EXISTS timeout_seconds INTEGER,
6+
ADD COLUMN IF NOT EXISTS timeout_seconds INTEGER;
7+
8+
ALTER TABLE hammerwork_jobs
79
ADD COLUMN IF NOT EXISTS timed_out_at TIMESTAMPTZ;

src/migrations/004_add_cron.postgres.sql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33

44
-- Add cron scheduling fields
55
ALTER TABLE hammerwork_jobs
6-
ADD COLUMN IF NOT EXISTS cron_schedule VARCHAR(100),
7-
ADD COLUMN IF NOT EXISTS next_run_at TIMESTAMPTZ,
8-
ADD COLUMN IF NOT EXISTS recurring BOOLEAN NOT NULL DEFAULT FALSE,
6+
ADD COLUMN IF NOT EXISTS cron_schedule VARCHAR(100);
7+
8+
ALTER TABLE hammerwork_jobs
9+
ADD COLUMN IF NOT EXISTS next_run_at TIMESTAMPTZ;
10+
11+
ALTER TABLE hammerwork_jobs
12+
ADD COLUMN IF NOT EXISTS recurring BOOLEAN NOT NULL DEFAULT FALSE;
13+
14+
ALTER TABLE hammerwork_jobs
915
ADD COLUMN IF NOT EXISTS timezone VARCHAR(50);
1016

1117
-- Create indexes for cron job queries

src/migrations/006_add_result_storage.postgres.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33

44
-- Add result storage fields
55
ALTER TABLE hammerwork_jobs
6-
ADD COLUMN IF NOT EXISTS result_data JSONB,
7-
ADD COLUMN IF NOT EXISTS result_stored_at TIMESTAMPTZ,
6+
ADD COLUMN IF NOT EXISTS result_data JSONB;
7+
8+
ALTER TABLE hammerwork_jobs
9+
ADD COLUMN IF NOT EXISTS result_stored_at TIMESTAMPTZ;
10+
11+
ALTER TABLE hammerwork_jobs
812
ADD COLUMN IF NOT EXISTS result_expires_at TIMESTAMPTZ;
913

1014
-- Create index for result cleanup operations

src/migrations/007_add_dependencies.postgres.sql

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33

44
-- Add dependency tracking columns to hammerwork_jobs table
55
ALTER TABLE hammerwork_jobs
6-
ADD COLUMN IF NOT EXISTS depends_on JSONB DEFAULT '[]'::jsonb,
7-
ADD COLUMN IF NOT EXISTS dependents JSONB DEFAULT '[]'::jsonb,
8-
ADD COLUMN IF NOT EXISTS dependency_status VARCHAR DEFAULT 'none',
9-
ADD COLUMN IF NOT EXISTS workflow_id UUID,
6+
ADD COLUMN IF NOT EXISTS depends_on JSONB DEFAULT '[]'::jsonb;
7+
8+
ALTER TABLE hammerwork_jobs
9+
ADD COLUMN IF NOT EXISTS dependents JSONB DEFAULT '[]'::jsonb;
10+
11+
ALTER TABLE hammerwork_jobs
12+
ADD COLUMN IF NOT EXISTS dependency_status VARCHAR DEFAULT 'none';
13+
14+
ALTER TABLE hammerwork_jobs
15+
ADD COLUMN IF NOT EXISTS workflow_id UUID;
16+
17+
ALTER TABLE hammerwork_jobs
1018
ADD COLUMN IF NOT EXISTS workflow_name VARCHAR;
1119

1220
-- Add comments for clarity

src/migrations/008_add_result_config.postgres.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
-- Add result configuration fields
55
ALTER TABLE hammerwork_jobs
6-
ADD COLUMN IF NOT EXISTS result_storage_type VARCHAR(20) DEFAULT 'none',
7-
ADD COLUMN IF NOT EXISTS result_ttl_seconds BIGINT,
6+
ADD COLUMN IF NOT EXISTS result_storage_type VARCHAR(20) DEFAULT 'none';
7+
8+
ALTER TABLE hammerwork_jobs
9+
ADD COLUMN IF NOT EXISTS result_ttl_seconds BIGINT;
10+
11+
ALTER TABLE hammerwork_jobs
812
ADD COLUMN IF NOT EXISTS result_max_size_bytes BIGINT;

src/migrations/009_add_tracing.postgres.sql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33

44
-- Add tracing fields to support distributed tracing and correlation
55
ALTER TABLE hammerwork_jobs
6-
ADD COLUMN IF NOT EXISTS trace_id VARCHAR(128),
7-
ADD COLUMN IF NOT EXISTS correlation_id VARCHAR(128),
8-
ADD COLUMN IF NOT EXISTS parent_span_id VARCHAR(128),
6+
ADD COLUMN IF NOT EXISTS trace_id VARCHAR(128);
7+
8+
ALTER TABLE hammerwork_jobs
9+
ADD COLUMN IF NOT EXISTS correlation_id VARCHAR(128);
10+
11+
ALTER TABLE hammerwork_jobs
12+
ADD COLUMN IF NOT EXISTS parent_span_id VARCHAR(128);
13+
14+
ALTER TABLE hammerwork_jobs
915
ADD COLUMN IF NOT EXISTS span_context TEXT;
1016

1117
-- Index for trace ID lookups (finding all jobs in a trace)

0 commit comments

Comments
 (0)