|
|
@ -6,7 +6,7 @@ import { |
|
|
|
OnModuleInit, |
|
|
|
OnModuleInit, |
|
|
|
Optional, |
|
|
|
Optional, |
|
|
|
} from '@nestjs/common'; |
|
|
|
} from '@nestjs/common'; |
|
|
|
|
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import { customAlphabet } from 'nanoid'; |
|
|
|
import { customAlphabet } from 'nanoid'; |
|
|
|
import CryptoJS from 'crypto-js'; |
|
|
|
import CryptoJS from 'crypto-js'; |
|
|
|
import { Connection } from '../connection/connection'; |
|
|
|
import { Connection } from '../connection/connection'; |
|
|
@ -256,8 +256,8 @@ export class MetaService { |
|
|
|
|
|
|
|
|
|
|
|
await this.knexConnection(target).insert({ |
|
|
|
await this.knexConnection(target).insert({ |
|
|
|
...insertObj, |
|
|
|
...insertObj, |
|
|
|
created_at: data?.created_at || this.knexConnection?.fn?.now(), |
|
|
|
created_at: this.now(), |
|
|
|
updated_at: data?.updated_at || this.knexConnection?.fn?.now(), |
|
|
|
updated_at: this.now(), |
|
|
|
}); |
|
|
|
}); |
|
|
|
return insertObj; |
|
|
|
return insertObj; |
|
|
|
} |
|
|
|
} |
|
|
@ -539,9 +539,9 @@ export class MetaService { |
|
|
|
return this.knexConnection(target).insert({ |
|
|
|
return this.knexConnection(target).insert({ |
|
|
|
db_alias: dbAlias, |
|
|
|
db_alias: dbAlias, |
|
|
|
project_id, |
|
|
|
project_id, |
|
|
|
created_at: this.knexConnection?.fn?.now(), |
|
|
|
|
|
|
|
updated_at: this.knexConnection?.fn?.now(), |
|
|
|
|
|
|
|
...data, |
|
|
|
...data, |
|
|
|
|
|
|
|
created_at: this.now(), |
|
|
|
|
|
|
|
updated_at: this.now(), |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -689,7 +689,7 @@ export class MetaService { |
|
|
|
|
|
|
|
|
|
|
|
delete data.created_at; |
|
|
|
delete data.created_at; |
|
|
|
|
|
|
|
|
|
|
|
query.update({ ...data, updated_at: this.knexConnection?.fn?.now() }); |
|
|
|
query.update({ ...data, updated_at: this.now() }); |
|
|
|
if (typeof idOrCondition !== 'object') { |
|
|
|
if (typeof idOrCondition !== 'object') { |
|
|
|
query.where('id', idOrCondition); |
|
|
|
query.where('id', idOrCondition); |
|
|
|
} else if (idOrCondition) { |
|
|
|
} else if (idOrCondition) { |
|
|
@ -810,8 +810,8 @@ export class MetaService { |
|
|
|
// todo: check project name used or not
|
|
|
|
// todo: check project name used or not
|
|
|
|
await this.knexConnection('nc_projects').insert({ |
|
|
|
await this.knexConnection('nc_projects').insert({ |
|
|
|
...project, |
|
|
|
...project, |
|
|
|
created_at: this.knexConnection?.fn?.now(), |
|
|
|
created_at: this.now(), |
|
|
|
updated_at: this.knexConnection?.fn?.now(), |
|
|
|
updated_at: this.now(), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// todo
|
|
|
|
// todo
|
|
|
@ -1030,6 +1030,20 @@ export class MetaService { |
|
|
|
return nanoid(); |
|
|
|
return nanoid(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private isMySQL(): boolean { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
this.connection.clientType() === 'mysql' || |
|
|
|
|
|
|
|
this.connection.clientType() === 'mysql2' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private now(): any { |
|
|
|
|
|
|
|
if (this.isMySQL()) { |
|
|
|
|
|
|
|
return dayjs().utc().format('YYYY-MM-DD HH:mm:ss'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return dayjs().utc().toISOString(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async audit( |
|
|
|
public async audit( |
|
|
|
project_id: string, |
|
|
|
project_id: string, |
|
|
|
dbAlias: string, |
|
|
|
dbAlias: string, |
|
|
@ -1051,6 +1065,10 @@ export class MetaService { |
|
|
|
migrationSource: new XcMigrationSourcev2(), |
|
|
|
migrationSource: new XcMigrationSourcev2(), |
|
|
|
tableName: 'xc_knex_migrationsv2', |
|
|
|
tableName: 'xc_knex_migrationsv2', |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
if (this.isMySQL()) { |
|
|
|
|
|
|
|
// set timezone
|
|
|
|
|
|
|
|
await this.connection.raw(`SET time_zone = '+00:00'`); |
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|