|
|
|
@ -29,10 +29,16 @@ export class OldDBTasksService {
@@ -29,10 +29,16 @@ export class OldDBTasksService {
|
|
|
|
|
private readonly tasksEventsService: Tasks.ITasksEventsService |
|
|
|
|
@Inject(TASKS_REPOSITORY) private readonly tasksRepository: ITasksRepository |
|
|
|
|
|
|
|
|
|
constructor(@InjectConnection('old') private readonly connection: Connection) {} |
|
|
|
|
constructor( |
|
|
|
|
@InjectConnection('old') private readonly connection: Connection, |
|
|
|
|
@InjectConnection() private readonly connectionCurrent: Connection, |
|
|
|
|
) {} |
|
|
|
|
|
|
|
|
|
public async run() { |
|
|
|
|
await this.connectionCurrent.query('ALTER SEQUENCE tasks_id_seq RESTART WITH 100000;') |
|
|
|
|
|
|
|
|
|
const oldTasks = await this.getOldTasks() |
|
|
|
|
|
|
|
|
|
for await (const oldTask of oldTasks) { |
|
|
|
|
try { |
|
|
|
|
await this.saveTask(oldTask) |
|
|
|
@ -40,10 +46,15 @@ export class OldDBTasksService {
@@ -40,10 +46,15 @@ export class OldDBTasksService {
|
|
|
|
|
console.log('Error on save task', oldTask, e) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const lastTask = oldTasks[oldTasks.length - 1].id + 50 |
|
|
|
|
|
|
|
|
|
await this.connectionCurrent.query(`ALTER SEQUENCE tasks_id_seq RESTART WITH ${lastTask};`) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private async getOldTasks(): Promise<IOldTask[]> { |
|
|
|
|
const result = await this.connection.query('SELECT * FROM task', []) |
|
|
|
|
const result = await this.connection.query('SELECT * FROM task ORDER BY task.id ASC', []) |
|
|
|
|
|
|
|
|
|
return result |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -66,6 +77,7 @@ export class OldDBTasksService {
@@ -66,6 +77,7 @@ export class OldDBTasksService {
|
|
|
|
|
const createdAt = oldTask.create_date |
|
|
|
|
? new Date(oldTask.create_date).toDateString() |
|
|
|
|
: new Date(Number(oldTask.created_at)).toDateString() |
|
|
|
|
|
|
|
|
|
const status = this.getStatus(oldTask) |
|
|
|
|
|
|
|
|
|
const task = await this.tasksRepository.save({ |
|
|
|
|