diff --git a/backend/services/core/migrations/20230822094308_add_custom_author_type_to_articles.ts b/backend/services/core/migrations/20230822094308_add_custom_author_type_to_articles.ts index 38787b7c..f2157acd 100644 --- a/backend/services/core/migrations/20230822094308_add_custom_author_type_to_articles.ts +++ b/backend/services/core/migrations/20230822094308_add_custom_author_type_to_articles.ts @@ -28,6 +28,10 @@ export async function up(knex: Knex): Promise { table.enu('type', ['Member', 'Mandate', 'Custom'], { useNative: true, enumName: 'author_type' }).notNullable().defaultTo('Member'); table.uuid('temp_article_id').unsigned().notNullable().references('articles.id') .comment('Temporary column during migration'); + + table.check(`type = 'Member' AND mandate_id IS NULL AND custom_id IS NULL + OR type = 'Mandate' AND mandate_id IS NOT NULL AND custom_id IS NULL + OR type = 'Custom' AND mandate_id IS NULL AND custom_id IS NOT NULL`, undefined, 'enforce_author_type'); }); // Get all articles posted by a member, not as a mandate const memberAuthorArticles = await knex('articles').select('id', 'author_id', 'author_type', 'published_datetime', 'latest_edit_datetime') diff --git a/backend/services/core/src/types/graphql.ts b/backend/services/core/src/types/graphql.ts index f6a11ad1..b20e2dc1 100644 --- a/backend/services/core/src/types/graphql.ts +++ b/backend/services/core/src/types/graphql.ts @@ -1895,7 +1895,7 @@ export type ReferenceResolver = ( type NullableCheck = Maybe extends T ? Maybe, S>> : ListCheck; type ListCheck = T extends (infer U)[] ? NullableCheck[] : GraphQLRecursivePick; export type GraphQLRecursivePick = { [K in keyof T & keyof S]: ScalarCheck }; - + export type ResolverWithResolve = { resolve: ResolverFn;