테이블 타입관리 에러
This commit is contained in:
@@ -171,8 +171,8 @@ export class AuthService {
|
||||
|
||||
// 권한명들을 쉼표로 연결
|
||||
const authNames = authInfo
|
||||
.filter((auth) => auth.authority_master?.auth_name)
|
||||
.map((auth) => auth.authority_master!.auth_name!)
|
||||
.filter((auth: any) => auth.authority_master?.auth_name)
|
||||
.map((auth: any) => auth.authority_master!.auth_name!)
|
||||
.join(",");
|
||||
|
||||
// 회사 정보 조회 (Prisma ORM 사용으로 변경)
|
||||
|
||||
@@ -368,48 +368,40 @@ export class TableManagementService {
|
||||
};
|
||||
|
||||
// column_labels 테이블에 해당 컬럼이 있는지 확인
|
||||
const checkQuery = `
|
||||
SELECT COUNT(*) as count
|
||||
FROM column_labels
|
||||
WHERE table_name = $1 AND column_name = $2
|
||||
`;
|
||||
const existingColumn = await prisma.column_labels.findFirst({
|
||||
where: {
|
||||
table_name: tableName,
|
||||
column_name: columnName,
|
||||
},
|
||||
});
|
||||
|
||||
const checkResult = await this.client.query(checkQuery, [
|
||||
tableName,
|
||||
columnName,
|
||||
]);
|
||||
|
||||
if (checkResult.rows[0].count > 0) {
|
||||
if (existingColumn) {
|
||||
// 기존 컬럼 라벨 업데이트
|
||||
const updateQuery = `
|
||||
UPDATE column_labels
|
||||
SET web_type = $3, detail_settings = $4, updated_date = NOW()
|
||||
WHERE table_name = $1 AND column_name = $2
|
||||
`;
|
||||
|
||||
await this.client.query(updateQuery, [
|
||||
tableName,
|
||||
columnName,
|
||||
webType,
|
||||
JSON.stringify(finalDetailSettings),
|
||||
]);
|
||||
await prisma.column_labels.update({
|
||||
where: {
|
||||
id: existingColumn.id,
|
||||
},
|
||||
data: {
|
||||
web_type: webType,
|
||||
detail_settings: JSON.stringify(finalDetailSettings),
|
||||
updated_date: new Date(),
|
||||
},
|
||||
});
|
||||
logger.info(
|
||||
`컬럼 웹 타입 업데이트 완료: ${tableName}.${columnName} = ${webType}`
|
||||
);
|
||||
} else {
|
||||
// 새로운 컬럼 라벨 생성
|
||||
const insertQuery = `
|
||||
INSERT INTO column_labels (
|
||||
table_name, column_name, web_type, detail_settings, created_date, updated_date
|
||||
) VALUES ($1, $2, $3, $4, NOW(), NOW())
|
||||
`;
|
||||
|
||||
await this.client.query(insertQuery, [
|
||||
tableName,
|
||||
columnName,
|
||||
webType,
|
||||
JSON.stringify(finalDetailSettings),
|
||||
]);
|
||||
await prisma.column_labels.create({
|
||||
data: {
|
||||
table_name: tableName,
|
||||
column_name: columnName,
|
||||
web_type: webType,
|
||||
detail_settings: JSON.stringify(finalDetailSettings),
|
||||
created_date: new Date(),
|
||||
updated_date: new Date(),
|
||||
},
|
||||
});
|
||||
logger.info(
|
||||
`컬럼 라벨 생성 및 웹 타입 설정 완료: ${tableName}.${columnName} = ${webType}`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user