mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
perf: 修改sql升级语句,兼容mysql5.7
This commit is contained in:
@@ -11,6 +11,8 @@ typeorm:
|
||||
default:
|
||||
logging: false
|
||||
|
||||
flyway:
|
||||
allowHashNotMatch: true
|
||||
|
||||
account:
|
||||
server:
|
||||
|
||||
@@ -97,7 +97,7 @@ CREATE TABLE `cd_cert_info`
|
||||
|
||||
CREATE INDEX `index_cert_info_user_id` ON `cd_cert_info` (`user_id`);
|
||||
CREATE INDEX `index_cert_info_domain` ON `cd_cert_info` (`domain`);
|
||||
CREATE INDEX `index_cert_info_domains` ON `cd_cert_info` (`domains`(200));
|
||||
CREATE INDEX `index_cert_info_domains` ON `cd_cert_info` (`domains`(190));
|
||||
CREATE INDEX `index_cert_info_pipeline` ON `cd_cert_info` (`pipeline_id`);
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ CREATE TABLE `cd_site_info`
|
||||
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE INDEX `index_site_info_user_id` ON `cd_site_info` (`user_id`);
|
||||
CREATE INDEX `index_site_info_domain` ON `cd_site_info` (`domain`);
|
||||
|
||||
@@ -16,5 +16,5 @@ CREATE TABLE `cd_domain`
|
||||
);
|
||||
|
||||
CREATE INDEX `index_domain_user_id` ON `cd_domain` (`user_id`);
|
||||
CREATE INDEX `index_domain_domain` ON `cd_domain` (`domain`);
|
||||
CREATE INDEX `index_domain_domain` ON `cd_domain` (`domain`(100));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
CREATE TABLE `cd_oauth_bound`
|
||||
CREATE TABLE IF NOT EXISTS `cd_oauth_bound`
|
||||
(
|
||||
`id` bigint PRIMARY KEY AUTO_INCREMENT NOT NULL,
|
||||
`user_id` bigint NOT NULL,
|
||||
@@ -7,8 +7,8 @@ CREATE TABLE `cd_oauth_bound`
|
||||
`open_id` varchar(512) NOT NULL,
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
|
||||
CREATE INDEX `index_oauth_bound_user_id` ON `cd_oauth_bound` (`user_id`);
|
||||
CREATE INDEX `index_oauth_bound_open_id` ON `cd_oauth_bound` (`open_id`);
|
||||
CREATE INDEX `index_oauth_bound_open_id` ON `cd_oauth_bound` (`open_id`(190));
|
||||
|
||||
@@ -75,6 +75,8 @@ function transformMysql() {
|
||||
pgSql = pgSql.replaceAll(/text/g, 'longtext');
|
||||
//双引号 替换成反引号
|
||||
pgSql = pgSql.replaceAll(/"/g, '`');
|
||||
//create table if not exists
|
||||
pgSql = pgSql.replaceAll(/CREATE TABLE ([ ]+)`/g, 'CREATE TABLE IF NOT EXISTS `');
|
||||
|
||||
fs.writeFileSync(`./migration-mysql/${notFile}`, pgSql);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { MidwayConfig } from '@midwayjs/core';
|
||||
// import { fileURLToPath } from 'node:url';
|
||||
// // const __filename = fileURLToPath(import.meta.url);
|
||||
// const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
import { FlywayHistory } from '@certd/midway-flyway-js';
|
||||
import { FlywayHistory, setFlywayLogger } from '@certd/midway-flyway-js';
|
||||
import { UserEntity } from '../modules/sys/authority/entity/user.js';
|
||||
import { PipelineEntity } from '../modules/pipeline/entity/pipeline.js';
|
||||
//import { logger } from '../utils/logger';
|
||||
@@ -15,6 +15,7 @@ import { commercialEntities } from '@certd/commercial-core';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { DefaultUploadFileMimeType, uploadWhiteList } from '@midwayjs/upload';
|
||||
import path from 'path';
|
||||
import { logger } from '@certd/basic';
|
||||
|
||||
const env = process.env.NODE_ENV || 'development';
|
||||
|
||||
@@ -137,4 +138,6 @@ mergeConfig(development, 'development');
|
||||
|
||||
mergeConfig(development, env);
|
||||
|
||||
setFlywayLogger(logger);
|
||||
|
||||
export default development;
|
||||
|
||||
@@ -78,7 +78,7 @@ export class MainConfiguration {
|
||||
app: koa.Application;
|
||||
|
||||
async onReady() {
|
||||
|
||||
// 设置flyway logger
|
||||
|
||||
|
||||
// add middleware
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { AccessInput, BaseAccess, IsAccess } from "@certd/pipeline";
|
||||
import { AliyunAccess } from "./aliyun-access.js";
|
||||
|
||||
@IsAccess({
|
||||
name: "alioss",
|
||||
@@ -36,6 +37,15 @@ export class AliossAccess extends BaseAccess {
|
||||
title: "Bucket",
|
||||
helper: "存储桶名称",
|
||||
required: true,
|
||||
component: {
|
||||
name: "remote-auto-complete",
|
||||
vModel: "value",
|
||||
type: "access",
|
||||
action: AliossAccess.prototype.onGetBucketList.name,
|
||||
search: false,
|
||||
pager: false,
|
||||
watches: ["accessId", "region"],
|
||||
},
|
||||
})
|
||||
bucket!: string;
|
||||
|
||||
@@ -76,6 +86,32 @@ export class AliossAccess extends BaseAccess {
|
||||
}
|
||||
}
|
||||
|
||||
async onGetBucketList() {
|
||||
const access = (await this.ctx.accessService.getById(this.accessId)) as AliyunAccess;
|
||||
const client = await this.getClient(access);
|
||||
|
||||
let res;
|
||||
const buckets = [];
|
||||
do {
|
||||
const requestData = { marker: res?.nextMarker || null, "max-keys": 1000 };
|
||||
res = await client.listBuckets(requestData);
|
||||
buckets.push(...(res?.buckets || []));
|
||||
} while (!!res?.nextMarker);
|
||||
return buckets.filter(bucket => bucket?.region === this.region).map(bucket => ({ label: `${bucket.name}<${bucket.region}>`, value: bucket.name }));
|
||||
}
|
||||
|
||||
async getClient(access: AliyunAccess) {
|
||||
// @ts-ignore
|
||||
const OSS = await import("ali-oss");
|
||||
return new OSS.default({
|
||||
accessKeyId: access.accessKeyId,
|
||||
accessKeySecret: access.accessKeySecret,
|
||||
// yourRegion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。
|
||||
region: this.region,
|
||||
//@ts-ignore
|
||||
authorizationV4: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
new AliossAccess();
|
||||
|
||||
Reference in New Issue
Block a user