-
Notifications
You must be signed in to change notification settings - Fork 103
feat: поле tag хоста из строки в массив tags #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
47f8edb
cc3344e
09fda0b
c7e83d3
567690b
8032a39
5daad91
f250a23
8acbc0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Security Policy | ||
|
|
||
| ## Reporting a Vulnerability | ||
|
|
||
| Use this section to tell people how to report a vulnerability. | ||
|
|
||
| Tell them where to go, how often they can expect to get an update on a | ||
| reported vulnerability, what to expect if the vulnerability is accepted or | ||
| declined, etc. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| -- AlterTable: migrate host tag (single string) to tags (array of strings) | ||
|
|
||
| -- Step 1: Add new tags column with default empty array | ||
| ALTER TABLE "hosts" ADD COLUMN "tags" TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[]; | ||
|
|
||
| -- Step 2: Migrate existing tag data to tags array | ||
| UPDATE "hosts" SET "tags" = ARRAY["tag"] WHERE "tag" IS NOT NULL; | ||
|
|
||
| -- Step 3: Drop old tag column | ||
| ALTER TABLE "hosts" DROP COLUMN "tag"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { Prisma } from '@prisma/client'; | ||
| import { sql } from 'kysely'; | ||
|
|
||
| import { IReorderHost } from 'src/modules/hosts/interfaces/reorder-host.interface'; | ||
|
|
||
|
|
@@ -93,6 +94,7 @@ export class HostsRepository implements ICrud<HostsEntity> { | |
| | 'excludedInternalSquads' | ||
| | 'excludeFromSubscriptionTypes' | ||
| | 'finalMask' | ||
| | 'tags' | ||
| >, | ||
| ): Promise<HostsEntity[]> { | ||
| const list = await this.prisma.tx.hosts.findMany({ | ||
|
|
@@ -245,14 +247,15 @@ export class HostsRepository implements ICrud<HostsEntity> { | |
| } | ||
|
|
||
| public async getAllHostTags(): Promise<string[]> { | ||
| const result = await this.prisma.tx.hosts.findMany({ | ||
| select: { | ||
| tag: true, | ||
| }, | ||
| distinct: ['tag'], | ||
| }); | ||
| const result = await this.qb.kysely | ||
| .selectFrom('hosts') | ||
| .select(sql<string>`unnest(tags)`.as('tag')) | ||
| .distinct() | ||
| .where('tags', 'is not', null) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Or simply omit the |
||
| .orderBy('tag') | ||
| .execute(); | ||
|
|
||
| return result.map((host) => host.tag).filter((tag) => tag !== null); | ||
| return result.map((value) => value.tag); | ||
| } | ||
|
|
||
| public async addNodesToHost(hostUuid: string, nodes: string[]): Promise<boolean> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains GitHub's default template text (
"Tell them where to go, how often they can expect to get an update...") and is unrelated to the host-tags migration. It should either be filled in with a real vulnerability-disclosure policy or removed from this PR and tracked separately.