Skip to content

Commit c3517ae

Browse files
authored
Add support for Wellturn T330 shocker (#285)
* Add support for Wellturn T330 shocker * Fix migration
1 parent 62751bd commit c3517ae

7 files changed

Lines changed: 1527 additions & 5 deletions

File tree

Common/Migrations/20260316125819_AddWellturnT330.Designer.cs

Lines changed: 1463 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
#nullable disable
4+
5+
namespace OpenShock.Common.Migrations
6+
{
7+
/// <inheritdoc />
8+
public partial class AddWellturnT330 : Migration
9+
{
10+
/// <inheritdoc />
11+
protected override void Up(MigrationBuilder migrationBuilder)
12+
{
13+
migrationBuilder.AlterDatabase()
14+
.Annotation("Npgsql:CollationDefinition:public.ndcoll", "und-u-ks-level2,und-u-ks-level2,icu,False")
15+
.Annotation("Npgsql:Enum:configuration_value_type", "string,bool,int,float,json")
16+
.Annotation("Npgsql:Enum:control_type", "sound,vibrate,shock,stop")
17+
.Annotation("Npgsql:Enum:match_type_enum", "exact,contains")
18+
.Annotation("Npgsql:Enum:ota_update_status", "started,running,finished,error,timeout")
19+
.Annotation("Npgsql:Enum:password_encryption_type", "pbkdf2,bcrypt_enhanced")
20+
.Annotation("Npgsql:Enum:permission_type", "shockers.use,shockers.edit,shockers.pause,devices.edit,devices.auth")
21+
.Annotation("Npgsql:Enum:role_type", "support,staff,admin,system")
22+
.Annotation("Npgsql:Enum:shocker_model_type", "caiXianlin,petTrainer,petrainer998DR,wellturnT330")
23+
.OldAnnotation("Npgsql:CollationDefinition:public.ndcoll", "und-u-ks-level2,und-u-ks-level2,icu,False")
24+
.OldAnnotation("Npgsql:Enum:configuration_value_type", "string,bool,int,float,json")
25+
.OldAnnotation("Npgsql:Enum:control_type", "sound,vibrate,shock,stop")
26+
.OldAnnotation("Npgsql:Enum:match_type_enum", "exact,contains")
27+
.OldAnnotation("Npgsql:Enum:ota_update_status", "started,running,finished,error,timeout")
28+
.OldAnnotation("Npgsql:Enum:password_encryption_type", "pbkdf2,bcrypt_enhanced")
29+
.OldAnnotation("Npgsql:Enum:permission_type", "shockers.use,shockers.edit,shockers.pause,devices.edit,devices.auth")
30+
.OldAnnotation("Npgsql:Enum:role_type", "support,staff,admin,system")
31+
.OldAnnotation("Npgsql:Enum:shocker_model_type", "caiXianlin,petTrainer,petrainer998DR");
32+
}
33+
34+
/// <inheritdoc />
35+
protected override void Down(MigrationBuilder migrationBuilder)
36+
{
37+
migrationBuilder.AlterDatabase()
38+
.Annotation("Npgsql:CollationDefinition:public.ndcoll", "und-u-ks-level2,und-u-ks-level2,icu,False")
39+
.Annotation("Npgsql:Enum:configuration_value_type", "string,bool,int,float,json")
40+
.Annotation("Npgsql:Enum:control_type", "sound,vibrate,shock,stop")
41+
.Annotation("Npgsql:Enum:match_type_enum", "exact,contains")
42+
.Annotation("Npgsql:Enum:ota_update_status", "started,running,finished,error,timeout")
43+
.Annotation("Npgsql:Enum:password_encryption_type", "pbkdf2,bcrypt_enhanced")
44+
.Annotation("Npgsql:Enum:permission_type", "shockers.use,shockers.edit,shockers.pause,devices.edit,devices.auth")
45+
.Annotation("Npgsql:Enum:role_type", "support,staff,admin,system")
46+
.Annotation("Npgsql:Enum:shocker_model_type", "caiXianlin,petTrainer,petrainer998DR")
47+
.OldAnnotation("Npgsql:CollationDefinition:public.ndcoll", "und-u-ks-level2,und-u-ks-level2,icu,False")
48+
.OldAnnotation("Npgsql:Enum:configuration_value_type", "string,bool,int,float,json")
49+
.OldAnnotation("Npgsql:Enum:control_type", "sound,vibrate,shock,stop")
50+
.OldAnnotation("Npgsql:Enum:match_type_enum", "exact,contains")
51+
.OldAnnotation("Npgsql:Enum:ota_update_status", "started,running,finished,error,timeout")
52+
.OldAnnotation("Npgsql:Enum:password_encryption_type", "pbkdf2,bcrypt_enhanced")
53+
.OldAnnotation("Npgsql:Enum:permission_type", "shockers.use,shockers.edit,shockers.pause,devices.edit,devices.auth")
54+
.OldAnnotation("Npgsql:Enum:role_type", "support,staff,admin,system")
55+
.OldAnnotation("Npgsql:Enum:shocker_model_type", "caiXianlin,petTrainer,petrainer998DR,wellturnT330");
56+
}
57+
}
58+
}

Common/Migrations/OpenShockContextModelSnapshot.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
2121
#pragma warning disable 612, 618
2222
modelBuilder
2323
.HasAnnotation("Npgsql:CollationDefinition:public.ndcoll", "und-u-ks-level2,und-u-ks-level2,icu,False")
24-
.HasAnnotation("ProductVersion", "9.0.8")
24+
.HasAnnotation("ProductVersion", "10.0.5")
2525
.HasAnnotation("Relational:MaxIdentifierLength", 63);
2626

2727
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "configuration_value_type", new[] { "string", "bool", "int", "float", "json" });
@@ -31,7 +31,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
3131
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "password_encryption_type", new[] { "pbkdf2", "bcrypt_enhanced" });
3232
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "permission_type", new[] { "shockers.use", "shockers.edit", "shockers.pause", "devices.edit", "devices.auth" });
3333
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "role_type", new[] { "support", "staff", "admin", "system" });
34-
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "shocker_model_type", new[] { "caiXianlin", "petTrainer", "petrainer998DR" });
34+
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "shocker_model_type", new[] { "caiXianlin", "petTrainer", "petrainer998DR", "wellturnT330" });
3535
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
3636

3737
modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>
@@ -102,7 +102,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
102102
.HasColumnName("name_change_request_count");
103103

104104
b.Property<string>("PasswordHashType")
105-
.IsRequired()
106105
.HasColumnType("character varying")
107106
.HasColumnName("password_hash_type");
108107

Common/Models/ShockerModelType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ public enum ShockerModelType
77
[PgName("caiXianlin")] CaiXianlin = 0,
88
[PgName("petTrainer")] PetTrainer = 1, // Misspelled, should be "petrainer",
99
[PgName("petrainer998DR")] Petrainer998DR = 2,
10+
[PgName("wellturnT330")] WellturnT330 = 3,
1011
}

Common/OpenShockDb/OpenShockContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
146146
.HasPostgresEnum("permission_type",
147147
["shockers.use", "shockers.edit", "shockers.pause", "devices.edit", "devices.auth"])
148148
.HasPostgresEnum("role_type", ["support", "staff", "admin", "system"])
149-
.HasPostgresEnum("shocker_model_type", ["caiXianlin", "petTrainer", "petrainer998DR"])
149+
.HasPostgresEnum("shocker_model_type", ["caiXianlin", "petTrainer", "petrainer998DR", "wellturnT330"])
150150
.HasPostgresEnum("match_type_enum", ["exact", "contains"])
151151
.HasPostgresEnum("configuration_value_type", ["string", "bool", "int", "float", "json"])
152152
.HasCollation("public", "ndcoll", "und-u-ks-level2", "icu", false); // Add case-insensitive, accent-sensitive comparison collation

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
2727
<PackageVersion Include="NRedisStack" Version="1.3.0" />
2828
<PackageVersion Include="OneOf" Version="3.0.271" />
29-
<PackageVersion Include="OpenShock.Serialization.Flatbuffers" Version="2.0.0-preview.5" />
29+
<PackageVersion Include="OpenShock.Serialization.Flatbuffers" Version="2.1.0" />
3030
<PackageVersion Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.12.0-beta.1" />
3131
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.15.0" />
3232
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.15.1" />

LiveControlGateway/Mappers/FbsMapper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public static Serialization.Types.ShockerModelType ToFbsModelType(Common.Models.
1414
Common.Models.ShockerModelType.CaiXianlin => Serialization.Types.ShockerModelType.CaiXianlin,
1515
Common.Models.ShockerModelType.PetTrainer => Serialization.Types.ShockerModelType.Petrainer,
1616
Common.Models.ShockerModelType.Petrainer998DR => Serialization.Types.ShockerModelType.Petrainer998DR,
17+
Common.Models.ShockerModelType.WellturnT330 => Serialization.Types.ShockerModelType.WellturnT330,
1718
_ => throw new NotImplementedException(),
1819
};
1920
}

0 commit comments

Comments
 (0)