Skip to content

simplify users entity #2

Description

@dqian

import { BaseEntity, Column, Entity, PrimaryGeneratedColumn, Timestamp } from 'typeorm'

This file can be simplified and we can do away with the custom users table + uuid migrations and rely on the generated one (typeorm -- migration:generate -n ...) by using the following entity schema:

import { BaseEntity, Column, Entity, PrimaryGeneratedColumn, Timestamp, getConnection, Unique, CreateDateColumn, UpdateDateColumn, DeleteDateColumn } from 'typeorm'
import config from '~/config'

@Entity(`${config.DB.MAIN_SCHEMA}.users`)
export class User extends BaseEntity {
  @PrimaryGeneratedColumn("uuid")
  public id: string

  @Column({ type: "varchar", length: 255, unique: true })
  public email: string

  @CreateDateColumn()
  public created_at: Timestamp

  @UpdateDateColumn()
  public updated_at: Timestamp

  @DeleteDateColumn()
  public deleted_at: Timestamp
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions