Merge pull request 'patches v1.7.4' (#123) from develop into main
Reviewed-on: #123
This commit is contained in:
commit
01723d9bf2
4 changed files with 53 additions and 4 deletions
|
@ -50,6 +50,7 @@ import { memberEducations } from "./entity/club/member/memberEducations";
|
||||||
|
|
||||||
import { BackupAndResetDatabase1749296262915 } from "./migrations/1749296262915-BackupAndResetDatabase";
|
import { BackupAndResetDatabase1749296262915 } from "./migrations/1749296262915-BackupAndResetDatabase";
|
||||||
import { CreateSchema1749296280721 } from "./migrations/1749296280721-CreateSchema";
|
import { CreateSchema1749296280721 } from "./migrations/1749296280721-CreateSchema";
|
||||||
|
import { UpdateNewsletterQueryRelation1752502069178 } from "./migrations/1752502069178-updateNewsletterQueryRelation";
|
||||||
|
|
||||||
configCheck();
|
configCheck();
|
||||||
|
|
||||||
|
@ -108,7 +109,11 @@ const dataSource = new DataSource({
|
||||||
webapiPermission,
|
webapiPermission,
|
||||||
setting,
|
setting,
|
||||||
],
|
],
|
||||||
migrations: [BackupAndResetDatabase1749296262915, CreateSchema1749296280721],
|
migrations: [
|
||||||
|
BackupAndResetDatabase1749296262915,
|
||||||
|
CreateSchema1749296280721,
|
||||||
|
UpdateNewsletterQueryRelation1752502069178,
|
||||||
|
],
|
||||||
migrationsRun: true,
|
migrationsRun: true,
|
||||||
migrationsTransactionMode: "each",
|
migrationsTransactionMode: "each",
|
||||||
subscribers: [],
|
subscribers: [],
|
||||||
|
|
|
@ -40,7 +40,7 @@ export class newsletter {
|
||||||
|
|
||||||
@ManyToOne(() => query, {
|
@ManyToOne(() => query, {
|
||||||
nullable: true,
|
nullable: true,
|
||||||
onDelete: "CASCADE",
|
onDelete: "SET NULL",
|
||||||
onUpdate: "RESTRICT",
|
onUpdate: "RESTRICT",
|
||||||
cascade: ["insert"],
|
cascade: ["insert"],
|
||||||
})
|
})
|
||||||
|
|
|
@ -65,7 +65,7 @@ export default abstract class DynamicQueryBuilder {
|
||||||
count?: number;
|
count?: number;
|
||||||
noLimit?: boolean;
|
noLimit?: boolean;
|
||||||
}): SelectQueryBuilder<ObjectLiteral> {
|
}): SelectQueryBuilder<ObjectLiteral> {
|
||||||
let affix = queryObj.id.replaceAll("-", "") ?? StringHelper.random(10);
|
let affix = queryObj.id?.replaceAll("-", "") ?? StringHelper.random(10);
|
||||||
let query = dataSource.getRepository(queryObj.table).createQueryBuilder(`${affix}_${queryObj.table}`);
|
let query = dataSource.getRepository(queryObj.table).createQueryBuilder(`${affix}_${queryObj.table}`);
|
||||||
|
|
||||||
this.buildDynamicQuery(query, queryObj, affix);
|
this.buildDynamicQuery(query, queryObj, affix);
|
||||||
|
@ -118,7 +118,7 @@ export default abstract class DynamicQueryBuilder {
|
||||||
|
|
||||||
if (queryObject.join) {
|
if (queryObject.join) {
|
||||||
for (const join of queryObject.join) {
|
for (const join of queryObject.join) {
|
||||||
let subaffix = join.id.replaceAll("-", "") ?? StringHelper.random(10);
|
let subaffix = join.id?.replaceAll("-", "") ?? StringHelper.random(10);
|
||||||
if (join.type == undefined) join.type = "defined";
|
if (join.type == undefined) join.type = "defined";
|
||||||
if (join.type == "defined") {
|
if (join.type == "defined") {
|
||||||
query.innerJoin(`${alias}.${join.foreignColumn}`, `${subaffix}_${join.table}`);
|
query.innerJoin(`${alias}.${join.foreignColumn}`, `${subaffix}_${join.table}`);
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
import { MigrationInterface, QueryRunner, TableForeignKey } from "typeorm";
|
||||||
|
import { newsletter_table } from "./baseSchemaTables/newsletter";
|
||||||
|
|
||||||
|
export class UpdateNewsletterQueryRelation1752502069178 implements MigrationInterface {
|
||||||
|
name = "UpdateNewsletterQueryRelation1752502069178";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
const table = await queryRunner.getTable("newsletter");
|
||||||
|
const foreignKey = table?.foreignKeys.find((fk) => fk.columnNames.includes("recipientsByQueryId"));
|
||||||
|
if (foreignKey) {
|
||||||
|
await queryRunner.dropForeignKey("newsletter", foreignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
await queryRunner.createForeignKey(
|
||||||
|
newsletter_table,
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["recipientsByQueryId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "query",
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
const table = await queryRunner.getTable("newsletter");
|
||||||
|
const foreignKey = table?.foreignKeys.find((fk) => fk.columnNames.includes("recipientsByQueryId"));
|
||||||
|
if (foreignKey) {
|
||||||
|
await queryRunner.dropForeignKey("newsletter", foreignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
await queryRunner.createForeignKey(
|
||||||
|
newsletter_table,
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["recipientsByQueryId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "query",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue