--- title: "Release Notes v0.4.4" description: "Release notes for RoomSharp 0.4.4" canonical: "https://roomsharp.dev/docs/v0.4.7/release-notes-0-4-4" source: "src/content/v0.4.7/release-notes-0-4-4.mdx" --- # RoomSharp 0.4.4 – Release Notes ## Highlights - **Fluent Migration DX Enhancements**: Improved developer experience with fluent column chaining, convenience methods, and TypeAffinity alias. - **Programmatic Seeding API**: New `db.SeedAsync()` API for MAUI/mobile apps where CLI seeding is not possible. - **RoomSeeder Base Class**: Optional strongly-typed base class for cleaner seeder implementations. - **Security & Stability Fixes**: SQL injection prevention, deadlock fixes, and compiler warning cleanup. --- ## New Features ### Fluent Migration Improvements - **Fluent Column Chaining**: All `ColumnBuilder` configuration methods now return `this` for fluent chaining. ```csharp table.Column("email").Nullable().Unique() .Column("createdAt").DefaultExpression("CURRENT_TIMESTAMP"); ``` - **TypeAffinity Alias**: Added `TypeAffinity(string sqlType)` as a more descriptive alternative to `Type(string)`. - **Convenience Methods** for `TableBuilder`: - `Id()` – auto-increment primary key - `CreatedAt()` / `UpdatedAt()` / `Timestamps()` – timestamp columns - `SoftDelete()` – `deleted_at` nullable timestamp - `IsActive()` – boolean with default true - `String()` / `Int()` / `Bool()` – typed columns with fluent config - **Direct Fluent Syntax** via `ColumnChain`: ```csharp table.Column("name").NotNull().Unique(); // Returns ColumnChain ``` ### Programmatic Seeding API - **`db.SeedAsync()`**: Run seeders programmatically for MAUI/mobile apps. ```csharp await db.SeedAsync(); // Discover and run all seeders await db.SeedAsync(new SeederOptions { Environment = "Development", Seeders = new[] { new CurrencySeeder() } }); ``` - **`SeederOptions`**: Configuration record for programmatic seeding (Environment, AllowProduction, DryRun, Force, ContinueOnError). - **`SeederContext` Enhancements**: - Builder pattern with `SeederContext.Create(db).WithEnvironment(...).Build()` - Environment helpers: `IsDevelopment`, `IsProduction`, `IsEnvironment(string)` - `Connection` property for raw SQL access - **`SeederContextExtensions`**: Helper methods for common seeding patterns: - `ExecuteAsync(sql)` / `ExecuteAsync(sql, parameters)` - `ExecuteScalarAsync(sql)` - `IsTableEmptyAsync(tableName)` / `TableExistsAsync(tableName)` - `SeedIfEmptyAsync(tableName, insertAsync, entities...)` - `SeedInDevelopmentAsync(action)` / `SeedInEnvironmentsAsync(envs, action)` - **`RoomSeeder` Base Class**: Optional base for seeders with common helpers. - **`RoomSeeder`**: Strongly-typed base class for direct access to database and DAOs. ```csharp [Seeder(Order = 1)] public class CurrencySeeder : RoomSeeder { protected override async ValueTask SeedCoreAsync(SeederContext ctx, MyAppDatabase db) { await ctx.SeedIfEmptyAsync("currencies", db.CurrencyDao.InsertAsync, new Currency { Code = "USD" }, new Currency { Code = "EUR" }); } } ``` --- ## Improvements ### Documentation - Updated README.md with Fluent Column Chaining section. - Updated README.md with Programmatic Seeding section. - Updated migrations.mdx with Programmatic Seeding documentation. ### CLI Compatibility - Updated `RoomSharp.Cli.Host` to use new `SeederContext` builder pattern. ### PagingSource - Added optional `ILogger` parameter for better error diagnostics when page loading fails. ### RoomSharp.Cli - New Commands #### Migration Commands - **`migrate:rollback`**: Roll back migrations with `IReversibleMigration` support. ```bash room migrate:rollback --steps=3 # Roll back 3 steps room migrate:rollback --to=5 # Roll back to version 5 ``` - **`migrate:timeline`**: Visual migration history with success/failure status and execution time. ```bash room migrate:timeline ``` #### Inspection Commands - **`db:stats`**: Display database statistics (size, tables, rows, indexes). ```bash room db:stats ``` - **`generate:diagram`**: Generate ERD diagrams in Mermaid or DBML format. ```bash room generate:diagram --output=schema.dbml --format=dbml ``` #### Scaffolding Commands - **`make:view `**: Scaffold DatabaseView entity for SQL views. ```bash room make:view UserStats --view=user_stats ``` - **`make:converter `**: Scaffold TypeConverter class for custom type mappings. ```bash room make:converter JsonConverter --from=MyType --to=string ``` ### RoomSharp.Cli - Config Enhancements - **New config paths**: Added `views`, `converters`, `repositories` paths to `room.config.json`. - **`IReversibleMigration`**: New interface for migrations that support rollback via `DownAsync`. --- ## Fixes ### Security - **SQL Injection Prevention**: Fixed `SchemaGenerator.TableExists()` to use parameterized queries instead of string interpolation. ### Stability - **Deadlock Prevention**: Fixed potential deadlock in `ObservableQuery.Publish()` when using `DeliveryMode.All` by replacing blocking `GetAwaiter().GetResult()` with non-blocking `TryWrite`. - **Compiler Warnings**: Fixed CS8509 (non-exhaustive switch) in `ILFactory.RefReader.cs` and CS8601 (null reference) in `InsertStatementBuilder.cs`. --- ## Breaking Changes - `SeederContext` constructor is now private; use `SeederContext.Create(db)` builder pattern. - `SeederContext.Journal` property removed (internal implementation detail). --- ## Upgrade Notes - No breaking changes for existing seeder implementations using `IRoomSeeder` interface directly. - If you were creating `SeederContext` manually (advanced usage), switch to the builder pattern: ```csharp var ctx = SeederContext.Create(database) .WithEnvironment("Development") .WithLogger(msg => Console.WriteLine(msg)) .Build(); ```