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
Commit 97280c2
Browse filesBrowse the repository at this point in the historyBrowse files
- support independent migration scopes
- preserve global migration application order
- store scope-local migration sequences
- validate migration histories independently for each scope
- support multiple scopes within the same transaction
- expand migration tests and documentation
-**ADO.NET Utilities**: Provides helpers for commands, parameters, readers, data adapters, schema inspection, and common SQLite operations.
17
17
-**Allocation-Conscious APIs**: Provides span-based parameters, `ValueTask`-based coordination, and explicit-state callbacks that help avoid closure allocations.
18
-
-**Database Migrations**: Applies ordered schema and data migrations transactionally, records migration history with optional version metadata, and validates that the applied history matches the configured migration sequence.
18
+
-**Database Migrations**: Applies ordered schema and data migrations transactionally, supports independent migration scopes, preserves global application order, records optional version metadata, and strictly validates each configured migration sequence.
19
19
20
20
## Why NuExt.System.Data.SQLite?
21
21
22
22
`NuExt.System.Data.SQLite` is designed as a performance-oriented infrastructure layer over ADO.NET rather than an ORM. It keeps SQL, commands, parameters, readers, and transactions explicit while removing repetitive connection, transaction, and resource lifecycle code. It also preserves SQLite's synchronous execution model instead of wrapping database operations in artificial asynchronous work.
23
23
24
-
The library supports both standalone DAL operations and coordinated units of work, protects complete database operation scopes during concurrent and reentrant execution, and provides forward-only migrations with deterministic ordering and strict history validation.
24
+
The library supports both standalone DAL operations and coordinated units of work, protects complete database operation scopes during concurrent and reentrant execution, and provides forward-only migrations with deterministic ordering, independent scopes, and strict history validation.
25
25
26
26
The result is a lightweight data access foundation that adds predictable resource ownership, transaction coordination, and schema evolution without introducing change tracking, SQL generation, or a custom query language.
27
27
@@ -83,24 +83,58 @@ internal sealed class CreateMoviesSchema_0001 : SQLiteDbMigration
Migrations are applied in the order in which they are registered. Applied migrations are recorded in the `__nuext_migrations` table together with their application time and optional version information. When a connection factory is used, the complete migration batch is executed within a synchronized transaction and is rolled back if any migration fails. Migrations can also run within an existing `SQLiteDbContext`, allowing migration and application operations to share the same caller-owned transaction.
122
+
Migrations are applied in the order in which they are registered. Each migration scope maintains an independent ordered sequence, and its applied history must be an exact prefix of the configured migration sequence.
123
+
124
+
Applied migrations are recorded in the `__nuext_migrations` table with a global history identifier, scope-local sequence, application time, and optional version information. This preserves the complete migration chronology while allowing the application core and independently installed modules to maintain separate migration chains.
125
+
126
+
`Migrate` uses the default migration scope, while `MigrateScope` applies migrations to an explicitly named scope. Scope identifiers must remain stable after deployment because changing a scope creates a separate migration history.
127
+
128
+
When a connection factory is used, the complete migration batch is executed within a synchronized transaction and is rolled back if any migration fails. Migrations from multiple scopes can also run within an existing `SQLiteDbContext`, allowing core, module, and application operations to share the same caller-owned transaction.
95
129
96
130
## Commonly Used Types
97
131
98
-
-**`System.Data.SQLite.SQLiteDalBase`**: Base class for SQLite DAL implementations with synchronized provider-managed context execution and access to connection creation for custom scenarios.
99
-
-**`System.Data.SQLite.SQLiteDbConnection`**: Wraps SQLite connections with process-local synchronization, transaction coordination, command execution, schema inspection, and common data access utilities.
100
-
-**`System.Data.SQLite.SQLiteDbContext`**: Manages connection state and transaction lifetime, with optional validation that the connection lock remains held for the lifetime of the context.
101
-
-**`System.Data.SQLite.SQLiteDbMigration`**: Base class for defining ordered SQLite schema and data migrations.
102
-
-**`System.Data.SQLite.SQLiteDbMigrationContext`**: Provides the execution context used by SQLite migrations.
103
-
-**`System.Data.SQLite.SQLiteDbTransaction`**: Wraps SQLite transactions with explicit state tracking, commit and rollback operations, and transaction lifetime diagnostics.
132
+
-**`SQLiteDalBase`**: Base class for SQLite DAL implementations with synchronized provider-managed context execution and access to connection creation for custom scenarios.
133
+
-**`SQLiteDbConnection`**: Wraps SQLite connections with process-local synchronization, transaction coordination, command execution, schema inspection, and common data access utilities.
134
+
-**`SQLiteDbTransaction`**: Wraps SQLite transactions with explicit state tracking, commit and rollback operations, and transaction lifetime diagnostics.
135
+
-**`SQLiteDbContext`**: Manages connection state and transaction lifetime, with optional validation that the connection lock remains held for the lifetime of the context.
136
+
-**`SQLiteDbMigration`**: Base class for defining forward-only SQLite schema and data migrations within ordered, independently validated scopes.
137
+
-**`SQLiteDbMigrationContext`**: Provides the execution context used by SQLite migrations.
Copy file name to clipboardExpand all lines: src/System/Data/SQLite/SQLiteDbMigrationExtensions.cs
+74-8Lines changed: 74 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -6,39 +6,69 @@
6
6
publicstaticclassSQLiteDbMigrationExtensions
7
7
{
8
8
/// <summary>
9
-
/// Applies all pending migrations to a SQLite database.
9
+
/// Applies all pending migrations to the default migration scope of a SQLite database.
10
10
/// </summary>
11
11
/// <param name="migrations">The migrations in the order in which they must be applied.</param>
12
12
/// <param name="createConnection">A function that creates a SQLite database connection.</param>
13
13
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
14
14
/// <exception cref="ArgumentNullException"><paramref name="migrations"/> or <paramref name="createConnection"/> is <see langword="null"/>.</exception>
/// Applies all pending migrations to a SQLite database.
21
+
/// Applies all pending migrations to the default migration scope of a SQLite database.
22
22
/// </summary>
23
23
/// <param name="migrations">The migrations in the order in which they must be applied.</param>
24
24
/// <param name="createConnection">A function that creates a SQLite database connection.</param>
25
25
/// <param name="version">Optional version information to record for each applied migration.</param>
26
26
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
27
27
/// <exception cref="ArgumentNullException"><paramref name="migrations"/> or <paramref name="createConnection"/> is <see langword="null"/>.</exception>
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
40
+
/// <exception cref="ArgumentNullException"><paramref name="migrations"/> or <paramref name="createConnection"/> is <see langword="null"/>.</exception>
41
+
/// <exception cref="ArgumentException"><paramref name="scope"/> is <see langword="null"/>, empty, or consists only of white-space characters.</exception>
/// <param name="version">Optional version information to record for each applied migration.</param>
54
+
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
55
+
/// <exception cref="ArgumentNullException"><paramref name="migrations"/> or <paramref name="createConnection"/> is <see langword="null"/>.</exception>
56
+
/// <exception cref="ArgumentException"><paramref name="scope"/> is <see langword="null"/>, empty, or consists only of white-space characters.</exception>
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
108
+
/// <exception cref="ArgumentNullException"><paramref name="migrations"/> or <paramref name="dbContext"/> is <see langword="null"/>.</exception>
109
+
/// <exception cref="ArgumentException"><paramref name="scope"/> is <see langword="null"/>, empty, or consists only of white-space characters.</exception>
110
+
/// <remarks>
111
+
/// The caller owns the database context and is responsible for committing or rolling back its transaction.
/// <param name="version">Optional version information to record for each applied migration.</param>
125
+
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
126
+
/// <exception cref="ArgumentNullException"><paramref name="migrations"/> or <paramref name="dbContext"/> is <see langword="null"/>.</exception>
127
+
/// <exception cref="ArgumentException"><paramref name="scope"/> is <see langword="null"/>, empty, or consists only of white-space characters.</exception>
128
+
/// <remarks>
129
+
/// The caller owns the database context and is responsible for committing or rolling back its transaction.
0 commit comments