add db migration

This commit is contained in:
liuyi 2025-06-20 22:46:11 +08:00
parent cecc96bbba
commit edff100ef2
2 changed files with 11 additions and 8 deletions

View File

@ -1,12 +1,14 @@
/* eslint-disable @typescript-eslint/no-require-imports */
import { resolve } from 'path';
import chalk from 'chalk';
import { CommandUtils } from 'typeorm/commands/CommandUtils';
import { PlatformTools } from 'typeorm/platform/PlatformTools';
import { camelCase } from 'typeorm/util/StringUtils';
import { MigrationCreateOptions } from '@/modules/database/commands/types';
const { CommandUtils } = require('typeorm/commands/CommandUtils');
const { PlatformTools } = require('typeorm/platform/PlatformTools');
const { camelCase } = require('typeorm/util/StringUtils');
type HandleOptions = MigrationCreateOptions & { dir: string };
export class TypeormMigrationCreate {

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-require-imports */
import { resolve } from 'path';
import chalk from 'chalk';
@ -5,13 +6,12 @@ import { upperFirst } from 'lodash';
import { format } from 'mysql2';
import { DataSource } from 'typeorm';
import { CommandUtils } from 'typeorm/commands/CommandUtils';
import { PlatformTools } from 'typeorm/platform/PlatformTools';
import { camelCase } from 'typeorm/util/StringUtils';
import { MigrationGenerateOptions } from '@/modules/database/commands/types';
const { CommandUtils } = require('typeorm/commands/CommandUtils');
const { PlatformTools } = require('typeorm/platform/PlatformTools');
const { camelCase } = require('typeorm/util/StringUtils');
type HandlerOptions = MigrationGenerateOptions & { dataSource: DataSource } & { dir: string };
export class TypeormMigrationGenerate {
@ -44,6 +44,7 @@ export class TypeormMigrationGenerate {
downSql.query = TypeormMigrationGenerate.prettifyQuery(downSql.query);
});
}
console.log('sqlInMemory', sqlInMemory);
sqlInMemory.upQueries.forEach((upQuery) => {
upSqls.push(
` await queryRunner.query(\`${upQuery.query.replace(