import {__decorate,__param,__metadata}from'tslib';import {injectable,inject}from'inversify';import'@cdm-logger/core';import {SERVER_TYPES}from'common';import {loadAllCountries,loadAllStates,loadAllCities}from'./load-utils.js';var CountriesAndCitiesMigration_1;
let CountriesAndCitiesMigration = CountriesAndCitiesMigration_1 = class CountriesAndCitiesMigration {
  countryService;
  stateService;
  cityService;
  logger;
  // eslint-disable-next-line class-methods-use-this
  get id() {
    return 'CountriesAndCitiesMigration_20240811';
  }
  constructor(countryService, stateService, cityService, logger) {
    this.countryService = countryService;
    this.stateService = stateService;
    this.cityService = cityService;
    this.logger = logger.child({
      className: CountriesAndCitiesMigration_1.name
    });
  }
  async up() {
    await this.down();
    const updateCountryRows = async rows => this.countryService.bulkCreate(rows);
    const updateStateRows = async rows => this.stateService.bulkCreate(rows);
    const updateCityRows = async rows => this.cityService.bulkCreate(rows);
    const loadedCountries = await loadAllCountries(updateCountryRows);
    this.logger.info(`No. of Countries loaded is [%s]`, loadedCountries);
    const loadedStatesCount = await loadAllStates(updateStateRows);
    this.logger.info(`No. of States loaded is [%s]`, loadedStatesCount);
    const loadedCitiesCount = await loadAllCities(updateCityRows);
    this.logger.info(`No. of Cities loaded is [%s]`, loadedCitiesCount);
  }
  async down() {
    this.logger.info(`Countries dropped!`);
    // await this.cityService.bulkDelete({});
  }
};
CountriesAndCitiesMigration = CountriesAndCitiesMigration_1 = __decorate([injectable(), __param(0, inject(SERVER_TYPES.CountryRepository)), __param(1, inject(SERVER_TYPES.StateService)), __param(2, inject(SERVER_TYPES.CityRepository)), __param(3, inject('Logger')), __metadata("design:paramtypes", [Object, Object, Object, Object])], CountriesAndCitiesMigration);export{CountriesAndCitiesMigration};//# sourceMappingURL=countries-and-cities-migration.js.map
