Flowgrate 0.1.1
dotnet add package Flowgrate --version 0.1.1
NuGet\Install-Package Flowgrate -Version 0.1.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="Flowgrate" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Flowgrate" Version="0.1.1" />
<PackageReference Include="Flowgrate" />
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 Flowgrate --version 0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Flowgrate, 0.1.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 Flowgrate@0.1.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=Flowgrate&version=0.1.1
#tool nuget:?package=Flowgrate&version=0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
flowgrate/dotnet
C# SDK for Flowgrate — Laravel-style database migrations with a fluent API.
How it works
Define migrations in C# using the fluent Blueprint API. The SDK serializes them to JSON and pipes to the Flowgrate CLI, which compiles and executes the SQL.
Requirements
- Flowgrate CLI — download the binary for your platform and put it on your
PATH
# Linux / macOS
curl -L https://github.com/flowgrate/core/releases/latest/download/flowgrate-linux-amd64 -o flowgrate
chmod +x flowgrate
sudo mv flowgrate /usr/local/bin/
# Or build from source
go install github.com/flowgrate/core@latest
Setup
1. Reference the SDK in your migrations project:
<ProjectReference Include="path/to/Flowgrate/Flowgrate.csproj" />
2. Add Program.cs:
using System.Reflection;
using Flowgrate;
FlowgrateRunner.Run(Assembly.GetExecutingAssembly());
3. Create flowgrate.yml next to your project:
Generate it with the CLI (recommended):
flowgrate init --db=postgres://user:pass@localhost/mydb
Or create manually:
database:
url: postgres://user:pass@localhost/mydb
migrations:
project: ./Migrations
sdk: csharp
4. Generate and run migrations:
flowgrate make CreateUsersTable
flowgrate up
Migration anatomy
using Flowgrate;
public class _20260402_163107_CreateUsersTable : Migration
{
public static string Version => "20260402_163107";
public override void Up()
{
Schema.Create("users", table =>
{
table.Id();
table.String("name");
table.String("email", 100);
table.Timestamps();
});
}
public override void Down()
{
Schema.DropIfExists("users");
}
}
Blueprint API reference
Create / drop table
Schema.Create("users", table => { ... });
Schema.Table("users", table => { ... }); // ALTER TABLE
Schema.Drop("users");
Schema.DropIfExists("users");
Column types
table.Id() // BIGSERIAL PRIMARY KEY
table.SmallInteger("level") // SMALLINT
table.Integer("views") // INTEGER
table.BigInteger("score") // BIGINT
table.Decimal("price", 10, 2) // NUMERIC(10, 2)
table.Float("rating") // REAL
table.Double("latitude") // DOUBLE PRECISION
table.Boolean("active") // BOOLEAN
table.String("name") // VARCHAR(255)
table.String("code", 10) // VARCHAR(10)
table.Text("bio") // TEXT
table.Uuid("public_id") // UUID
table.Json("settings") // JSON
table.Jsonb("metadata") // JSONB
table.Binary("avatar") // BYTEA
table.Date("birthday") // DATE
table.Time("opens_at") // TIME
table.Timestamp("verified_at") // TIMESTAMP
Column modifiers (chainable)
.Nullable() // NULL
.Default(value) // DEFAULT 'value'
.DefaultExpression("NOW()") // DEFAULT NOW() — raw SQL
.GeneratedUuid() // DEFAULT gen_random_uuid()
.Comment("description")
.Unique() // single-column unique index
Helpers
table.Timestamps() // created_at + updated_at TIMESTAMP DEFAULT NOW()
table.SoftDeletes() // deleted_at TIMESTAMP NULL
table.RememberToken() // remember_token VARCHAR(100) NULL
table.Polymorphic("commentable") // commentable_id BIGINT + commentable_type VARCHAR(255) + index
table.NullablePolymorphic("taggable")
Foreign keys
table.ForeignId("role_id")
.Constrained("roles") // REFERENCES roles(id)
.OnDelete("cascade")
.OnUpdate("cascade");
Indexes
table.Unique("email", "tenant_id").Name("uq_users_email_tenant");
table.Index("created_at");
table.Index("email", "name").Name("idx_users_search");
ALTER TABLE
Schema.Table("users", table =>
{
table.AddColumn("phone").String(20).Nullable();
table.ChangeColumn("name").String(500);
table.DropColumn("avatar");
});
Running in Docker
docker compose exec sdk dotnet run --project /migrations | flowgrate up
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.