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
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,34 @@ public override void Down()
```csharp
public override void BuildUp(MigrationBuilder migration)
{
migration.Create.Column("Email", "Users").AsString(320);
migration.Create.Column("Email").OnTable("Users").AsString(320);
}

public override void BuildDown(MigrationBuilder migration)
{
migration.Delete.Column("Email", "Users");
migration.Delete.Column("Email").FromTable("Users");
}
```

Fluent expressions name the table separately: `Create.Column(name).OnTable(table)`,
`Alter.Column(name).OnTable(table)` and `Delete.Column(name).FromTable(table)`.
Renames read `Rename.Column(oldName).OnTable(table).To(newName)`. Indexes and
constraints follow the same pattern:

```csharp
migration.Create.Index("IX_Users_Email").OnTable("Users").WithColumns("Email").Unique();
migration.Create.ForeignKey("FK_Orders_Users")
.FromTable("Orders").WithColumns("UserId")
.ToTable("Users").WithColumns("Id")
.OnDelete(ForeignKeyConstraintType.Cascade);
```

Table, create-column and alter-column builders share type and option methods;
each column requires `As...` or `OfType(...)`. Update and delete require a
predicate or explicit `AllRows()`. Unfinished expressions fail before execution.
See the [API map](https://dotnetprojects.github.io/Migrator.NET/guide/api-map.html)
for the complete syntax.

Provider implementations determine which operations are available and how they map to SQL. Use `Database.ExecuteNonQuery(...)` or `migration.Execute.Sql(...)` for custom SQL and keep dialect-specific statements explicit. The [Classic/Fluent API map](https://dotnetprojects.github.io/Migrator.NET/guide/api-map.html) lists the corresponding operations.

### Explicit constraints, SQL defaults and collations
Expand Down
78 changes: 39 additions & 39 deletions docs/_src/content.py

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions docs/assets/search-index.json

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions docs/fluent-operation-coverage.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
{
"AddTable": "Create.Table(...).WithFields(...) / WithEngine(...)",
"AddColumn": "Create.Column(...).OfType(...).WithPrecision(...)",
"ChangeColumn": "Alter.Column(...).OfType(...).WithPrecision(...)",
"AddPrimaryKey": "Create.PrimaryKey(...) / Create.NonClusteredPrimaryKey(...)",
"AddPrimaryKeyNonClustered": "Create.PrimaryKey(...) / Create.NonClusteredPrimaryKey(...)",
"AddForeignKey": "Create.ForeignKey(...); supply a generated name for GenerateForeignKey convenience overloads",
"GenerateForeignKey": "Create.ForeignKey(...); supply a generated name for GenerateForeignKey convenience overloads",
"AddUniqueConstraint": "Create.Unique(...) / Create.Check(...)",
"AddCheckConstraint": "Create.Unique(...) / Create.Check(...)",
"AddIndex": "Create.Index(table, Index)",
"AddView": "Create.View(...), both view-definition forms",
"RemoveTable": "Delete.Table/Column/ForeignKey/Constraint/PrimaryKey/Default/Index/AllIndexes/AllConstraints/ForeignKeysForColumn",
"RemoveColumn": "Delete.Table/Column/ForeignKey/Constraint/PrimaryKey/Default/Index/AllIndexes/AllConstraints/ForeignKeysForColumn",
"RemoveForeignKey": "Delete.Table/Column/ForeignKey/Constraint/PrimaryKey/Default/Index/AllIndexes/AllConstraints/ForeignKeysForColumn",
"RemoveConstraint": "Delete.Table/Column/ForeignKey/Constraint/PrimaryKey/Default/Index/AllIndexes/AllConstraints/ForeignKeysForColumn",
"RemovePrimaryKey": "Delete.Table/Column/ForeignKey/Constraint/PrimaryKey/Default/Index/AllIndexes/AllConstraints/ForeignKeysForColumn",
"RemoveColumnDefaultValue": "Delete.Table/Column/ForeignKey/Constraint/PrimaryKey/Default/Index/AllIndexes/AllConstraints/ForeignKeysForColumn",
"RemoveIndex": "Delete.Table/Column/ForeignKey/Constraint/PrimaryKey/Default/Index/AllIndexes/AllConstraints/ForeignKeysForColumn",
"RemoveAllIndexes": "Delete.Table/Column/ForeignKey/Constraint/PrimaryKey/Default/Index/AllIndexes/AllConstraints/ForeignKeysForColumn",
"RemoveAllConstraints": "Delete.Table/Column/ForeignKey/Constraint/PrimaryKey/Default/Index/AllIndexes/AllConstraints/ForeignKeysForColumn",
"RemoveAllForeignKeys": "Delete.Table/Column/ForeignKey/Constraint/PrimaryKey/Default/Index/AllIndexes/AllConstraints/ForeignKeysForColumn",
"RenameTable": "Rename.Table(...) / Rename.Column(...)",
"RenameColumn": "Rename.Table(...) / Rename.Column(...)",
"AddColumn": "Create.Column(name).OnTable(table).OfType(...) / Create.Column(definition).OnTable(table)",
"ChangeColumn": "Alter.Column(name).OnTable(table).OfType(...) / Alter.Column(definition).OnTable(table)",
"AddPrimaryKey": "Create.PrimaryKey(name).OnTable(table).WithColumns(...)",
"AddPrimaryKeyNonClustered": "Create.NonClusteredPrimaryKey(name).OnTable(table).WithColumns(...)",
"AddForeignKey": "Create.ForeignKey(name).FromTable(child).WithColumns(...).ToTable(parent).WithColumns(...).OnDelete(...).OnUpdate(...)",
"GenerateForeignKey": "Create.ForeignKey(name).FromTable(child).WithColumns(...).ToTable(parent).WithColumns(...); supply the generated name explicitly",
"AddUniqueConstraint": "Create.UniqueConstraint(name).OnTable(table).WithColumns(...)",
"AddCheckConstraint": "Create.CheckConstraint(name).OnTable(table).WithExpression(sql)",
"AddIndex": "Create.Index(name).OnTable(table).WithColumns(...) / Create.Index(definition).OnTable(table)",
"AddView": "Create.View(name).FromTable(table).WithFields(...) / WithElements(...)",
"RemoveTable": "Delete.Table(table)",
"RemoveColumn": "Delete.Column(name).FromTable(table)",
"RemoveForeignKey": "Delete.ForeignKey(name).FromTable(table)",
"RemoveConstraint": "Delete.Constraint(name).FromTable(table)",
"RemovePrimaryKey": "Delete.PrimaryKey().FromTable(table)",
"RemoveColumnDefaultValue": "Delete.DefaultValue(column).FromTable(table)",
"RemoveIndex": "Delete.Index(name).FromTable(table)",
"RemoveAllIndexes": "Delete.AllIndexes().FromTable(table)",
"RemoveAllConstraints": "Delete.AllConstraints().FromTable(table)",
"RemoveAllForeignKeys": "Delete.ForeignKeysForColumn(column).FromTable(table)",
"RenameTable": "Rename.Table(oldName).To(newName)",
"RenameColumn": "Rename.Column(oldName).OnTable(table).To(newName)",
"Insert": "Insert.IntoTable(...).Row(...)[.IfNotExists(...)]",
"InsertIfNotExists": "Insert.IntoTable(...).Row(...)[.IfNotExists(...)]",
"Update": "Update.Table(...).Set(...).Where(...) / WhereSql(...)",
"Delete": "Delete.FromTable(...).Where(...)",
"Update": "Update.Table(table).Set(...).Where(...) / WhereSql(...) / AllRows()",
"Delete": "Delete.FromTable(table).Where(...) / AllRows()",
"TruncateTable": "Execute.Truncate(...)",
"CopyDataFromTableToTable": "Execute.CopyData(...) / Execute.UpdateFrom(...)",
"UpdateTargetFromSource": "Execute.CopyData(...) / Execute.UpdateFrom(...)",
"CopyDataFromTableToTable": "Execute.CopyDataFromTable(source).ToTable(target).WithColumns(sourceColumns, targetColumns).OrderBy(...)",
"UpdateTargetFromSource": "Execute.UpdateTable(target).FromTable(source).Set(copyPairs).Match(keyPairs)",
"ExecuteNonQuery": "Execute.Sql(...) / Script(...) / EmbeddedScript(...)",
"ExecuteQuery": "Schema.Query(...) / Strings(...) / Scalar(...) / NullableScalar<T>(...)",
"ExecuteStringQuery": "Schema.Query(...) / Strings(...) / Scalar(...) / NullableScalar<T>(...)",
"ExecuteScalar": "Schema.Query(...) / Strings(...) / Scalar(...) / NullableScalar<T>(...)",
"Select": "Schema.Select(...) / SelectScalar(...); raw selection overloads through explicit Context",
"SelectComplex": "Schema.Select(...) / SelectScalar(...); raw selection overloads through explicit Context",
"SelectScalar": "Schema.Select(...) / SelectScalar(...); raw selection overloads through explicit Context",
"Select": "Schema.Table(table).Select(...); raw selection overloads through explicit Context",
"SelectComplex": "Schema.Table(table).Select(...)",
"SelectScalar": "Schema.Table(table).SelectScalar(columns, where)",
"GetColumns": "Schema.Table(...).Columns/Column/Indexes/ForeignKeys/ContentSize/NullableContentSize",
"GetColumnByName": "Schema.Table(...).Columns/Column/Indexes/ForeignKeys/ContentSize/NullableContentSize",
"GetIndexes": "Schema.Table(...).Columns/Column/Indexes/ForeignKeys/ContentSize/NullableContentSize",
Expand All @@ -60,7 +60,7 @@
"DropDatabases": "Administration.CreateDatabase/DropDatabase/SwitchDatabase/KillConnections",
"SwitchDatabase": "Administration.CreateDatabase/DropDatabase/SwitchDatabase/KillConnections",
"KillDatabaseConnections": "Administration.CreateDatabase/DropDatabase/SwitchDatabase/KillConnections",
"IsThisProvider": "IfDatabase(...); Context.IsThisProvider(...) for imperative branching",
"IsThisProvider": "IfProvider(...); Context.IsThisProvider(...) for imperative branching",
"CreateCommand": "Execute.WithCommand(...); explicit Context for advanced command lifetime",
"GetCommand": "Execute.WithCommand(...); explicit Context for advanced command lifetime",
"BeginTransaction": "Explicit Context history/transaction APIs; not schema expressions",
Expand Down
16 changes: 8 additions & 8 deletions docs/fluent-operation-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ The machine-readable [inventory](fluent-operation-coverage.json) maps every name

| Capability | Authoring / inspection | Validation evidence |
| --- | --- | --- |
| Complete tables, columns, types, defaults, identity, nullability and precision | `Create.Table`, `Create.Column`, `Alter.Column` | Complete table snapshot, SQLite schema/data, provider precision tests |
| Keys, foreign-key actions, unique/check constraints | `Create.PrimaryKey`, `ForeignKey`, `Unique`, `Check` | Provider constraint/action suites; unsupported providers throw |
| Index keys, include/filter/cluster options | `Create.Index` with the existing `Index` model | Provider index suites; preview rejects unsupported options |
| Views and joins | `Create.View` with either normal definition model | Definitions snapshot caller input; provider implementations retain their own limitations |
| Complete tables, columns, types, defaults, identity, nullability and precision | `Create.Table(...).WithColumn(...)`, `Create.Column(...).OnTable(...)`, `Alter.Column(...).OnTable(...)` | Shared column options, independent column handles and snapshots, SQLite schema/data |
| Keys, foreign-key actions, unique/check constraints | `Create.PrimaryKey/UniqueConstraint/CheckConstraint(...).OnTable(...)`; `Create.ForeignKey(...).FromTable(...).WithColumns(...).ToTable(...).WithColumns(...).OnDelete(...).OnUpdate(...)` | Composite key order, independent actions and provider dispatch; unsupported providers throw |
| Index keys, include/filter/cluster options | `Create.Index(name).OnTable(table).WithColumns(...)` or `Create.Index(definition).OnTable(table)` | Input/build snapshots, provider index suites; preview rejects unsupported options |
| Views and joins | `Create.View(name).FromTable(table).WithFields(...)` or `.WithElements(...)` | Definitions snapshot caller input; provider implementations retain their own limitations |
| Drop/rename operations | `Delete` / `Rename` | SQLite schema tests, reversal tests; destructive changes need explicit reverse definitions |
| Inserts, conditional insert, update, delete | `Insert`, `Update`, `Delete.FromTable` | FluentDataChangesAndSchemaReadsPersistExpectedRows |
| Truncate, data copy, update from another table | `Execute.Truncate/CopyData/UpdateFrom` | Normal provider tests; mutable pair snapshot regression |
| Inserts, conditional insert, update, delete | `Insert.IntoTable(...).Row(...).IfNotExists(...)`, `Update.Table(...).Set(...).Where(...)`, `Delete.FromTable(...).Where(...)`; explicit `AllRows()` for unfiltered update/delete | Persisted rows, invalid/incomplete expressions rejected before execution |
| Truncate, data copy, update from another table | `Execute.Truncate(table)`, `Execute.CopyDataFromTable(source).ToTable(target).WithColumns(...)`, `Execute.UpdateTable(target).FromTable(source).Set(...).Match(...)` | SQLite copy, normal provider tests, mutable pair snapshots |
| SQL, files, resources | `Execute.Sql/Script/EmbeddedScript` | SQL execution/preview tests; SQL Server GO batch splitting through the script APIs, with explicit rejection of unsupported client directives |
| Scalars/readers/existence/metadata | `Schema`, `Schema.Table`, `Select`, `SelectScalar` | Reader disposal and persisted-data assertions; nullable helpers are additive |
| Scalars/readers/existence/metadata | `Schema`, `Schema.Table(table).Select(...) / SelectScalar(...)` | Reader disposal and persisted-data assertions; nullable helpers are additive |
| Database administration | `Administration` | Typed operations flag transaction incompatibility; backend capabilities still apply |
| Provider conditions, commands/connections | `IfDatabase`, `Execute.WithCommand/WithConnection/WithProvider` | Inactive reversal, explicit preview rejection; callbacks execute trusted code |
| Provider conditions, commands/connections | `IfProvider`, `Execute.WithCommand/WithConnection/WithProvider` | Inactive reversal, explicit preview rejection; callbacks execute trusted code |
| History and transaction administration | Explicit `Context` | Runner transaction/scope/history regressions; not schema expressions |

Execution coverage is broader than SQL-generation and automatic-reversal coverage. Unsupported preview/reversal operations fail explicitly. The inventory is an API coverage check, not a claim that every overload has an independent live test on every engine. Continue adding behavioral provider tests when changing an operation's semantics.
Loading
Loading