Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
chore: update migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Nov 4, 2022
1 parent d4bd928 commit 410bd11
Show file tree
Hide file tree
Showing 5 changed files with 656 additions and 536 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3'
services:
eoapi-remote-server:
# build: 从当前路径构建镜像
build: .
# build: .
image: eolinker/eoapi-remote-server:latest
container_name: eoapi-remote-server
deploy:
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
"docker:logs": "docker compose logs -f"
},
"dependencies": {
"@nestjs/axios": "^0.1.0",
"@nestjs/common": "^9.1.2",
"@nestjs/axios": "^1.0.0",
"@nestjs/common": "^9.1.6",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.1.2",
"@nestjs/core": "^9.1.6",
"@nestjs/jwt": "^9.0.0",
"@nestjs/mapped-types": "*",
"@nestjs/passport": "^9.0.0",
"@nestjs/platform-express": "^9.1.2",
"@nestjs/swagger": "^6.1.2",
"@nestjs/platform-express": "^9.1.6",
"@nestjs/swagger": "^6.1.3",
"@nestjs/typeorm": "^9.0.1",
"ajv": "^8.11.0",
"class-transformer": "^0.5.1",
Expand All @@ -58,32 +58,32 @@
"typeorm": "^0.3.10"
},
"devDependencies": {
"@nestjs/cli": "^9.1.3",
"@nestjs/cli": "^9.1.5",
"@nestjs/schematics": "^9.0.3",
"@nestjs/testing": "^9.1.2",
"@nestjs/testing": "^9.1.6",
"@types/crypto-js": "^4.1.1",
"@types/express": "^4.17.14",
"@types/jest": "29.0.3",
"@types/node": "^18.7.23",
"@types/jest": "29.2.1",
"@types/node": "^18.11.9",
"@types/passport": "^1.0.11",
"@types/passport-http": "^0.3.9",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"dotenv": "^16.0.2",
"eslint": "^8.24.0",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"dotenv": "^16.0.3",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "29.0.3",
"jest": "29.2.2",
"prettier": "^2.7.1",
"source-map-support": "^0.5.21",
"supertest": "^6.2.4",
"ts-jest": "29.0.2",
"supertest": "^6.3.1",
"ts-jest": "29.0.3",
"ts-loader": "^9.4.1",
"ts-node": "^10.9.1",
"tsconfig-paths": "4.1.0",
"typescript": "^4.8.3"
"typescript": "^4.8.4"
},
"jest": {
"moduleFileExtensions": [
Expand Down
2 changes: 1 addition & 1 deletion src/entities/base.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export abstract class FictitiousBase extends TimestampBase {
}

export abstract class Base extends FictitiousBase {
@Column()
@Column({ length: '500' })
@ApiProperty()
name: string;

Expand Down
69 changes: 40 additions & 29 deletions src/migrations/1666580390462-update-table_1_9_0.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { MigrationInterface, QueryRunner } from 'typeorm';

export class updateTable1901666580390462 implements MigrationInterface {
name = 'updateTable1901666580390462'
name = 'updateTable1901666580390462';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`shared\` (\`createdAt\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updatedAt\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`uuid\` int NOT NULL AUTO_INCREMENT, \`uniqueID\` varchar(36) NOT NULL, \`projectID\` int NOT NULL, PRIMARY KEY (\`uuid\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`api_data\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`api_data\` ADD \`name\` varchar(255) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`api_group\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`api_group\` ADD \`name\` varchar(255) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`project\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`project\` ADD \`name\` varchar(255) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`mock\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`mock\` ADD \`name\` varchar(255) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`environment\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`environment\` ADD \`name\` varchar(255) NOT NULL`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`environment\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`environment\` ADD \`name\` varchar(500) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`mock\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`mock\` ADD \`name\` varchar(500) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`project\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`project\` ADD \`name\` varchar(500) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`api_group\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`api_group\` ADD \`name\` varchar(500) NOT NULL`);
await queryRunner.query(`ALTER TABLE \`api_data\` DROP COLUMN \`name\``);
await queryRunner.query(`ALTER TABLE \`api_data\` ADD \`name\` varchar(500) NOT NULL`);
await queryRunner.query(`DROP TABLE \`shared\``);
}
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE \`shared\` (\`createdAt\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updatedAt\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`uuid\` int NOT NULL AUTO_INCREMENT, \`uniqueID\` varchar(36) NOT NULL, \`projectID\` int NOT NULL, PRIMARY KEY (\`uuid\`)) ENGINE=InnoDB`,
);
await queryRunner.query(
`ALTER TABLE \`api_group\` modify column \`name\` varchar(500) NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE \`environment\` modify column \`name\` varchar(500) NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE \`project\` modify column \`name\` varchar(500) NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE \`mock\` modify column \`name\` varchar(500) NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE \`api_data\` modify column \`name\` varchar(500) NOT NULL`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE \`api_data\` modify column \`name\` varchar(255) NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE \`mock\` modify column \`name\` varchar(255) NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE \`project\` modify column \`name\` varchar(255) NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE \`environment\` modify column \`name\` varchar(255) NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE \`api_group\` modify column \`name\` varchar(255) NOT NULL`,
);
await queryRunner.query(`DROP TABLE \`shared\``);
}
}
Loading

0 comments on commit 410bd11

Please sign in to comment.