Skip to content

Commit

Permalink
Json check + Exram.Gremlinq 12.2.1 (#3)
Browse files Browse the repository at this point in the history
* Update Gremlinq dependency 12.2.1

* A json control

* Improve readme
  • Loading branch information
etrange02 committed Mar 10, 2024
1 parent 20409cb commit ea64cf1
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Ivet.Model/Ivet.Model.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>david.lecoconnier</Authors>
<Version>1.1.1</Version>
<Version>1.2.0</Version>
<Title>Ivet.Model</Title>
<PackageProjectUrl>https://github.com/etrange02/Ivet</PackageProjectUrl>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/etrange02/Ivet</RepositoryUrl>
<Description>Ivet's attributes. Tag your code with these classes then use Ivet to generate and update your Janusgraph schema</Description>
<PackageLicenseExpression>CECILL-B</PackageLicenseExpression>
<PackageTags>janusgraph;graph;database schema;generator;update</PackageTags>
<PackageReleaseNotes></PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 5 additions & 3 deletions Ivet/Ivet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
<PackageProjectUrl>https://github.com/etrange02/Ivet</PackageProjectUrl>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageLicenseExpression>CECILL-B</PackageLicenseExpression>
<Version>1.1.1</Version>
<Version>1.2.0</Version>
<Authors>david.lecoconnier</Authors>
<PackageReleaseNotes>* Allow only json files
* Exram.Gremlinq 12.2.1 dependecy update</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand All @@ -29,8 +31,8 @@
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="ConsoleTables" Version="2.6.1" />
<PackageReference Include="CsvHelper" Version="31.0.2" />
<PackageReference Include="ExRam.Gremlinq.Providers.JanusGraph" Version="12.1.2" />
<PackageReference Include="ExRam.Gremlinq.Support.NewtonsoftJson" Version="12.1.2" />
<PackageReference Include="ExRam.Gremlinq.Providers.JanusGraph" Version="12.2.1" />
<PackageReference Include="ExRam.Gremlinq.Support.NewtonsoftJson" Version="12.2.1" />
<PackageReference Include="JanusGraph.Net" Version="1.0.0" />
</ItemGroup>

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Ivet/Verbs/Services/ListAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ListAction
public static void Do(ListOptions options)
{
var files = new List<string>();
files.AddRange(Directory.EnumerateFiles(options.Input));
files.AddRange(Directory.EnumerateFiles(options.Input, "*.json"));

var migrations = files.ConvertAll(x => new { Name = Path.GetFileNameWithoutExtension(x), Migration = JsonSerializer.Deserialize<MigrationFile>(File.ReadAllText(x)) });

Expand Down
8 changes: 6 additions & 2 deletions Ivet/Verbs/Services/UpgradeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Ivet.Model;
using Ivet.Services;
using Ivet.Verbs.Model;
using System.Globalization;
using System.Text.Json;

namespace Ivet.Verbs.Services
Expand All @@ -14,11 +15,14 @@ public static void Do(UpgradeOptions options)

if (File.Exists(options.Input))
{
files.Add(options.Input);
if (options.Input.EndsWith(".json", true, CultureInfo.InvariantCulture))
files.Add(options.Input);
else
throw new FormatException("Bad extension. Must be a json file or a directory.");
}
else
{
files.AddRange(Directory.EnumerateFiles(options.Input));
files.AddRange(Directory.EnumerateFiles(options.Input, "*.json"));
}

using var database = new DatabaseService(options.IpAddress, options.Port);
Expand Down
41 changes: 36 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ The **generate** command creates a json file containing commands to execute. The
To keep trace of all applied migrations, migration names are saved into janusgraph server when **upgrade** is called.
You can check at any moment the **list** of migrations both applied and not.

A **test** command is used to populate database either for personnal tests or unit tests. Do not use it in your production environment.
> [!CAUTION]
> There is a fourth command `test`. It is used to populate database either for personnal tests or unit tests. Do not use it in your production environment.
Available commands
=======
Expand All @@ -23,9 +24,6 @@ Available commands
* **input*** Can be a file or a directory containing migrations to be applied
* **ip** _localhost_
* **port** _8182_
* test* _Must not be used in Prod. This command is only used to apply a schema to a Janusgraph server_
* **ip** _localhost_
* **port** _8182_

Docker image
=======
Expand Down Expand Up @@ -55,7 +53,7 @@ Ivet list --input "C:\MigrationFiles"

How to tag code?
=======
Add `Ivet.Model` to your project. You are now ready to tag your code.
Add `Ivet.Model` (https://www.nuget.org/packages/Ivet.Model) to your project. You are now ready to tag your code.
All names and possibilities are listed in Janusgraph documentation at https://docs.janusgraph.org/schema/.

Tag a Vertex:
Expand Down Expand Up @@ -110,4 +108,37 @@ public class MyVertex
[MixedIndex("vertex2_mixed", Backend = "search", Mapping = MappingType.TEXTSTRING)]
public string SearchProperty { get; set; }
}
```


What's next?
=======
You can now run a `generate` command in order to create migration files.

> [!NOTE]
> Many files are created by the `generate` command. One contains vertices and edges and properties. Indices are in different files to avoid timeout at migration time.
You can can have some details of migrations with `list`.

> [!TIP]
> You can open and manually edit your migration files. In particular there is a description field whose content can be seen with `list` command
```
> Ivet list --input ".\Migrations"
-------------------------------------------------------------------------------------------------------
| Name | Description | Date |
-------------------------------------------------------------------------------------------------------
| Migration_202403032330_000 | Vertex and edge creation for my new feature | 10/03/2024 14:21:54 |
-------------------------------------------------------------------------------------------------------
| Migration_202403032330_001 | | 10/03/2024 14:22:04 |
-------------------------------------------------------------------------------------------------------
| Migration_202403032330_002 | | 10/03/2024 14:22:14 |
-------------------------------------------------------------------------------------------------------
| Migration_202403032330_003 | | 10/03/2024 14:22:24 |
-------------------------------------------------------------------------------------------------------
| Migration_202403032330_004 | | 10/03/2024 14:22:34 |
-------------------------------------------------------------------------------------------------------
Count:5
```

0 comments on commit ea64cf1

Please sign in to comment.