-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from Vaibhav-Ganatra/master
Entities, Migrations, Interfaces and Custom Repositories for all tables except permissions and roles
- Loading branch information
Showing
17 changed files
with
589 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
Timestamp, | ||
ManyToOne, | ||
JoinColumn, | ||
ManyToMany, | ||
JoinTable | ||
} from 'typeorm'; | ||
|
||
import { Taskboard } from './Taskboard'; | ||
import { Users } from './User'; | ||
|
||
export enum CardStatus { | ||
ONGOING = 'ongoing', | ||
TODO = 'todo', | ||
COMPLETED = 'completed' | ||
} | ||
|
||
@Entity({name: 'cards'}) | ||
export class Card { | ||
@PrimaryGeneratedColumn() | ||
id: number | undefined; | ||
|
||
@Column('text') | ||
title: string | undefined; | ||
|
||
@Column('text') | ||
description: string | undefined; | ||
|
||
@CreateDateColumn() | ||
created_at: Timestamp | undefined; | ||
|
||
@UpdateDateColumn() | ||
updated_at: Timestamp | undefined; | ||
|
||
@ManyToOne((type) => Taskboard, board => board.cards) | ||
board: Taskboard | undefined; | ||
|
||
@ManyToOne((type) => Users) | ||
@JoinColumn() | ||
created_by: Users | undefined; | ||
|
||
@Column('text', { array: true, nullable: true }) | ||
labels: string[] | undefined; | ||
|
||
@Column({ | ||
type: 'enum', | ||
enum: CardStatus, | ||
default: CardStatus.TODO | ||
}) | ||
card_status: CardStatus | undefined; | ||
|
||
@ManyToMany(type => Users, user => user.cards) | ||
@JoinTable() | ||
members: Users[] | undefined; | ||
|
||
@Column({ | ||
type: 'timestamp', | ||
nullable: true | ||
}) | ||
completed_at: Timestamp | undefined; | ||
|
||
@Column('timestamp') | ||
deadline: Timestamp | undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Entity, PrimaryColumn, Column } from 'typeorm'; | ||
|
||
@Entity({ name: 'github'}) | ||
export class Github { | ||
|
||
@PrimaryColumn('text') | ||
username: string | undefined; | ||
|
||
@Column('text') | ||
login: string | undefined; | ||
|
||
@Column('text') | ||
avatar_url: string | undefined; | ||
|
||
@Column('text') | ||
html_url: string | undefined; | ||
|
||
@Column('text') | ||
repos_url: string | undefined; | ||
|
||
@Column('text') | ||
name: string | undefined; | ||
|
||
@Column('text') | ||
company: string | undefined; | ||
|
||
@Column('text') | ||
blog: string | undefined; | ||
|
||
@Column('text') | ||
location: string | undefined; | ||
|
||
@Column('text') | ||
email: string | undefined; | ||
|
||
@Column('text') | ||
bio: string | undefined; | ||
|
||
@Column('text') | ||
twitter_username: string | undefined; | ||
|
||
@Column('int') | ||
public_repos: number | undefined; | ||
|
||
@Column('int') | ||
public_gists: number | undefined; | ||
|
||
@Column('int') | ||
followers: number | undefined; | ||
|
||
@Column('int') | ||
following: number | undefined; | ||
|
||
@Column('int') | ||
private_gists: number | undefined; | ||
|
||
@Column('int') | ||
total_private_repos: number | undefined; | ||
|
||
@Column('int') | ||
owned_private_repos: number | undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
Column, | ||
JoinColumn, | ||
ManyToOne, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
Timestamp, | ||
OneToMany, | ||
ManyToMany, | ||
JoinTable | ||
} from 'typeorm'; | ||
import { Users } from './User'; | ||
import { Taskboard } from './Taskboard'; | ||
|
||
@Entity({name: 'projects'}) | ||
export class Project { | ||
@PrimaryGeneratedColumn() | ||
id: number | undefined; | ||
|
||
@Column({ | ||
type: 'varchar', | ||
unique: true | ||
}) | ||
name: string | undefined; | ||
|
||
@Column('text') | ||
description: string | undefined; | ||
|
||
@Column('int') | ||
chat_channel_id: number | undefined; | ||
|
||
@Column({ | ||
type: 'int', | ||
unique: true | ||
}) | ||
created_by_id: number | undefined; | ||
|
||
@ManyToOne((type) => Users) | ||
@JoinColumn() | ||
created_by: Users | undefined; | ||
|
||
@OneToMany((type) => Taskboard, taskboard => taskboard.project) | ||
boards: Taskboard[] | undefined; | ||
|
||
@CreateDateColumn() | ||
created_time: Timestamp | undefined; | ||
|
||
@UpdateDateColumn() | ||
updated_time: Timestamp | undefined; | ||
|
||
@ManyToMany((type) => Users, user => user.projects) | ||
@JoinTable() | ||
members: Users[] | undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
Column, | ||
UpdateDateColumn, | ||
CreateDateColumn, | ||
Timestamp, | ||
ManyToOne, | ||
JoinColumn, | ||
ManyToMany, | ||
JoinTable, | ||
OneToMany | ||
} from 'typeorm'; | ||
|
||
import { Project } from './Project'; | ||
import { Users } from './User'; | ||
import { Card } from './Card'; | ||
|
||
@Entity({ name: 'taskboards'}) | ||
export class Taskboard { | ||
@PrimaryGeneratedColumn() | ||
id: number | undefined; | ||
|
||
@Column('varchar') | ||
name: string | undefined; | ||
|
||
@Column('text') | ||
description: string | undefined; | ||
|
||
@Column('text') | ||
github_repo_url: string | undefined; | ||
|
||
@CreateDateColumn() | ||
created_at: Timestamp | undefined; | ||
|
||
@UpdateDateColumn() | ||
updated_at: Timestamp | undefined; | ||
|
||
@Column('int') | ||
chat_channel_id: number | undefined; | ||
|
||
@ManyToOne((type) => Project, project => project.boards) | ||
project: Project | undefined; | ||
|
||
@ManyToOne((type) => Users) | ||
@JoinColumn() | ||
created_by: Users | undefined; | ||
|
||
@ManyToMany(type => Users, user => user.boards) | ||
@JoinTable() | ||
members: Users[] | undefined; | ||
|
||
@OneToMany(type => Card, card => card.board) | ||
cards: Card[] | undefined; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,76 @@ | ||
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; | ||
import { | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
Column, | ||
JoinColumn, | ||
JoinTable, | ||
OneToOne, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
Timestamp, | ||
ManyToMany | ||
} from 'typeorm'; | ||
import { Github } from './Github'; | ||
import { Project } from './Project'; | ||
import { Taskboard } from './Taskboard'; | ||
import { Card } from './Card'; | ||
|
||
export enum UserRole { | ||
COORDI = 'coordi', | ||
CORE = 'core', | ||
CREW = 'crew' | ||
} | ||
|
||
@Entity() | ||
@Entity({name: 'users'}) | ||
export class Users { | ||
@PrimaryGeneratedColumn() | ||
id: number | undefined; | ||
|
||
@PrimaryGeneratedColumn() | ||
id: number | undefined; | ||
|
||
@Column('text') | ||
login: string | undefined; | ||
|
||
@Column('text') | ||
avatar_url: string | undefined; | ||
|
||
@Column('text') | ||
html_url: string | undefined; | ||
|
||
@Column('text') | ||
repos_url: string | undefined; | ||
|
||
@Column('text') | ||
name: string | undefined; | ||
|
||
@Column('text') | ||
company: string | undefined; | ||
|
||
@Column('text') | ||
blog: string | undefined; | ||
@Column('varchar') | ||
name: string | undefined; | ||
|
||
@Column('text') | ||
location: string | undefined; | ||
@Column({ type: 'varchar', unique: true }) | ||
email: string | undefined; | ||
|
||
@Column('text') | ||
email: string | undefined; | ||
@Column({ type: 'text', nullable: true }) | ||
avatar_url: string | undefined; | ||
|
||
@Column('text') | ||
bio: string | undefined; | ||
@Column({ | ||
type: 'enum', | ||
enum: UserRole, | ||
default: UserRole.CREW | ||
}) | ||
org_role: UserRole | undefined; | ||
|
||
@Column('text') | ||
twitter_username: string | undefined; | ||
@Column({ | ||
type: 'text', | ||
unique: true | ||
}) | ||
github_username: string | undefined; | ||
|
||
@Column('int') | ||
public_repos: number | undefined; | ||
@OneToOne((type) => Github) | ||
@JoinColumn() | ||
github: Github | undefined; | ||
|
||
@Column('int') | ||
public_gists: number | undefined; | ||
@CreateDateColumn() | ||
created_at: Timestamp | undefined; | ||
|
||
@Column('int') | ||
followers: number | undefined; | ||
@UpdateDateColumn() | ||
updated_at: Timestamp | undefined; | ||
|
||
@Column('int') | ||
following: number | undefined; | ||
@ManyToMany((type) => Project, project => project.members, { | ||
cascade: true | ||
}) | ||
projects: Project[] | undefined; | ||
|
||
@Column('int') | ||
private_gists: number | undefined; | ||
@ManyToMany(type => Taskboard, board => board.members, { | ||
cascade: true | ||
}) | ||
boards: Taskboard[] | undefined; | ||
|
||
@Column('int') | ||
total_private_repos: number | undefined; | ||
@ManyToMany(type => Card, card => card.members, { | ||
cascade: true | ||
}) | ||
cards: Card[] | undefined; | ||
|
||
@Column('int') | ||
owned_private_repos: number | undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class GithubMigration implements MigrationInterface { | ||
name?: string; | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TABLE "cards" IF NOT EXISTS`); | ||
} | ||
async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE "cards"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class GithubMigration implements MigrationInterface { | ||
name?: string; | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TABLE "github" IF NOT EXISTS`); | ||
} | ||
async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE "github"`); | ||
} | ||
} |
Oops, something went wrong.