mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
update graphql schema
This commit is contained in:
parent
a6192ed86b
commit
2adf753f8f
9 changed files with 77 additions and 83 deletions
|
|
@ -1,44 +0,0 @@
|
|||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
import { User } from './user'
|
||||
|
||||
@Entity({ name: 'rss_subscription' })
|
||||
export class RssSubscription {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string
|
||||
|
||||
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'user_id' })
|
||||
user!: User
|
||||
|
||||
@Column('varchar', { length: 255 })
|
||||
title!: string
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
description?: string | null
|
||||
|
||||
@Column('text')
|
||||
url!: string
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
imageUrl?: string | null
|
||||
|
||||
@Column('integer', { default: 0 })
|
||||
count!: number
|
||||
|
||||
@Column('timestamp', { nullable: true })
|
||||
lastFetchedAt?: Date | null
|
||||
|
||||
@CreateDateColumn({ default: () => 'CURRENT_TIMESTAMP' })
|
||||
createdAt!: Date
|
||||
|
||||
@UpdateDateColumn({ default: () => 'CURRENT_TIMESTAMP' })
|
||||
updatedAt!: Date
|
||||
}
|
||||
|
|
@ -5,15 +5,13 @@ import {
|
|||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
import { User } from './user'
|
||||
import { SubscriptionStatus } from '../generated/graphql'
|
||||
import { SubscriptionStatus, SubscriptionType } from '../generated/graphql'
|
||||
import { NewsletterEmail } from './newsletter_email'
|
||||
import { User } from './user'
|
||||
|
||||
@Entity({ name: 'subscriptions' })
|
||||
@Unique(['name', 'user'])
|
||||
export class Subscription {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string
|
||||
|
|
@ -50,9 +48,20 @@ export class Subscription {
|
|||
@Column('text', { nullable: true })
|
||||
icon?: string
|
||||
|
||||
@CreateDateColumn()
|
||||
@Column('enum', {
|
||||
enum: SubscriptionType,
|
||||
})
|
||||
type!: SubscriptionType
|
||||
|
||||
@Column('integer', { default: 0 })
|
||||
count!: number
|
||||
|
||||
@Column('timestamp', { nullable: true })
|
||||
lastFetchedAt?: Date | null
|
||||
|
||||
@CreateDateColumn({ default: () => 'CURRENT_TIMESTAMP' })
|
||||
createdAt!: Date
|
||||
|
||||
@UpdateDateColumn()
|
||||
@UpdateDateColumn({ default: () => 'CURRENT_TIMESTAMP' })
|
||||
updatedAt!: Date
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2706,13 +2706,16 @@ export type SubscribeSuccess = {
|
|||
|
||||
export type Subscription = {
|
||||
__typename?: 'Subscription';
|
||||
count: Scalars['Int'];
|
||||
createdAt: Scalars['Date'];
|
||||
description?: Maybe<Scalars['String']>;
|
||||
icon?: Maybe<Scalars['String']>;
|
||||
id: Scalars['ID'];
|
||||
lastFetchedAt?: Maybe<Scalars['Date']>;
|
||||
name: Scalars['String'];
|
||||
newsletterEmail: Scalars['String'];
|
||||
newsletterEmail?: Maybe<Scalars['String']>;
|
||||
status: SubscriptionStatus;
|
||||
type: SubscriptionType;
|
||||
unsubscribeHttpUrl?: Maybe<Scalars['String']>;
|
||||
unsubscribeMailTo?: Maybe<Scalars['String']>;
|
||||
updatedAt: Scalars['Date'];
|
||||
|
|
@ -2725,6 +2728,11 @@ export enum SubscriptionStatus {
|
|||
Unsubscribed = 'UNSUBSCRIBED'
|
||||
}
|
||||
|
||||
export enum SubscriptionType {
|
||||
Newsletter = 'NEWSLETTER',
|
||||
Rss = 'RSS'
|
||||
}
|
||||
|
||||
export type SubscriptionsError = {
|
||||
__typename?: 'SubscriptionsError';
|
||||
errorCodes: Array<SubscriptionsErrorCode>;
|
||||
|
|
@ -3691,6 +3699,7 @@ export type ResolversTypes = {
|
|||
SubscribeSuccess: ResolverTypeWrapper<SubscribeSuccess>;
|
||||
Subscription: ResolverTypeWrapper<{}>;
|
||||
SubscriptionStatus: SubscriptionStatus;
|
||||
SubscriptionType: SubscriptionType;
|
||||
SubscriptionsError: ResolverTypeWrapper<SubscriptionsError>;
|
||||
SubscriptionsErrorCode: SubscriptionsErrorCode;
|
||||
SubscriptionsResult: ResolversTypes['SubscriptionsError'] | ResolversTypes['SubscriptionsSuccess'];
|
||||
|
|
@ -5745,13 +5754,16 @@ export type SubscribeSuccessResolvers<ContextType = ResolverContext, ParentType
|
|||
};
|
||||
|
||||
export type SubscriptionResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['Subscription'] = ResolversParentTypes['Subscription']> = {
|
||||
count?: SubscriptionResolver<ResolversTypes['Int'], "count", ParentType, ContextType>;
|
||||
createdAt?: SubscriptionResolver<ResolversTypes['Date'], "createdAt", ParentType, ContextType>;
|
||||
description?: SubscriptionResolver<Maybe<ResolversTypes['String']>, "description", ParentType, ContextType>;
|
||||
icon?: SubscriptionResolver<Maybe<ResolversTypes['String']>, "icon", ParentType, ContextType>;
|
||||
id?: SubscriptionResolver<ResolversTypes['ID'], "id", ParentType, ContextType>;
|
||||
lastFetchedAt?: SubscriptionResolver<Maybe<ResolversTypes['Date']>, "lastFetchedAt", ParentType, ContextType>;
|
||||
name?: SubscriptionResolver<ResolversTypes['String'], "name", ParentType, ContextType>;
|
||||
newsletterEmail?: SubscriptionResolver<ResolversTypes['String'], "newsletterEmail", ParentType, ContextType>;
|
||||
newsletterEmail?: SubscriptionResolver<Maybe<ResolversTypes['String']>, "newsletterEmail", ParentType, ContextType>;
|
||||
status?: SubscriptionResolver<ResolversTypes['SubscriptionStatus'], "status", ParentType, ContextType>;
|
||||
type?: SubscriptionResolver<ResolversTypes['SubscriptionType'], "type", ParentType, ContextType>;
|
||||
unsubscribeHttpUrl?: SubscriptionResolver<Maybe<ResolversTypes['String']>, "unsubscribeHttpUrl", ParentType, ContextType>;
|
||||
unsubscribeMailTo?: SubscriptionResolver<Maybe<ResolversTypes['String']>, "unsubscribeMailTo", ParentType, ContextType>;
|
||||
updatedAt?: SubscriptionResolver<ResolversTypes['Date'], "updatedAt", ParentType, ContextType>;
|
||||
|
|
|
|||
|
|
@ -2058,13 +2058,16 @@ type SubscribeSuccess {
|
|||
}
|
||||
|
||||
type Subscription {
|
||||
count: Int!
|
||||
createdAt: Date!
|
||||
description: String
|
||||
icon: String
|
||||
id: ID!
|
||||
lastFetchedAt: Date
|
||||
name: String!
|
||||
newsletterEmail: String!
|
||||
newsletterEmail: String
|
||||
status: SubscriptionStatus!
|
||||
type: SubscriptionType!
|
||||
unsubscribeHttpUrl: String
|
||||
unsubscribeMailTo: String
|
||||
updatedAt: Date!
|
||||
|
|
@ -2077,6 +2080,11 @@ enum SubscriptionStatus {
|
|||
UNSUBSCRIBED
|
||||
}
|
||||
|
||||
enum SubscriptionType {
|
||||
NEWSLETTER
|
||||
RSS
|
||||
}
|
||||
|
||||
type SubscriptionsError {
|
||||
errorCodes: [SubscriptionsErrorCode!]!
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1619,16 +1619,24 @@ const schema = gql`
|
|||
subscriptions: [Subscription!]!
|
||||
}
|
||||
|
||||
enum SubscriptionType {
|
||||
RSS
|
||||
NEWSLETTER
|
||||
}
|
||||
|
||||
type Subscription {
|
||||
id: ID!
|
||||
name: String!
|
||||
newsletterEmail: String!
|
||||
newsletterEmail: String
|
||||
url: String
|
||||
description: String
|
||||
status: SubscriptionStatus!
|
||||
unsubscribeMailTo: String
|
||||
unsubscribeHttpUrl: String
|
||||
icon: String
|
||||
type: SubscriptionType!
|
||||
count: Int!
|
||||
lastFetchedAt: Date
|
||||
createdAt: Date!
|
||||
updatedAt: Date!
|
||||
}
|
||||
|
|
|
|||
15
packages/db/migrations/0114.do.add_type_to_subscriptions.sql
Executable file
15
packages/db/migrations/0114.do.add_type_to_subscriptions.sql
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
-- Type: DO
|
||||
-- Name: add_type_to_subscriptions
|
||||
-- Description: Add type, count and last_fetched_at fields to subscriptions table
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TYPE subscription_type AS ENUM ('NEWSLETTER', 'RSS');
|
||||
|
||||
ALTER TABLE omnivore.subscriptions
|
||||
ADD COLUMN "type" subscription_type NOT NULL DEFAULT 'NEWSLETTER',
|
||||
ADD COLUMN count INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN last_fetched_at timestamptz,
|
||||
DROP CONSTRAINT subscriptions_user_id_name_key; -- Drop unique constraint on user_id and name
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
-- Type: DO
|
||||
-- Name: rss_subscription
|
||||
-- Description: Create a table for RSS subscriptions
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE omnivore.rss_subscription (
|
||||
id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
|
||||
user_id uuid NOT NULL REFERENCES omnivore.user ON DELETE CASCADE,
|
||||
title character varying(255) NOT NULL,
|
||||
description TEXT,
|
||||
url TEXT NOT NULL,
|
||||
image_url TEXT,
|
||||
count integer NOT NULL DEFAULT 0,
|
||||
last_fetched_at timestamptz,
|
||||
created_at timestamptz NOT NULL DEFAULT current_timestamp,
|
||||
updated_at timestamptz NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
15
packages/db/migrations/0114.undo.add_type_to_subscriptions.sql
Executable file
15
packages/db/migrations/0114.undo.add_type_to_subscriptions.sql
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
-- Type: UNDO
|
||||
-- Name: add_type_to_subscriptions
|
||||
-- Description: Add type, count and last_fetched_at fields to subscriptions table
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE omnivore.subscriptions
|
||||
ADD CONSTRAINT subscriptions_user_id_name_key UNIQUE (user_id, name),
|
||||
DROP COLUMN last_fetched_at,
|
||||
DROP COLUMN count,
|
||||
DROP COLUMN "type";
|
||||
|
||||
DROP TYPE omnivore.subscription_type;
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
-- Type: UNDO
|
||||
-- Name: rss_subscription
|
||||
-- Description: Create a table for RSS subscriptions
|
||||
|
||||
BEGIN;
|
||||
|
||||
DROP TABLE IF EXISTS omnivore.rss_subscription;
|
||||
|
||||
COMMIT;
|
||||
Loading…
Reference in a new issue