hunk.code_window:  * Generates a new migration file with sql needs to be executed to update schema.
    */
   export class MigrationGenerateCommand {
       command = "migrations:generate";
       describe = "Generates a new migration file with sql needs to be executed to update schema.";
       builder(yargs: any) {
           return yargs
  
hunk.labels: keep keep keep keep replace keep keep keep keep
hunk.after_edit:     command = "migration:generate";
  
hunk.file_path: src/commands/MigrationGenerateCommand.ts
hunk.type: replace
file: import "reflect-metadata";
  import {expect} from "chai";
  import {
      closeTestingConnections,
      createTestingConnections,
      reloadTestingDatabases
  } from "../../../../../utils/test-utils";
  import {Connection} from "../../../../../../src/connection/Connection";
  import {Post} from "./entity/Post";
  import {Category} from "./entity/Category";
  import {Counters} from "./entity/Counters";
  import {User} from "./entity/User";
  import {Subcounters} from "./entity/Subcounters";
  
  describe("query builder > relation-id > one-to-one > embedded", () => {
  
      let connections: Connection[];
      before(async () => connections = await createTestingConnections({
          entities: [__dirname + "/entity/*{.js,.ts}"],
      }));
      beforeEach(() => reloadTestingDatabases(connections));
      after(() => closeTestingConnections(connections));
  
      it("should load ids when loadRelationIdAndMap used on embedded and nested embedded tables", () => Promise.all(connections.map(async connection => {
  
          const user1 = new User();
          user1.name = "Alice";
          await connection.manager.save(user1);
  
          const user2 = new User();
          user2.name = "Bob";
          await connection.manager.save(user2);
  
          const category1 = new Category();
          category1.name = "cars";
          await connection.manager.save(category1);
  
          const category2 = new Category();
          category2.name = "airplanes";
          await connection.manager.save(category2);
  
          const post1 = new Post();
          post1.title = "About BMW";
          post1.counters = new Counters();
          post1.counters.likes = 1;
          post1.counters.comments = 2;
          post1.counters.favorites = 3;
          post1.counters.category = category1;
          post1.counters.subcounters = new Subcounters();
          post1.counters.subcounters.version = 1;
          post1.counters.subcounters.watches = 2;
          post1.counters.subcounters.watchedUser = user1;
          await connection.manager.save(post1);
  
          const post2 = new Post();
          post2.title = "About Boeing";
          post2.counters = new Counters();
          post2.counters.likes = 3;
          post2.counters.comments = 4;
          post2.counters.favorites = 5;
          post2.counters.category = category2;
          post2.counters.subcounters = new Subcounters();
          post2.counters.subcounters.version = 1;
          post2.counters.subcounters.watches = 1;
          post2.counters.subcounters.watchedUser = user2;
          await connection.manager.save(post2);
  
          const loadedPosts = await connection.manager
              .createQueryBuilder(Post, "post")
              .loadRelationIdAndMap("post.counters.categoryId", "post.counters.category")
              .loadRelationIdAndMap("post.counters.subcounters.watchedUserId", "post.counters.subcounters.watchedUser")
              .orderBy("post.id")
              .getMany();
  
          expect(loadedPosts[0].should.be.eql(
              {
                  title: "About BMW",
                  counters: {
                      likes: 1,
                      comments: 2,
                      favorites: 3,
                      categoryId: 1,
                      subcounters: {
                          id: 1,
                          version: 1,
                          watches: 2,
                          watchedUserId: 1
                      }
                  }
              }
          ));
          expect(loadedPosts[1].should.be.eql(
              {
                  title: "About Boeing",
                  counters: {
                      likes: 3,
                      comments: 4,
                      favorites: 5,
                      categoryId: 2,
                      subcounters: {
                          id: 2,
                          version: 1,
                          watches: 1,
                          watchedUserId: 2
                      }
                  }
              }
          ));
  
      })));
  
  });