Skip to content

Commit e0b89f3

Browse files
committed
Update sample & fix cancelling process
1 parent df2f31b commit e0b89f3

File tree

11 files changed

+152
-18
lines changed

11 files changed

+152
-18
lines changed

sample_dotnet/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,5 @@ $RECYCLE.BIN/
475475

476476
# Windows shortcuts
477477
*.lnk
478+
479+
CodeTemplates

sample_dotnet/ExampleAPI/Context/BloggingContext.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ public class Blog
7171
public List<Post> Posts { get; } = new();
7272
}
7373

74+
[Table("Users")]
75+
public class User
76+
{
77+
[Required]
78+
public long Id { get; set; }
79+
80+
[Required]
81+
public string Name { get; set; }
82+
}
83+
7484
[Table("Posts")]
7585
public class Post
7686
{
@@ -80,6 +90,9 @@ public class Post
8090
[Required]
8191
public string Title { get; set; }
8292

93+
[Required]
94+
public User User { get; set; }
95+
8396
public List<Tag> Tags { get; } = new List<Tag>();
8497

8598
public List<PostTag> PostTags { get; } = new List<PostTag>();

sample_dotnet/ExampleAPI/Migrations/20221229215530_InitialSchema.Designer.cs renamed to sample_dotnet/ExampleAPI/Migrations/20221230152215_InitialSchema.Designer.cs

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample_dotnet/ExampleAPI/Migrations/20221229215530_InitialSchema.cs renamed to sample_dotnet/ExampleAPI/Migrations/20221230152215_InitialSchema.cs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,50 @@ public partial class InitialSchema : Migration
1111
protected override void Up(MigrationBuilder migrationBuilder)
1212
{
1313
migrationBuilder.CreateTable(
14-
name: "Posts",
14+
name: "Tags",
1515
columns: table => new
1616
{
1717
Id = table.Column<long>(type: "INTEGER", nullable: false)
1818
.Annotation("Sqlite:Autoincrement", true),
19-
Title = table.Column<string>(type: "TEXT", nullable: false),
20-
Ranking = table.Column<int>(type: "INTEGER", nullable: true)
19+
Name = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false)
2120
},
2221
constraints: table =>
2322
{
24-
table.PrimaryKey("PK_Posts", x => x.Id);
23+
table.PrimaryKey("PK_Tags", x => x.Id);
2524
});
2625

2726
migrationBuilder.CreateTable(
28-
name: "Tags",
27+
name: "Users",
2928
columns: table => new
3029
{
3130
Id = table.Column<long>(type: "INTEGER", nullable: false)
3231
.Annotation("Sqlite:Autoincrement", true),
33-
Name = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false)
32+
Name = table.Column<string>(type: "TEXT", nullable: false)
3433
},
3534
constraints: table =>
3635
{
37-
table.PrimaryKey("PK_Tags", x => x.Id);
36+
table.PrimaryKey("PK_Users", x => x.Id);
37+
});
38+
39+
migrationBuilder.CreateTable(
40+
name: "Posts",
41+
columns: table => new
42+
{
43+
Id = table.Column<long>(type: "INTEGER", nullable: false)
44+
.Annotation("Sqlite:Autoincrement", true),
45+
Title = table.Column<string>(type: "TEXT", nullable: false),
46+
UserId = table.Column<long>(type: "INTEGER", nullable: false),
47+
Ranking = table.Column<int>(type: "INTEGER", nullable: true)
48+
},
49+
constraints: table =>
50+
{
51+
table.PrimaryKey("PK_Posts", x => x.Id);
52+
table.ForeignKey(
53+
name: "FK_Posts_Users_UserId",
54+
column: x => x.UserId,
55+
principalTable: "Users",
56+
principalColumn: "Id",
57+
onDelete: ReferentialAction.Cascade);
3858
});
3959

4060
migrationBuilder.CreateTable(
@@ -61,6 +81,11 @@ protected override void Up(MigrationBuilder migrationBuilder)
6181
onDelete: ReferentialAction.Cascade);
6282
});
6383

84+
migrationBuilder.CreateIndex(
85+
name: "IX_Posts_UserId",
86+
table: "Posts",
87+
column: "UserId");
88+
6489
migrationBuilder.CreateIndex(
6590
name: "IX_PostTags_PostId",
6691
table: "PostTags",
@@ -84,6 +109,9 @@ protected override void Down(MigrationBuilder migrationBuilder)
84109

85110
migrationBuilder.DropTable(
86111
name: "Tags");
112+
113+
migrationBuilder.DropTable(
114+
name: "Users");
87115
}
88116
}
89117
}

sample_dotnet/ExampleAPI/Migrations/20221229215549_NewMigration.Designer.cs renamed to sample_dotnet/ExampleAPI/Migrations/20221230152221_NewMigration.Designer.cs

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample_dotnet/ExampleAPI/Migrations/BloggingContextModelSnapshot.cs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ protected override void BuildModel(ModelBuilder modelBuilder)
3030
.IsRequired()
3131
.HasColumnType("TEXT");
3232

33+
b.Property<long>("UserId")
34+
.HasColumnType("INTEGER");
35+
3336
b.HasKey("Id");
3437

35-
b.ToTable("Posts");
38+
b.HasIndex("UserId");
39+
40+
b.ToTable("Posts", (string)null);
3641
});
3742

3843
modelBuilder.Entity("ExampleAPI.Context.PostTag", b =>
@@ -47,7 +52,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
4752

4853
b.HasIndex("PostId");
4954

50-
b.ToTable("PostTags");
55+
b.ToTable("PostTags", (string)null);
5156
});
5257

5358
modelBuilder.Entity("ExampleAPI.Context.Tag", b =>
@@ -66,7 +71,33 @@ protected override void BuildModel(ModelBuilder modelBuilder)
6671
b.HasIndex("Name")
6772
.IsUnique();
6873

69-
b.ToTable("Tags");
74+
b.ToTable("Tags", (string)null);
75+
});
76+
77+
modelBuilder.Entity("ExampleAPI.Context.User", b =>
78+
{
79+
b.Property<long>("Id")
80+
.ValueGeneratedOnAdd()
81+
.HasColumnType("INTEGER");
82+
83+
b.Property<string>("Name")
84+
.IsRequired()
85+
.HasColumnType("TEXT");
86+
87+
b.HasKey("Id");
88+
89+
b.ToTable("Users", (string)null);
90+
});
91+
92+
modelBuilder.Entity("ExampleAPI.Context.Post", b =>
93+
{
94+
b.HasOne("ExampleAPI.Context.User", "User")
95+
.WithMany()
96+
.HasForeignKey("UserId")
97+
.OnDelete(DeleteBehavior.Cascade)
98+
.IsRequired();
99+
100+
b.Navigation("User");
70101
});
71102

72103
modelBuilder.Entity("ExampleAPI.Context.PostTag", b =>
4 KB
Binary file not shown.

src/actions/GenerateERDAction.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,8 @@ export class GenerateERDAction extends TerminalAction {
173173

174174
return output;
175175
} catch (e) {
176-
this.logger.error(
177-
'Unable to generate ER diagram',
178-
(e as Error).message,
179-
);
176+
const msg = `Unable to generate ER diagram: ${(e as Error).message}`;
177+
this.logger.error(msg);
180178
return '';
181179
} finally {
182180
try {

src/cli/CLI.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export class CLI {
136136
});
137137

138138
cmd?.on('exit', async code => {
139+
handlers?.onStdOut?.(`Exited with code ${code}\n`);
139140
const error = stderr || CLI.getErrorsFromStdOut(stdout);
140141
if (error || code !== 0) {
141142
const finalError = CLI.filterInfoFromOutput(error || stdout);

0 commit comments

Comments
 (0)