Simple User Quota (#367)

* Simple User Quota
* 👷Fix build with OpenSearch
This commit is contained in:
Anton Shepilov
2024-02-22 10:17:25 +01:00
committed by GitHub
parent df0809ec48
commit 63f2c281c0
34 changed files with 10549 additions and 5836 deletions
@@ -124,8 +124,19 @@ export class PostgresConnector extends AbstractConnector<PostgresConnectionOptio
private async alterTablePrimaryKey(entity: EntityDefinition) {
if (entity.options.primaryKey) {
const query = `ALTER TABLE "${entity.name}" ADD PRIMARY KEY (
${entity.options.primaryKey.join(", ")});`;
const query = `
do $$
begin
IF NOT EXISTS
(SELECT constraint_name
FROM information_schema.table_constraints
WHERE table_name = '${entity.name}'
and constraint_type = 'PRIMARY KEY')
THEN
ALTER TABLE "${entity.name}" ADD PRIMARY KEY (
${entity.options.primaryKey.join(", ")});
END IF;
end $$;`;
try {
await this.client.query(query);
} catch (err) {