Repository navigation
Closed
Labels
Description
Issue Description
With no changes to any entities, typeorm is generating migration query statements when running migration:generate.
Expected Behavior
With no changes to an entity, typeorm should not be generating any migration query statements when running migration:generate.
Actual Behavior
With no changes to any entities, typeorm is generating migration query statements when running migration:generate.
// EXAMPLE OUTPUT:
import { MigrationInterface, QueryRunner } from 'typeorm';
export class AddressRefactor1631155178620 implements MigrationInterface {
name = 'AddressRefactor1631155178620';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` DROP FOREIGN KEY \`FK_53c83b83f4e367eb4349fe04029\``
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`address\` DROP PRIMARY KEY`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`address\` DROP COLUMN \`id\``);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`address\` ADD \`id\` char(36) NOT NULL PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP FOREIGN KEY \`FK_738760be7585aee2b59abcfb523\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` DROP FOREIGN KEY \`FK_81f288cfe50872d55c40c7d4c32\``
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`designation\` DROP PRIMARY KEY`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`designation\` DROP COLUMN \`id\``);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`designation\` ADD \`id\` char(36) NOT NULL PRIMARY KEY`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`designation\` CHANGE \`label\` \`label\` text NULL`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` DROP FOREIGN KEY \`FK_e0fcffa1693ff731d49753e6d03\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` DROP FOREIGN KEY \`FK_c6a0b53ff561e1617f4ba97dee1\``
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`position\` DROP PRIMARY KEY`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`position\` DROP COLUMN \`id\``);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`position\` ADD \`id\` char(36) NOT NULL PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP FOREIGN KEY \`FK_c39a002aa35cb07fc3900e7638e\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` DROP FOREIGN KEY \`FK_28e9f06f4b7afe099bfc403e6f7\``
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` DROP PRIMARY KEY`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` DROP COLUMN \`id\``);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` ADD \`id\` char(36) NOT NULL PRIMARY KEY`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` CHANGE \`salary\` \`salary\` int NULL`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` CHANGE \`yearsOfExperience\` \`yearsOfExperience\` int NULL`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` DROP COLUMN \`positionId\``);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` ADD \`positionId\` char(36) NULL`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` DROP COLUMN \`addressId\``);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` ADD \`addressId\` char(36) NULL`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`firstName\` \`firstName\` varchar(255) NULL`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`lastName\` \`lastName\` varchar(255) NULL`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`email\` \`email\` varchar(255) NULL`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`regionsOfInterest\` \`regionsOfInterest\` text NULL`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`yearsOfExperience\` \`yearsOfExperience\` int NULL`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`youtubeVideoLink\` \`youtubeVideoLink\` varchar(255) NULL`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`linkedInLink\` \`linkedInLink\` varchar(255) NULL`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`profileSummary\` \`profileSummary\` text NULL`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`salary\` \`salary\` int NULL`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`phoneNumber\` \`phoneNumber\` varchar(255) NULL`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD PRIMARY KEY (\`designationId\`)`
);
await queryRunner.query(
`DROP INDEX \`IDX_c39a002aa35cb07fc3900e7638\` ON \`database_name\`.\`work_role_designations_designation\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP COLUMN \`workRoleId\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD \`workRoleId\` char(36) NOT NULL`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD PRIMARY KEY (\`designationId\`, \`workRoleId\`)`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD PRIMARY KEY (\`workRoleId\`)`
);
await queryRunner.query(
`DROP INDEX \`IDX_738760be7585aee2b59abcfb52\` ON \`database_name\`.\`work_role_designations_designation\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP COLUMN \`designationId\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD \`designationId\` char(36) NOT NULL`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD PRIMARY KEY (\`workRoleId\`, \`designationId\`)`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` DROP PRIMARY KEY`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` ADD PRIMARY KEY (\`profileId\`)`
);
await queryRunner.query(
`DROP INDEX \`IDX_c6a0b53ff561e1617f4ba97dee\` ON \`database_name\`.\`profile_positions_of_interest_position\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` DROP COLUMN \`positionId\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` ADD \`positionId\` char(36) NOT NULL`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` DROP PRIMARY KEY`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` ADD PRIMARY KEY (\`profileId\`, \`positionId\`)`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` ADD PRIMARY KEY (\`profileId\`)`
);
await queryRunner.query(
`DROP INDEX \`IDX_28e9f06f4b7afe099bfc403e6f\` ON \`database_name\`.\`profile_selected_work_roles_work_role\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` DROP COLUMN \`workRoleId\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` ADD \`workRoleId\` char(36) NOT NULL`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` ADD PRIMARY KEY (\`profileId\`, \`workRoleId\`)`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`profile_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` ADD PRIMARY KEY (\`profileId\`)`
);
await queryRunner.query(
`DROP INDEX \`IDX_81f288cfe50872d55c40c7d4c3\` ON \`database_name\`.\`profile_designations_designation\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` DROP COLUMN \`designationId\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` ADD \`designationId\` char(36) NOT NULL`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`profile_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` ADD PRIMARY KEY (\`profileId\`, \`designationId\`)`
);
await queryRunner.query(
`CREATE INDEX \`IDX_c39a002aa35cb07fc3900e7638\` ON \`database_name\`.\`work_role_designations_designation\` (\`workRoleId\`)`
);
await queryRunner.query(
`CREATE INDEX \`IDX_738760be7585aee2b59abcfb52\` ON \`database_name\`.\`work_role_designations_designation\` (\`designationId\`)`
);
await queryRunner.query(
`CREATE INDEX \`IDX_c6a0b53ff561e1617f4ba97dee\` ON \`database_name\`.\`profile_positions_of_interest_position\` (\`positionId\`)`
);
await queryRunner.query(
`CREATE INDEX \`IDX_28e9f06f4b7afe099bfc403e6f\` ON \`database_name\`.\`profile_selected_work_roles_work_role\` (\`workRoleId\`)`
);
await queryRunner.query(
`CREATE INDEX \`IDX_81f288cfe50872d55c40c7d4c3\` ON \`database_name\`.\`profile_designations_designation\` (\`designationId\`)`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` ADD CONSTRAINT \`FK_e0fcffa1693ff731d49753e6d03\` FOREIGN KEY (\`positionId\`) REFERENCES \`database_name\`.\`position\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` ADD CONSTRAINT \`FK_53c83b83f4e367eb4349fe04029\` FOREIGN KEY (\`addressId\`) REFERENCES \`database_name\`.\`address\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD CONSTRAINT \`FK_c39a002aa35cb07fc3900e7638e\` FOREIGN KEY (\`workRoleId\`) REFERENCES \`database_name\`.\`work_role\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD CONSTRAINT \`FK_738760be7585aee2b59abcfb523\` FOREIGN KEY (\`designationId\`) REFERENCES \`database_name\`.\`designation\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` ADD CONSTRAINT \`FK_c6a0b53ff561e1617f4ba97dee1\` FOREIGN KEY (\`positionId\`) REFERENCES \`database_name\`.\`position\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` ADD CONSTRAINT \`FK_28e9f06f4b7afe099bfc403e6f7\` FOREIGN KEY (\`workRoleId\`) REFERENCES \`database_name\`.\`work_role\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` ADD CONSTRAINT \`FK_81f288cfe50872d55c40c7d4c32\` FOREIGN KEY (\`designationId\`) REFERENCES \`database_name\`.\`designation\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` DROP FOREIGN KEY \`FK_81f288cfe50872d55c40c7d4c32\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` DROP FOREIGN KEY \`FK_28e9f06f4b7afe099bfc403e6f7\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` DROP FOREIGN KEY \`FK_c6a0b53ff561e1617f4ba97dee1\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP FOREIGN KEY \`FK_738760be7585aee2b59abcfb523\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP FOREIGN KEY \`FK_c39a002aa35cb07fc3900e7638e\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` DROP FOREIGN KEY \`FK_53c83b83f4e367eb4349fe04029\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` DROP FOREIGN KEY \`FK_e0fcffa1693ff731d49753e6d03\``
);
await queryRunner.query(
`DROP INDEX \`IDX_81f288cfe50872d55c40c7d4c3\` ON \`database_name\`.\`profile_designations_designation\``
);
await queryRunner.query(
`DROP INDEX \`IDX_28e9f06f4b7afe099bfc403e6f\` ON \`database_name\`.\`profile_selected_work_roles_work_role\``
);
await queryRunner.query(
`DROP INDEX \`IDX_c6a0b53ff561e1617f4ba97dee\` ON \`database_name\`.\`profile_positions_of_interest_position\``
);
await queryRunner.query(
`DROP INDEX \`IDX_738760be7585aee2b59abcfb52\` ON \`database_name\`.\`work_role_designations_designation\``
);
await queryRunner.query(
`DROP INDEX \`IDX_c39a002aa35cb07fc3900e7638\` ON \`database_name\`.\`work_role_designations_designation\``
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`profile_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` ADD PRIMARY KEY (\`profileId\`)`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` DROP COLUMN \`designationId\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` ADD \`designationId\` varchar(36) NOT NULL`
);
await queryRunner.query(
`CREATE INDEX \`IDX_81f288cfe50872d55c40c7d4c3\` ON \`database_name\`.\`profile_designations_designation\` (\`designationId\`)`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`profile_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` ADD PRIMARY KEY (\`profileId\`, \`designationId\`)`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` ADD PRIMARY KEY (\`profileId\`)`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` DROP COLUMN \`workRoleId\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` ADD \`workRoleId\` varchar(36) NOT NULL`
);
await queryRunner.query(
`CREATE INDEX \`IDX_28e9f06f4b7afe099bfc403e6f\` ON \`database_name\`.\`profile_selected_work_roles_work_role\` (\`workRoleId\`)`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` ADD PRIMARY KEY (\`profileId\`, \`workRoleId\`)`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` DROP PRIMARY KEY`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` ADD PRIMARY KEY (\`profileId\`)`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` DROP COLUMN \`positionId\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` ADD \`positionId\` varchar(36) NOT NULL`
);
await queryRunner.query(
`CREATE INDEX \`IDX_c6a0b53ff561e1617f4ba97dee\` ON \`database_name\`.\`profile_positions_of_interest_position\` (\`positionId\`)`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` DROP PRIMARY KEY`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` ADD PRIMARY KEY (\`profileId\`, \`positionId\`)`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD PRIMARY KEY (\`workRoleId\`)`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP COLUMN \`designationId\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD \`designationId\` varchar(36) NOT NULL`
);
await queryRunner.query(
`CREATE INDEX \`IDX_738760be7585aee2b59abcfb52\` ON \`database_name\`.\`work_role_designations_designation\` (\`designationId\`)`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD PRIMARY KEY (\`designationId\`, \`workRoleId\`)`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD PRIMARY KEY (\`designationId\`)`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP COLUMN \`workRoleId\``
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD \`workRoleId\` varchar(36) NOT NULL`
);
await queryRunner.query(
`CREATE INDEX \`IDX_c39a002aa35cb07fc3900e7638\` ON \`database_name\`.\`work_role_designations_designation\` (\`workRoleId\`)`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` DROP PRIMARY KEY`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD PRIMARY KEY (\`workRoleId\`, \`designationId\`)`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`phoneNumber\` \`phoneNumber\` varchar(255) NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`salary\` \`salary\` int NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`profileSummary\` \`profileSummary\` text NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`linkedInLink\` \`linkedInLink\` varchar(255) NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`youtubeVideoLink\` \`youtubeVideoLink\` varchar(255) NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`yearsOfExperience\` \`yearsOfExperience\` int NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`regionsOfInterest\` \`regionsOfInterest\` text NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`email\` \`email\` varchar(255) NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`lastName\` \`lastName\` varchar(255) NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile\` CHANGE \`firstName\` \`firstName\` varchar(255) NULL DEFAULT 'NULL'`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` DROP COLUMN \`addressId\``);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` ADD \`addressId\` varchar(36) NULL DEFAULT 'NULL'`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` DROP COLUMN \`positionId\``);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` ADD \`positionId\` varchar(36) NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` CHANGE \`yearsOfExperience\` \`yearsOfExperience\` int NULL DEFAULT 'NULL'`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` CHANGE \`salary\` \`salary\` int NULL DEFAULT 'NULL'`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` DROP COLUMN \`id\``);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` ADD \`id\` varchar(36) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`work_role\` ADD PRIMARY KEY (\`id\`)`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_selected_work_roles_work_role\` ADD CONSTRAINT \`FK_28e9f06f4b7afe099bfc403e6f7\` FOREIGN KEY (\`workRoleId\`) REFERENCES \`database_name\`.\`work_role\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD CONSTRAINT \`FK_c39a002aa35cb07fc3900e7638e\` FOREIGN KEY (\`workRoleId\`) REFERENCES \`database_name\`.\`work_role\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`position\` DROP COLUMN \`id\``);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`position\` ADD \`id\` varchar(36) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`position\` ADD PRIMARY KEY (\`id\`)`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_positions_of_interest_position\` ADD CONSTRAINT \`FK_c6a0b53ff561e1617f4ba97dee1\` FOREIGN KEY (\`positionId\`) REFERENCES \`database_name\`.\`position\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` ADD CONSTRAINT \`FK_e0fcffa1693ff731d49753e6d03\` FOREIGN KEY (\`positionId\`) REFERENCES \`database_name\`.\`position\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`designation\` CHANGE \`label\` \`label\` text NULL DEFAULT 'NULL'`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`designation\` DROP COLUMN \`id\``);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`designation\` ADD \`id\` varchar(36) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`designation\` ADD PRIMARY KEY (\`id\`)`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`profile_designations_designation\` ADD CONSTRAINT \`FK_81f288cfe50872d55c40c7d4c32\` FOREIGN KEY (\`designationId\`) REFERENCES \`database_name\`.\`designation\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role_designations_designation\` ADD CONSTRAINT \`FK_738760be7585aee2b59abcfb523\` FOREIGN KEY (\`designationId\`) REFERENCES \`database_name\`.\`designation\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`address\` DROP COLUMN \`id\``);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`address\` ADD \`id\` varchar(36) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`database_name\`.\`address\` ADD PRIMARY KEY (\`id\`)`);
await queryRunner.query(
`ALTER TABLE \`database_name\`.\`work_role\` ADD CONSTRAINT \`FK_53c83b83f4e367eb4349fe04029\` FOREIGN KEY (\`addressId\`) REFERENCES \`database_name\`.\`address\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
}
}Steps to Reproduce
- Configure typeorm, add some types and run
schema:sync - Run
migration:generate
typeorm schema:sync
typeorm migration:generateMy Environment
| Dependency | Version |
|---|---|
| Operating System | any/mac os/linux |
| Node.js version | 12.18.3 |
| Typescript version | 4.0.2 |
| TypeORM version | 0.2.37 |
Additional Context
Relevant Database Driver(s)
MySQL driver connecting to MariaDB in AWS RDS.
| DB Type | Reproducible |
|---|---|
aurora-data-api |
no |
aurora-data-api-pg |
no |
better-sqlite3 |
no |
cockroachdb |
no |
cordova |
no |
expo |
no |
mongodb |
no |
mysql |
YES |
nativescript |
no |
oracle |
no |
postgres |
no |
react-native |
no |
sap |
no |
sqlite |
no |
sqlite-abstract |
no |
sqljs |
no |
sqlserver |
no |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
- ✖️ No, I don’t have the time, but I can support (using donations) development.
- ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Reacted by Emtiaj Hasan
Activity
Kage0x3B commentedon Sep 9, 2021
Just a guess as I had the same issue earlier, but do you use a custom naming strategy?
In the example output, you replaced the actual database name so I can't see it from there.
If you do, that might be the issue, if you didn't configure the typeorm cli correctly, to use the same naming strategy as the connection in your actual program.
The cli then searches for existing tables/keys/etc. with the default naming strategy, finds none, as the names are different and assumes the tables don't exist yet and generates this big migration.
resistdesign commentedon Sep 9, 2021
@Kage0x3B hmm interesting... I didn't add table names to my entity classes. Is that what you mean?
One thing I noticed was, if I do add a property to an entity class, it does put the query for that column first, like it seems to know that it's new.
Kage0x3B commentedon Sep 10, 2021
No, doesn't seem like the same problem then. I meant naming strategies, https://typeorm.io/#/naming-strategy/.
But after having fixed my issue with naming strategies, I have noticed something similar on the production database, which should be up-to-date, everything works, but typeorms sync still wants to recreate some primary keys and indexes.
Output from
typeorm schema:log:meganoob1337 commentedon Sep 10, 2021
Maybe it has something to do with this: #8173
They changed the Implementation of the SnakeCase generator so some Entity Names might get resolved differently
resistdesign commentedon Sep 10, 2021
@Kage0x3B Ok, based on that link, I definitely don't have a custom naming strategy. This is kind of weird 😛
@meganoob1337 It doesn't seem like a snake case issue for me 🤷
resistdesign commentedon Sep 10, 2021
Something interesting is that there are
CHANGElines, like this one:Why would it call it a change if it doesn't change anything?
resistdesign commentedon Sep 10, 2021
It almost feels like it's generating those lines just to set the default value, as if
schema:syncdidn't do that or something.It does seem like the default value is NOT set:

fanch317 commentedon Sep 14, 2021
Can you check that you use TYPEROM_TYPE = mariadb (instead mysql)?
I had similar case, where the NULL wasn't correctly detected. You can check #6030 (comment) for my diag.
I have abandoned and have rewrite manualy each migration, before find my mistake after many mounth in .env / ormconfig.json file.
resistdesign commentedon Sep 14, 2021
@fanch317 Oh Dang! I never would have thought of that!

resistdesign commentedon Sep 14, 2021
I have to check to see if that solves the problem.
resistdesign commentedon Sep 14, 2021
@fanch317 Oh man, I really thought you had found the issue, but after setting the type to
mariadband running the generation, it still generates the same thing 😦I even made sure to use
mariadbas the protocol in the connection URI I used, just in case, but it didn't change it.sebdec commentedon Sep 23, 2021
I have the same problem.
My understanding:
before: id and foreign keys were generated with type varchar(36)
after: id and foreign keys are now generated with type char(36)
resistdesign commentedon Sep 24, 2021
@sebdec YES! In the DB, the id field is
varchar, but in the generated migration, it wants to recreate it aschar.I wonder how this can be fixed???
pleerock commentedon Nov 9, 2021
Looks like this is duplicate of #8002
pleerock commentedon Nov 9, 2021
Fixed by #8343
resistdesign commentedon Nov 9, 2021
For real!??? This will fix my problem!? 😲😲😲😁😁😁
gagermaniac commentedon Nov 17, 2021
changing typeorm type to mariadb do fix my problem, thanks