From 599d61016e5ceede0356ba2bc7259f9507fcffd9 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Mon, 3 Jul 2023 19:06:45 +0800 Subject: [PATCH] feat: add category field to Filter object --- packages/api/src/entity/filter.ts | 3 +++ packages/api/src/generated/graphql.ts | 3 +++ packages/api/src/generated/schema.graphql | 2 ++ packages/api/src/schema.ts | 2 ++ .../0114.do.add_category_field_to_filters_table.sql | 9 +++++++++ .../0114.undo.add_category_field_to_filters_table.sql | 9 +++++++++ 6 files changed, 28 insertions(+) create mode 100755 packages/db/migrations/0114.do.add_category_field_to_filters_table.sql create mode 100755 packages/db/migrations/0114.undo.add_category_field_to_filters_table.sql diff --git a/packages/api/src/entity/filter.ts b/packages/api/src/entity/filter.ts index 54583167a..93a48e219 100644 --- a/packages/api/src/entity/filter.ts +++ b/packages/api/src/entity/filter.ts @@ -29,6 +29,9 @@ export class Filter { @Column('varchar', { length: 255 }) filter!: string + @Column('varchar', { length: 255 }) + category!: string + @Column('integer', { default: 0 }) position!: number diff --git a/packages/api/src/generated/graphql.ts b/packages/api/src/generated/graphql.ts index ed7f408d0..82e0206d4 100644 --- a/packages/api/src/generated/graphql.ts +++ b/packages/api/src/generated/graphql.ts @@ -762,6 +762,7 @@ export type FeedArticlesSuccess = { export type Filter = { __typename?: 'Filter'; + category: Scalars['String']; createdAt: Scalars['Date']; description?: Maybe; filter: Scalars['String']; @@ -2229,6 +2230,7 @@ export enum SaveFilterErrorCode { } export type SaveFilterInput = { + category: Scalars['String']; description?: InputMaybe; filter: Scalars['String']; id?: InputMaybe; @@ -4707,6 +4709,7 @@ export type FeedArticlesSuccessResolvers = { + category?: Resolver; createdAt?: Resolver; description?: Resolver, ParentType, ContextType>; filter?: Resolver; diff --git a/packages/api/src/generated/schema.graphql b/packages/api/src/generated/schema.graphql index c945a3e6e..010eca42a 100644 --- a/packages/api/src/generated/schema.graphql +++ b/packages/api/src/generated/schema.graphql @@ -674,6 +674,7 @@ type FeedArticlesSuccess { } type Filter { + category: String! createdAt: Date! description: String filter: String! @@ -1617,6 +1618,7 @@ enum SaveFilterErrorCode { } input SaveFilterInput { + category: String! description: String filter: String! id: ID diff --git a/packages/api/src/schema.ts b/packages/api/src/schema.ts index d943bf969..4800d8da4 100755 --- a/packages/api/src/schema.ts +++ b/packages/api/src/schema.ts @@ -2139,6 +2139,7 @@ const schema = gql` id: ID name: String! filter: String! + category: String! description: String } @@ -2153,6 +2154,7 @@ const schema = gql` name: String! filter: String! position: Int! + category: String! description: String createdAt: Date! updatedAt: Date! diff --git a/packages/db/migrations/0114.do.add_category_field_to_filters_table.sql b/packages/db/migrations/0114.do.add_category_field_to_filters_table.sql new file mode 100755 index 000000000..1e827682e --- /dev/null +++ b/packages/db/migrations/0114.do.add_category_field_to_filters_table.sql @@ -0,0 +1,9 @@ +-- Type: DO +-- Name: add_category_field_to_filters_table +-- Description: Add category field to filters table + +BEGIN; + +ALTER TABLE omnivore.filters ADD COLUMN category VARCHAR(255) NOT NULL; + +COMMIT; diff --git a/packages/db/migrations/0114.undo.add_category_field_to_filters_table.sql b/packages/db/migrations/0114.undo.add_category_field_to_filters_table.sql new file mode 100755 index 000000000..e4aa4c357 --- /dev/null +++ b/packages/db/migrations/0114.undo.add_category_field_to_filters_table.sql @@ -0,0 +1,9 @@ +-- Type: UNDO +-- Name: add_category_field_to_filters_table +-- Description: Add category field to filters table + +BEGIN; + +ALTER TABLE omnivore.filters DROP COLUMN IF EXISTS category; + +COMMIT;