Skip to content

Commit

Permalink
execute migration in specific db file
Browse files Browse the repository at this point in the history
  • Loading branch information
lamg committed Jan 11, 2025
1 parent 15562dd commit 547f292
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.3] - 2025-01-11

Added: `migrate.Execution.Exec.executeMigrationInDb`

- migrate as library

## [1.0.2] - 2025-01-11

Changed:
Expand Down
14 changes: 8 additions & 6 deletions src/MigLib/Execution/Exec.fs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ let generateMigrationScript (withColors: bool) =
return statements |> FormatSql.formatSeq withColors
}

let executeMigration (statements: string list) =
let dir = Environment.CurrentDirectory |> DirectoryInfo
let dbFile = getDbFile dir

let executeMigrationInDb (dbFile:string) (statements:string list) =
match connect dbFile with
| Ok conn ->
use conn = conn
Expand Down Expand Up @@ -161,8 +158,13 @@ let executeMigration (statements: string list) =
Error(Types.FailedSteps xs)

| Error e -> Error e



/// uses <current_directory>.sqlite as default database
let executeMigration (statements: string list) =
let dir = Environment.CurrentDirectory |> DirectoryInfo
let dbFile = getDbFile dir
executeMigrationInDb dbFile statements

let getDbSql withColors =
let dir = Environment.CurrentDirectory |> DirectoryInfo
let dbFile = getDbFile dir
Expand Down
2 changes: 1 addition & 1 deletion src/MigLib/MigLib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<PackageId>MigLib</PackageId>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<PackageOutputPath>./nupkg</PackageOutputPath>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>migrate</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion src/SqliteParserCs/SqliteParserCs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<RootNamespace>SqliteParser</RootNamespace>
<PackageId>SqliteParserCs</PackageId>
<Version>1.0.0</Version>
<Version>1.0.3</Version>
<PackageOutputPath>./nupkg</PackageOutputPath>
<InvariantGlobalization>true</InvariantGlobalization>
<AssemblyName>SqliteParserCs</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion src/mig/mig.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageId>migtool</PackageId>
<RootNamespace>migrate</RootNamespace>
<AssemblyName>migrate</AssemblyName>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<PackageOutputPath>./nupkg</PackageOutputPath>
<InvariantGlobalization>true</InvariantGlobalization>

Expand Down

0 comments on commit 547f292

Please sign in to comment.