Skip to content

Releases: bitalizer/db-migrator

v0.3.2 - Type-safe schema mapping

12 Apr 14:49

Choose a tag to compare

What's Changed since v0.2.5

Bug Fixes

  • Fix binary value quoting — was '0x...', now correctly 0x... without quotes
  • Fix Bit and U8 NULL handling — was outputting 0 for NULL, now correctly NULL
  • Fix float/real values being string-quoted — F32/F64 now output as bare numbers
  • Fix datetime2/time/datetimeoffset losing sub-second precision — now uses %.f format
  • Fix SmallDateTime crash from multiplying seconds_fragments by 60 (was already in minutes)
  • Fix SQL injection risk — all dynamic SQL identifiers now properly escaped (#18)
  • Fix error swallowing — migration errors now propagate correctly instead of being silently ignored
  • Fix formatted_tables bug in migrator
  • Fix format_snake_case to handle acronyms correctly (e.g., HTTPSStatushttps_status)
  • Fix missing .await calls and preserve error context in inserter
  • Fix fail-fast behavior — migration now stops on first table error
  • Fix safe fallback for available_parallelism
  • Fix exit code — errors now propagate to process exit code

Type-safe Schema Mapping (#21)

  • Replace all stringly-typed schema handling with type-safe enums (MssqlType with 29 variants, MySqlBaseType with 18 variants)
  • Add TypeRegistry with built-in exhaustive defaults for all MSSQL types — zero config needed
  • Separate source (ColumnSchema) from target (TargetColumn) with validated MySqlType
  • MySqlType.to_sql() renders correct MySQL type declarations with length, precision, scale, unsigned, zerofill
  • Validate length limits, MAX handling (-1), precision overflow, safe i32→u8 scale conversion
  • Share TypeRegistry across concurrent tasks via Arc

Configuration Improvements

  • mappings.toml is now optional — all defaults are built in
  • Simplified override format: nvarchar = "varchar(500)" instead of verbose [[mappings]] blocks
  • Bare type overrides like "varchar" auto-carry source length with safe defaults
  • Length/precision types without params get sensible fallbacks (varchar → 255, decimal → 10,2)

Error Handling & Safety (#17)

  • Add structured MigrationError enum replacing panics with proper Result propagation
  • Replace all .unwrap() and panic!() in extractor, inserter, format, and schema parsing
  • Replace Constraint::from_str error type () with MigrationError
  • Typed errors throughout the codebase with proper context via anyhow

Architecture (#19)

  • Make DatabaseMigrator and TableMigrator generic over Extractor/Inserter traits
  • Enables mock-based testing without real database connections

Testing (#20)

  • 179 unit tests (up from ~10)
  • Mock-based orchestration tests for DatabaseMigrator and TableMigrator
  • Tests cover: type mapping, schema conversion, SQL rendering, override parsing, query building, config parsing, batching, error propagation, snake_case formatting, constraint handling

CI/CD

  • Update GitHub Actions to non-deprecated versions
  • Update release workflow to support Rust 2024 edition
  • Add format check (cargo fmt --check) and clippy (-D warnings) to CI

Dependencies

  • Update all dependencies to latest compatible versions
  • Rust edition upgraded to 2024 (requires Rust 1.85+)

Contributors

Full Changelog: v0.2.5...v0.3.2

db-migrator 0.2.5

01 Sep 20:37
264dd8b

Choose a tag to compare

🚀 Release v0.2.5 - Database Integrity and Code Quality Enhancements 🛠️

In this release, we're introducing several critical improvements to enhance the overall reliability, maintainability, and performance of our database tool. Here's a breakdown of the key changes:

  • 🐞 Fixed a bug by ensuring transactional table creation: We've resolved a critical issue related to table creation operations. Now, all table creation operations utilize transactional queries, effectively preventing foreign key-related problems and ensuring data integrity during database operations.

  • 🧩 Improved foreign key reference creation: To reduce unnecessary dependencies and enhance database performance, we've optimized the creation of foreign key references. They are now generated only for whitelisted tables, streamlining the database structure.

  • 🏢 Table existence check before resetting: We've introduced a table existence check. This simple yet crucial addition enhances the safety of database operations.

  • 💼 Code formatting adjustments: We've maintained coding style consistency by making necessary formatting adjustments throughout the codebase. This ensures cleaner and more readable code

  • 🧰 Enhanced error handling in the inserter: We've made significant enhancements to error handling within the inserter component. This improvement provides better feedback in case of data insertion failures, making debugging and troubleshooting more efficient.

These changes collectively represent our commitment to delivering a robust and dependable database tool. We encourage all users to upgrade to version 0.2.5 to benefit from these enhancements.

db-migrator 0.2.4

22 Aug 12:42

Choose a tag to compare

🚀 Release v0.2.4 - Streamlined Insights and Enhanced Debugging

We're thrilled to introduce version 0.2.4, a release that elevates your debugging experience by streamlining insights and providing enhanced context. In this version, we've made the following update:

🔧 Refined Error Message Display:

Improved the error message display within transactional query execution error handling. We've removed the previous 100-character truncation limit, allowing the complete query to be included in the error message. This alteration provides comprehensive context for debugging and issue resolution.
Stay tuned for more advancements in our ongoing commitment to refining your development proces

db-migrator v0.2.3

04 Aug 13:32

Choose a tag to compare

🚀 Release v0.2.3 - Enhanced Control and Improved CLI Options

We are excited to announce the release of version 0.2.3, packed with improvements to the database migration process and optimization for better performance and data consistency. This release introduces the following key enhancements:

🔧 Database Migration Enhancements:

  • Statement logging for sqlx has been disabled to reduce log noise and improve logging readability (large queries caused thread crashes).
  • Fixed bug causing more tasks to be created than available SQL connections has been fixed.
  • Migration continuation from the last offset has been removed, ensuring a fresh and consistent migration of data.

📚 Code Refactor and Readability:

  • The codebase has undergone significant refactoring, enhancing code readability and maintainability.

✔️ Data Integrity Check:

  • Checks have been implemented to ensure that each output database table is empty before migration process, preventing broken data.

db-migrator v0.2.2

02 Aug 17:08

Choose a tag to compare

db-migrator v0.2.2 Pre-release
Pre-release

🚀 Release v0.2.2 - Enhanced Control and Improved CLI Options

What's New:

Constraints Creation Control 📏
Now you can exercise greater control over constraints creation with the new -c or --constraints command-line argument. Define custom constraints for your project effortlessly.

Parallelism Specification 🚀
We understand the importance of optimized performance. To address this, we've added the -p flag, allowing you to specify the desired parallelism level. By default, it will intelligently utilize your system's logical cores for improved execution speed.

Improved CLI Parameters 🛠️
As part of our commitment to a streamlined experience, we've made some changes to the CLI parameters:

The format_snake_case configuration option has been removed in favor of the new -f or --format command-line argument. Modify your output formatting on-the-fly.
The reset_tables configuration option has been eliminated and replaced with the -d or --drop command-line argument. Easily control table resets via the CLI.

db-migrator v0.2.1

01 Aug 20:19

Choose a tag to compare

db-migrator v0.2.1 Pre-release
Pre-release

🚀 Release v0.2.1 - Enhanced Database Migrations and Improved Error Output

What's New:

Table Constraints Export 📊
Managing table constraints is now a breeze! With this update, you can create and export table constraints directly from your input database, saving you time and effort. Enjoy a more efficient migration process with this enhanced functionality.

Resuming Migrations ⏩
No more starting from scratch! We've added a new feature that allows you to continue from the last migration offset.

Quiet Mode for Error Output 🔇
For those who prefer a more concise output, we've introduced the -q or --quiet flag. Enabling this option will output only errors, reducing unnecessary noise and providing a cleaner view of any potential issues.