You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add structured fluent operations and explicit SQL preview - #175
Builds on #174. Adds fluent authoring, operation records, automatic reversal, schema inspection, and offline SQL generation with planned-schema tracking. The legacy builder now creates complete tables. Unsupported preview operations fail explicitly and callbacks are never executed in structured preview. Includes execution-versus-preview SQLite tests and input snapshot tests. Further runner integration and documentation follow in the next PRs. Review and merge manually in stack order.
This reads a relative script path from the process working directory while the existing provider API resolves relative paths against CurrentMigration's assembly (TransformationProvider.ExecuteScript). Fluent migrations that call Execute.Script("...sql") will fail when launched from a different directory even though the equivalent provider operation works. Resolve relative paths with the same migration-aware rule or defer execution to the provider while defining the preview behavior.
AddTable execution emits indexes requested through ColumnProperty.Indexed—inline via JoinColumnsAndIndexes or as standalone indexes in providers such as DB2/Firebird/Informix/Sybase—but this preview renders only ColumnSql. A previewed create table can therefore lack an index that execution creates. Emit the corresponding provider-specific index statements or reject indexed columns explicitly instead of silently omitting them.
Create standalone indexes for indexed added columns
The new column fluent API lets callers set ColumnProperty.Indexed, but this add-column path relies on provider mapping alone. DB2/Firebird/Informix/Sybase set SupportsIndex = false; their AddColumn implementations only emit the mapped column and do not create the required standalone index, so Create.Column(...).WithProperty(ColumnProperty.Indexed) silently loses the index. Add the standalone index after the column or reject this combination explicitly.
When Index.Name is null, several providers synthesize a name and return it from AddIndex (for example IX_<table>_<columns>), but IndexOperation.Apply discards that return value and Reverse() stores null. Automatic reversal will then call RemoveIndex(table, null) and fail instead of dropping the index. Either capture/retain the generated name or require an explicit name for reversible index operations.
Use Oracle timestamp expressions for DateTime literals
This literal renders every DateTime as a bare quoted string. Oracle's dialect deliberately emits TO_TIMESTAMP(...) for DateTime defaults (src/Migrator/Providers/Impl/Oracle/OracleDialect.cs:138-142), so a previewed Oracle insert can depend on NLS settings or fail instead of inserting the same value as the parameterized execution path. Use the Oracle-specific dialect expression here.
Add Create/Alter/Delete/Rename/data/Execute/administration roots backed by operation records, immutable input snapshots, schema inspection and explicit provider callbacks. Build complete table definitions before execution, including the legacy builder adapter. Add automatic reversal for supported operations and reject unsupported preview/reversal rather than running callbacks. Track created and renamed tables during offline SQL generation. Validation: fluent snapshot, preview rejection, SQLite execution/preview equivalence and legacy-builder tests pass; unit and SQLite suites pass.
Reject insert-only modifiers on updates/deletes and reject raw delete predicates instead of silently deleting all rows. Dispatch complete table definitions through the provider's normal overload when no engine is specified. Retain legacy FK actions and defer conditional reversal until provider matching is known. Align preview identifier quoting with provider rules, render PostgreSQL82 booleans correctly and use Oracle RAW GUID conversion.
Validation: rebuilt solution; Unit 79 and SQLite 149 passed. Added regressions for invalid modifiers, inactive irreversible branches, preview identifiers/literals and actual legacy cascade-delete behavior. Addresses eight PR 175 review findings.
Map every normal API method family to fluent authoring, schema inspection or explicit context APIs, enforced by reflection coverage. Replace view/data-copy/update-from/database callbacks with typed operations and snapshot mutable definitions. Add schema query helpers and controlled command/connection callbacks. Reject structured SQL preview after raw SQL invalidates known schema and block administrative operations inside provider transactions.
Validation: rebuilt solution; Unit 84 and SQLite 154 passed before the final transaction guard. New tests cover persisted conditional inserts/updates/deletes, reader queries, pair snapshots and preview dependency rejection. Final guard and expanded provider coverage are checked on the next full build.
Delete.Row and Delete.Set now fail during authoring instead of silently ignoring row data and potentially deleting an entire table. DataOperation also rejects nonempty row fields when callers bypass the builder. Keep structured Where predicates as the delete input.
Validation: build, Unit 85 passed, SQLite 154 passed. Regression asserts no provider Delete call occurs for invalid modifiers. Addresses reviews 4072049125 and 4072049185.
Represent loaded scripts separately from raw SQL so execution uses provider batch handling and preview preserves client separators. Validate SQL Server GO syntax before preview output and invalidate schema knowledge after arbitrary scripts. Add a regression for file/resource operation capture and unchanged batch boundaries.
Validation: build, Unit 90 passed and SQLite 155 passed.
…operations
Validate the complete authored operation list before executing its first operation. Reversible and conditional wrappers propagate validation only for their active operations, so a database-administration expression cannot be discovered after earlier schema changes. Apply the same path to builders, fluent Up/Down and automatic reversal.
Validation: solution build, Unit 91 passed, SQLite 158 passed. Regression checks no earlier table is created and an inactive provider-specific operation does not block execution.
Verify one complete table definition reaches the provider, including type, primary key, size and default. Assert foreign-key ordering, direction and action, and verify existing-table columns use AddColumn without creating a table. Remove seven tests whose assertions were commented out.
Validation: solution build and Unit 88 passed; fewer test cases now cover meaningful observable behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #174. Adds fluent authoring, operation records, automatic reversal, schema inspection, and offline SQL generation with planned-schema tracking. The legacy builder now creates complete tables. Unsupported preview operations fail explicitly and callbacks are never executed in structured preview. Includes execution-versus-preview SQLite tests and input snapshot tests. Further runner integration and documentation follow in the next PRs. Review and merge manually in stack order.