@databricks-solutions/lakebase-scm-utils 0.2.50 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/scripts/index.cjs +2636 -2124
  2. package/dist/scripts/index.d.cts +1 -1
  3. package/dist/scripts/index.d.ts +1 -1
  4. package/dist/scripts/index.js +680 -178
  5. package/dist/scripts/lakebase/ci-resolve-branch.cli.cjs +2460 -2030
  6. package/dist/scripts/lakebase/ci-resolve-branch.cli.js +508 -81
  7. package/dist/scripts/lakebase/collapse-heads.cli.cjs +2429 -2007
  8. package/dist/scripts/lakebase/collapse-heads.cli.js +477 -58
  9. package/dist/scripts/lakebase/detect-language.cli.cjs +2441 -2016
  10. package/dist/scripts/lakebase/detect-language.cli.js +489 -67
  11. package/dist/scripts/lakebase/doctor.cli.cjs +2484 -2040
  12. package/dist/scripts/lakebase/doctor.cli.js +532 -91
  13. package/dist/scripts/lakebase/get-connection.cli.cjs +2 -2
  14. package/dist/scripts/lakebase/get-connection.cli.js +2 -2
  15. package/dist/scripts/lakebase/index.cjs +2633 -2121
  16. package/dist/scripts/lakebase/index.d.cts +59 -10
  17. package/dist/scripts/lakebase/index.d.ts +59 -10
  18. package/dist/scripts/lakebase/index.js +674 -172
  19. package/dist/scripts/lakebase/infra-runner.cli.cjs +2435 -2013
  20. package/dist/scripts/lakebase/infra-runner.cli.js +483 -64
  21. package/dist/scripts/lakebase/new-migration.cli.cjs +2429 -2007
  22. package/dist/scripts/lakebase/new-migration.cli.js +477 -58
  23. package/dist/scripts/lakebase/schema-diff.cli.cjs +2 -2
  24. package/dist/scripts/lakebase/schema-diff.cli.js +2 -2
  25. package/dist/scripts/lakebase/schema-migrate.cli.cjs +2461 -2029
  26. package/dist/scripts/lakebase/schema-migrate.cli.js +509 -80
  27. package/dist/scripts/lakebase/scm-claim-feature.cli.cjs +2460 -2030
  28. package/dist/scripts/lakebase/scm-claim-feature.cli.js +508 -81
  29. package/dist/scripts/lakebase/scm-doctor.cli.cjs +2486 -2056
  30. package/dist/scripts/lakebase/scm-doctor.cli.js +537 -107
  31. package/dist/scripts/lakebase/scm-merge.cli.cjs +2443 -2021
  32. package/dist/scripts/lakebase/scm-merge.cli.js +494 -72
  33. package/dist/scripts/lakebase/scm-reconcile-tier.cli.cjs +2464 -2034
  34. package/dist/scripts/lakebase/scm-reconcile-tier.cli.js +511 -84
  35. package/dist/scripts/util/index.cjs +2 -2
  36. package/dist/scripts/util/index.js +2 -2
  37. package/package.json +1 -1
  38. package/scripts/lakebase/adapters/efcore-adapter.ts +158 -0
  39. package/scripts/lakebase/adapters/flyway-adapter.ts +8 -5
  40. package/scripts/lakebase/collapse-heads.cli.ts +1 -1
  41. package/scripts/lakebase/create-project.ts +14 -12
  42. package/scripts/lakebase/detect-language.cli.ts +2 -2
  43. package/scripts/lakebase/doctor.ts +29 -0
  44. package/scripts/lakebase/dotnet-project.ts +112 -0
  45. package/scripts/lakebase/index.ts +1 -0
  46. package/scripts/lakebase/migration-layout.ts +43 -2
  47. package/scripts/lakebase/new-migration.cli.ts +1 -1
  48. package/scripts/lakebase/scaffold-language.ts +23 -2
  49. package/scripts/lakebase/scaffold.ts +4 -1
  50. package/scripts/lakebase/schema-migrate-runners/efcore.ts +399 -0
  51. package/scripts/lakebase/schema-migrate-runners/flyway.ts +6 -4
  52. package/scripts/lakebase/schema-migrate.cli.ts +3 -1
  53. package/scripts/lakebase/schema-migrate.ts +24 -10
  54. package/templates/project/common/.github/workflows/merge.yml +13 -1
  55. package/templates/project/common/.github/workflows/pr.yml +25 -5
  56. package/templates/project/common/.gitignore.base +7 -0
  57. package/templates/project/common/scripts/flyway-migrate.sh +54 -1
  58. package/templates/project/common/scripts/prepare-schema-diff.sh +5 -0
  59. package/templates/project/common/scripts/run-dev.sh +10 -1
  60. package/templates/project/common/scripts/run-tests.sh +6 -1
  61. package/templates/project/dotnet/.gitignore.extra +8 -0
  62. package/templates/project/dotnet/App.sln +56 -0
  63. package/templates/project/dotnet/Makefile +13 -0
  64. package/templates/project/dotnet/global.json +6 -0
  65. package/templates/project/dotnet/src/App/Data/AppDbContext.cs +12 -0
  66. package/templates/project/dotnet/src/App/Lakebase/DotEnv.cs +48 -0
  67. package/templates/project/dotnet/src/App/Lakebase/LakebaseConnection.cs +225 -0
  68. package/templates/project/dotnet/src/App/Program.cs +34 -0
  69. package/templates/project/dotnet/src/App/appsettings.json +9 -0
  70. package/templates/project/dotnet/tests/App.Tests/App.Tests.csproj +25 -0
  71. package/templates/project/dotnet/tests/App.Tests/HealthTests.cs +18 -0
  72. package/templates/project/dotnet/tests/App.Tests/OpenApiTests.cs +23 -0
  73. package/templates/project/dotnet-efcore/.config/dotnet-tools.json +13 -0
  74. package/templates/project/dotnet-efcore/src/App/App.csproj +22 -0
  75. package/templates/project/dotnet-efcore/src/App/Data/DesignTimeDbContextFactory.cs +24 -0
  76. package/templates/project/dotnet-efcore/src/App/Migrations/README.md +23 -0
  77. package/templates/project/dotnet-flyway/db/migrations/README.md +23 -0
  78. package/templates/project/dotnet-flyway/src/App/App.csproj +17 -0
@@ -0,0 +1,18 @@
1
+ using System.Net;
2
+ using System.Net.Http.Json;
3
+ using Microsoft.AspNetCore.Mvc.Testing;
4
+
5
+ namespace App.Tests;
6
+
7
+ public class HealthTests(WebApplicationFactory<Program> factory) : IClassFixture<WebApplicationFactory<Program>>
8
+ {
9
+ [Fact]
10
+ public async Task Health_ReturnsOk()
11
+ {
12
+ var response = await factory.CreateClient().GetAsync("/health");
13
+
14
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
15
+ var body = await response.Content.ReadFromJsonAsync<Dictionary<string, string>>();
16
+ Assert.Equal("ok", body!["status"]);
17
+ }
18
+ }
@@ -0,0 +1,23 @@
1
+ using System.Net;
2
+ using Microsoft.AspNetCore.Mvc.Testing;
3
+
4
+ namespace App.Tests;
5
+
6
+ public class OpenApiTests(WebApplicationFactory<Program> factory) : IClassFixture<WebApplicationFactory<Program>>
7
+ {
8
+ [Fact]
9
+ public async Task OpenApiDocument_ListsEndpoints()
10
+ {
11
+ var body = await factory.CreateClient().GetStringAsync("/openapi.json");
12
+
13
+ Assert.Contains("\"/health\"", body);
14
+ }
15
+
16
+ [Fact]
17
+ public async Task Docs_ServesSwaggerUi()
18
+ {
19
+ var response = await factory.CreateClient().GetAsync("/docs/index.html");
20
+
21
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
22
+ }
23
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": 1,
3
+ "isRoot": true,
4
+ "tools": {
5
+ "dotnet-ef": {
6
+ "version": "10.0.4",
7
+ "commands": [
8
+ "dotnet-ef"
9
+ ],
10
+ "rollForward": false
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,22 @@
1
+ <Project Sdk="Microsoft.NET.Sdk.Web">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>net10.0</TargetFramework>
5
+ <Nullable>enable</Nullable>
6
+ <ImplicitUsings>enable</ImplicitUsings>
7
+ <RootNamespace>App</RootNamespace>
8
+ <!-- {{PROJECT_NAME}} -->
9
+ </PropertyGroup>
10
+
11
+ <ItemGroup>
12
+ <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.3" />
13
+ <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.12" />
14
+ <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="10.3.0" />
15
+ <!-- Marks this project as the EF Core migrations owner for lakebase-schema-migrate. -->
16
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.4">
17
+ <PrivateAssets>all</PrivateAssets>
18
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19
+ </PackageReference>
20
+ </ItemGroup>
21
+
22
+ </Project>
@@ -0,0 +1,24 @@
1
+ using App.Lakebase;
2
+ using Microsoft.EntityFrameworkCore;
3
+ using Microsoft.EntityFrameworkCore.Design;
4
+
5
+ namespace App.Data;
6
+
7
+ /// <summary>
8
+ /// Used by `dotnet ef` (and the kit's lakebase-schema-migrate) to build the
9
+ /// DbContext without starting the web host. It reads the same connection
10
+ /// settings as the app: DATABASE_URL when set (the kit passes the target
11
+ /// branch DSN this way, so no password appears on a command line), otherwise
12
+ /// the Lakebase metadata in .env with a runtime-minted credential.
13
+ /// </summary>
14
+ public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<AppDbContext>
15
+ {
16
+ public AppDbContext CreateDbContext(string[] args)
17
+ {
18
+ DotEnv.LoadFromRepoRoot();
19
+ var options = new DbContextOptionsBuilder<AppDbContext>()
20
+ .UseNpgsql(LakebaseConnection.CreateDataSource())
21
+ .Options;
22
+ return new AppDbContext(options);
23
+ }
24
+ }
@@ -0,0 +1,23 @@
1
+ # EF Core migrations
2
+
3
+ Create a migration with the kit's tool-agnostic command (run in the project
4
+ root):
5
+
6
+ ```bash
7
+ ./scripts/lk lakebase-new-migration --name "<description>"
8
+ ```
9
+
10
+ This runs `dotnet ef migrations add`, which generates the migration from the
11
+ difference between your `AppDbContext` model and the last snapshot. Review the
12
+ generated `Up()` / `Down()` before committing. You can also run
13
+ `dotnet ef migrations add <Name> --project src/App` directly.
14
+
15
+ EF Core names migrations `<UTC timestamp>_<Name>.cs`, so sibling feature
16
+ branches never collide on an id. Commit the migration, its `.Designer.cs`, and
17
+ the updated `AppDbContextModelSnapshot.cs` together.
18
+
19
+ You do not run migrations by hand: the kit applies them to each paired Lakebase
20
+ branch through CI (`pr.yml` on the feature branch, `merge.yml` on staging /
21
+ production) via `lakebase-schema-migrate`, which passes the branch connection to
22
+ `dotnet ef` in `DATABASE_URL` (read by `Data/DesignTimeDbContextFactory.cs`).
23
+ To migrate your paired branch locally, run `./scripts/flyway-migrate.sh`.
@@ -0,0 +1,23 @@
1
+ # Flyway migrations
2
+
3
+ Create a migration with the kit's tool-agnostic command (run in the project
4
+ root):
5
+
6
+ ```bash
7
+ ./scripts/lk lakebase-new-migration --name "<description>"
8
+ ```
9
+
10
+ This writes a timestamp-versioned skeleton (`V<timestamp>__<slug>.sql`, a UTC
11
+ `YYYYMMDDHHMMSS` version); then author the DDL/DML. Timestamps are globally
12
+ unique and sort chronologically, so sibling feature branches never collide on a
13
+ version. Flyway runs with `-baselineOnMigrate=true -baselineVersion=0`, so every
14
+ `V<n>` file is applied as a pending migration.
15
+
16
+ Flyway owns the schema; EF Core is used only as the runtime ORM. Keep your
17
+ `AppDbContext` model in step with the SQL here, and do not add EF Core
18
+ migrations to this project.
19
+
20
+ You do not run migrations by hand: the kit applies them to each paired Lakebase
21
+ branch through CI (`pr.yml` on the feature branch, `merge.yml` on staging /
22
+ production) via `lakebase-schema-migrate`. To migrate your paired branch
23
+ locally, run `./scripts/flyway-migrate.sh`.
@@ -0,0 +1,17 @@
1
+ <Project Sdk="Microsoft.NET.Sdk.Web">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>net10.0</TargetFramework>
5
+ <Nullable>enable</Nullable>
6
+ <ImplicitUsings>enable</ImplicitUsings>
7
+ <RootNamespace>App</RootNamespace>
8
+ <!-- {{PROJECT_NAME}} -->
9
+ </PropertyGroup>
10
+
11
+ <ItemGroup>
12
+ <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.3" />
13
+ <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.12" />
14
+ <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="10.3.0" />
15
+ </ItemGroup>
16
+
17
+ </Project>