CloudflareD1.NET.Migrations 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package CloudflareD1.NET.Migrations --version 1.0.1
                    
NuGet\Install-Package CloudflareD1.NET.Migrations -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CloudflareD1.NET.Migrations" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CloudflareD1.NET.Migrations" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="CloudflareD1.NET.Migrations" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CloudflareD1.NET.Migrations --version 1.0.1
                    
#r "nuget: CloudflareD1.NET.Migrations, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CloudflareD1.NET.Migrations@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CloudflareD1.NET.Migrations&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=CloudflareD1.NET.Migrations&version=1.0.1
                    
Install as a Cake Tool

CloudflareD1.NET.Migrations

NuGet License: MIT

Database migration system for CloudflareD1.NET with fluent API and version tracking.

Features

  • Fluent Migration API: Chain methods to build complex migrations
  • Version Tracking: Automatic history in __migrations table
  • Up/Down Migrations: Full rollback support
  • Type-Safe Schema Building: Strongly typed column definitions
  • Full DDL Support: CREATE/ALTER/DROP tables, indexes, constraints
  • Programmatic & CLI: Use in code or via CLI tool
  • Well Tested: 29 unit tests + integration tests

Installation

dotnet add package CloudflareD1.NET.Migrations

For CLI tool:

dotnet tool install -g dotnet-d1

Quick Start

Create a Migration

using CloudflareD1.NET.Migrations;

public class CreateUsersTable : Migration
{
    public override void Up(MigrationBuilder builder)
    {
        builder.CreateTable("users", t =>
        {
            t.Integer("id").PrimaryKey().AutoIncrement();
            t.Text("name").NotNull();
            t.Text("email").NotNull().Unique();
            t.Integer("age");
            t.Text("created_at").Default("CURRENT_TIMESTAMP");
        });

        builder.CreateIndex("users", "idx_users_email", "email");
    }

    public override void Down(MigrationBuilder builder)
    {
        builder.DropTable("users");
    }
}

Run Migrations Programmatically

using CloudflareD1.NET;
using CloudflareD1.NET.Migrations;
using System.Reflection;

var client = new D1Client(config);
var runner = new MigrationRunner(client, Assembly.GetExecutingAssembly());

// Apply all pending migrations
await runner.MigrateAsync();

// Rollback last migration
await runner.RollbackAsync();

// Get migration history
var history = await runner.GetAppliedMigrationsAsync();

CLI Usage

# Add a new migration
dotnet d1 migrations add CreateUsersTable

# Apply pending migrations
dotnet d1 migrations update

# List migrations
dotnet d1 migrations list

# Rollback last migration
dotnet d1 migrations rollback

Migration API

Table Operations

  • CreateTable(name, columns) - Create new table
  • DropTable(name) - Drop existing table
  • AlterTable(name, columns) - Modify table structure

Column Types

  • Integer(name) - Integer column
  • Real(name) - Floating point column
  • Text(name) - Text/string column
  • Blob(name) - Binary data column

Column Modifiers

  • .PrimaryKey() - Mark as primary key
  • .AutoIncrement() - Auto-incrementing values
  • .NotNull() - NOT NULL constraint
  • .Unique() - UNIQUE constraint
  • .Default(value) - Default value

Index Operations

  • CreateIndex(table, name, column) - Create index
  • CreateUniqueIndex(table, name, column) - Create unique index
  • DropIndex(table, name) - Drop index

Raw SQL

  • ExecuteRaw(sql) - Execute custom SQL

Documentation

Full documentation is available at https://jdtoon.github.io/CloudflareD1.NET/docs/migrations/overview

License

MIT License - see LICENSE for details

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CloudflareD1.NET.Migrations:

Package Downloads
CloudflareD1.NET.CodeFirst

Code-First ORM for CloudflareD1.NET. Define your database schema using C# classes and attributes, with automatic migration generation. Includes DbContext pattern, entity relationships, and model-driven development similar to Entity Framework Core but optimized for Cloudflare D1 and SQLite.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 197 10/28/2025
1.0.1 260 10/27/2025
1.0.0 168 10/27/2025

v1.0.1: Documentation improvements and package README. v1.0.0: Initial release with migration support, fluent MigrationBuilder API, history tracking, and rollback capabilities.