-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add common view for v1 and v2 avatars and their trust connections
- Loading branch information
Showing
16 changed files
with
481 additions
and
16 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
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
13 changes: 13 additions & 0 deletions
13
Circles.Index.CirclesViews/Circles.Index.CirclesViews.csproj
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Circles.Index.Common\Circles.Index.Common.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,111 @@ | ||
using Circles.Index.Common; | ||
|
||
namespace Circles.Index.CirclesViews; | ||
|
||
public class DatabaseSchema : IDatabaseSchema | ||
{ | ||
public ISchemaPropertyMap SchemaPropertyMap { get; } = new SchemaPropertyMap(); | ||
|
||
public IEventDtoTableMap EventDtoTableMap { get; } = new EventDtoTableMap(); | ||
|
||
public static readonly EventSchema TrustRelations = new("V_Crc", "TrustRelations", new byte[32], [ | ||
new("blockNumber", ValueTypes.Int, true), | ||
new("timestamp", ValueTypes.Int, true), | ||
new("transactionIndex", ValueTypes.Int, true), | ||
new("logIndex", ValueTypes.Int, true), | ||
new("transactionHash", ValueTypes.String, true), | ||
new("version", ValueTypes.Int, false), | ||
new("trustee", ValueTypes.String, false), | ||
new("truster", ValueTypes.String, false), | ||
new("expiryTime", ValueTypes.Int, false), | ||
new("limit", ValueTypes.Int, false) | ||
]) | ||
{ | ||
SqlMigrationItem = new SqlMigrationItem(@" | ||
create or replace view ""V_Crc_TrustRelations"" as | ||
select ""blockNumber"", | ||
""timestamp"", | ||
""transactionIndex"", | ||
""logIndex"", | ||
""transactionHash"", | ||
2 as ""version"", | ||
""trustee"", | ||
""truster"", | ||
""expiryTime"", | ||
null as ""limit"" | ||
from ""V_CrcV2_TrustRelations"" | ||
union all | ||
select ""blockNumber"", | ||
""timestamp"", | ||
""transactionIndex"", | ||
""logIndex"", | ||
""transactionHash"", | ||
1 as ""version"", | ||
""user"", | ||
""canSendTo"", | ||
null as ""expiryTime"", | ||
""limit"" | ||
from ""V_CrcV1_TrustRelations""; | ||
") | ||
}; | ||
|
||
public static readonly EventSchema Avatars = new("V_Crc", "Avatars", new byte[32], [ | ||
new("blockNumber", ValueTypes.Int, true), | ||
new("timestamp", ValueTypes.Int, true), | ||
new("transactionIndex", ValueTypes.Int, true), | ||
new("logIndex", ValueTypes.Int, true), | ||
new("transactionHash", ValueTypes.String, true), | ||
new("version", ValueTypes.Int, false), | ||
new("type", ValueTypes.String, false), | ||
new("invitedBy", ValueTypes.String, false), | ||
new("avatar", ValueTypes.String, false), | ||
new("tokenId", ValueTypes.String, false), | ||
new("name", ValueTypes.String, false), | ||
new("cidV0Digest", ValueTypes.Bytes, false), | ||
]) | ||
{ | ||
SqlMigrationItem = new SqlMigrationItem(@" | ||
create or replace view ""V_Crc_Avatars"" as | ||
select ""blockNumber"", | ||
""timestamp"", | ||
""transactionIndex"", | ||
""logIndex"", | ||
""transactionHash"", | ||
2 as ""version"", | ||
""type"", | ||
""invitedBy"", | ||
""avatar"", | ||
""tokenId"", | ||
""name"", | ||
""cidV0Digest"" | ||
from ""V_CrcV2_Avatars"" | ||
union all | ||
select ""blockNumber"", | ||
""timestamp"", | ||
""transactionIndex"", | ||
""logIndex"", | ||
""transactionHash"", | ||
1 as ""version"", | ||
""type"", | ||
null as ""invitedBy"", | ||
""user"" as ""avatar"", | ||
""token"" as ""tokenId"", | ||
null as ""name"", | ||
null as ""cidV0Digest"" | ||
from ""V_CrcV1_Avatars""; | ||
") | ||
}; | ||
|
||
public IDictionary<(string Namespace, string Table), EventSchema> Tables { get; } = | ||
new Dictionary<(string Namespace, string Table), EventSchema> | ||
{ | ||
{ | ||
("V_Crc", "Avatars"), | ||
Avatars | ||
}, | ||
{ | ||
("V_Crc", "TrustRelations"), | ||
TrustRelations | ||
} | ||
}; | ||
} |
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
Oops, something went wrong.