add rss subscription entity class

This commit is contained in:
Hongbo Wu 2023-07-05 16:55:08 +08:00
parent 9f7796e2f0
commit a6192ed86b
2 changed files with 45 additions and 1 deletions

View file

@ -0,0 +1,44 @@
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
}

View file

@ -12,7 +12,7 @@ CREATE TABLE omnivore.rss_subscription (
url TEXT NOT NULL,
image_url TEXT,
count integer NOT NULL DEFAULT 0,
last_updated timestamptz,
last_fetched_at timestamptz,
created_at timestamptz NOT NULL DEFAULT current_timestamp,
updated_at timestamptz NOT NULL DEFAULT current_timestamp
);