-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
type checking done, F# project generation, fix mig log
- Loading branch information
Showing
20 changed files
with
216 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Changelog | ||
|
||
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). | ||
|
||
## [0.0.18] - 2024-06-28 | ||
|
||
Added: | ||
|
||
- Basic SQL type checking for project schema | ||
- F# project generation with `selectAll` queries for all views and tables | ||
|
||
Fixed: | ||
|
||
- `mig relations` command. | ||
- `mig log` command when SQLite file does not exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2023 Luis Ángel Méndez Gort | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
module internal Migrate.FsGeneration.FsprojFile | ||
|
||
open System.IO | ||
open System.Xml.Linq | ||
open Migrate.Types | ||
|
||
let projectToFsproj (p: Project) = | ||
|
||
let includeQuery = | ||
XElement(XName.Get "Compile", XAttribute(XName.Get "Include", "Query.fs")) | ||
|
||
let fs = | ||
p.includeFsFiles | ||
|> List.map (fun f -> XElement(XName.Get "Compile", XAttribute(XName.Get "Include", f))) | ||
|
||
XElement( | ||
XName.Get "Project", | ||
XAttribute(XName.Get "Sdk", "Microsoft.NET.Sdk"), | ||
|
||
XElement(XName.Get "PropertyGroup", XElement(XName.Get "TargetFramework", "net8.0")), | ||
|
||
XElement(XName.Get "ItemGroup", includeQuery :: fs), | ||
|
||
XElement( | ||
XName.Get "ItemGroup", | ||
XElement( | ||
XName.Get "PackageReference", | ||
XAttribute(XName.Get "Include", "Microsoft.Data.Sqlite"), | ||
XAttribute(XName.Get "Version", "8.0.6") | ||
), | ||
XElement( | ||
XName.Get "PackageReference", | ||
XAttribute(XName.Get "Include", "MigrateLib"), | ||
XAttribute(XName.Get "Version", "0.0.18") | ||
) | ||
) | ||
) | ||
|
||
let saveXmlTo (dir: string) (xml: XElement) = | ||
Path.Join(dir, "Database.fsproj") |> xml.Save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2023 Luis Ángel Méndez Gort | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
module internal Migrate.FsGeneration.Main | ||
|
||
open System.IO | ||
open Migrate.Types | ||
open Migrate.Checks.Types | ||
|
||
let generateDatabaseProj (dir: string option) (p: Project) = | ||
let dir = Option.defaultValue (Directory.GetCurrentDirectory()) dir | ||
p |> FsprojFile.projectToFsproj |> FsprojFile.saveXmlTo dir | ||
let rs, errs = typeCheck p.source | ||
|
||
match errs with | ||
| [] -> | ||
let queryFs = | ||
rs |> relationTypes |> QueryModule.queryModule |> QueryModule.toFsString | ||
|
||
let queryPath = Path.Join(dir, "Query.fs") | ||
File.WriteAllText(queryPath, queryFs) | ||
1 | ||
| _ -> | ||
errs |> String.concat "\n" |> LamgEnv.errPrint | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2023 Luis Ángel Méndez Gort | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
module Migrate.FsGeneration.Util | ||
|
||
open System.Data | ||
open Microsoft.Data.Sqlite | ||
|
||
type ReaderExecuter = | ||
abstract member ExecuteReader: string -> IDataReader | ||
|
||
type SqliteReaderExecuter(connection: SqliteConnection, transaction: SqliteTransaction) = | ||
interface ReaderExecuter with | ||
member _.ExecuteReader(sql: string) = | ||
let command = new SqliteCommand(sql, connection, transaction) | ||
command.ExecuteReader() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.