Skip to content

Commit

Permalink
Set up initial migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
arnavb committed Jun 11, 2024
1 parent 6a5e45f commit 5225bea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Migrations/Migrations.fsproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
Expand All @@ -10,7 +9,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DbUp" Version="5.0.40" />
<PackageReference Include="dbup-sqlite" Version="5.0.40" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.6" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Scripts\*.sql" />
</ItemGroup>
</Project>
30 changes: 27 additions & 3 deletions Migrations/Program.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
[<EntryPoint>]
open System.Reflection

open DbUp
open Microsoft.Data.Sqlite

[<EntryPoint>]
let main args =
let connectionString = ""
0
let connectionString = "Data Source=JimBroBot.db"

use connection = new SqliteConnection(connectionString)
use _ = new SQLite.Helpers.SharedConnection(connection)

let upgrader =
DeployChanges.To
.SQLiteDatabase(connection.ConnectionString)
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly())
.LogToConsole()
.Build()

let result = upgrader.PerformUpgrade()

match result.Successful, result.Error with
| (false, err) ->
printfn $"ERROR: ${err}"
1
| (true, _) ->
printfn "Migrations successful"
0

0 comments on commit 5225bea

Please sign in to comment.