From 0d926b8ad12ba4e91fca44c358376b6f614783c2 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 29 Feb 2024 12:08:51 +0800 Subject: [PATCH] Add features table to admin --- pkg/admin/src/db.ts | 25 +++++++++++++++++++++++++ pkg/admin/src/index.ts | 2 ++ 2 files changed, 27 insertions(+) diff --git a/pkg/admin/src/db.ts b/pkg/admin/src/db.ts index aa0133bca..25f7a2de1 100644 --- a/pkg/admin/src/db.ts +++ b/pkg/admin/src/db.ts @@ -439,3 +439,28 @@ export class GroupMembership extends BaseEntity { @Column('boolean', { default: false }) is_admin!: boolean } + +@Entity({ name: 'features' }) +export class Feature extends BaseEntity { + @PrimaryGeneratedColumn('uuid') + id!: string + + @JoinColumn({ name: 'user_id' }) + @ManyToOne(() => User, (user) => user.articles, { eager: true }) + user!: User + + @Column('text') + name!: string + + @Column('timestamp', { nullable: true }) + grantedAt?: Date | null + + @Column('timestamp', { nullable: true }) + expiresAt?: Date | null + + @Column({ type: 'timestamp', name: 'created_at' }) + createdAt!: Date + + @Column({ type: 'timestamp', name: 'updated_at' }) + updatedAt!: Date +} diff --git a/pkg/admin/src/index.ts b/pkg/admin/src/index.ts index 20875919c..73740109c 100644 --- a/pkg/admin/src/index.ts +++ b/pkg/admin/src/index.ts @@ -15,6 +15,7 @@ import { LibraryItem, Recommendation, GroupMembership, + Feature, } from './db' import { compare, hashSync } from 'bcryptjs' const readYamlFile = require('read-yaml-file') @@ -50,6 +51,7 @@ const ADMIN_USER_EMAIL = }, { resource: Recommendation, options: { parent: { name: 'Users' } } }, { resource: GroupMembership, options: { parent: { name: 'Users' } } }, + { resource: Feature, options: { parent: { name: 'Users' } } }, ], })