-
Notifications
You must be signed in to change notification settings - Fork 4
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 #3 from thanhbao922003/migration
Project: Migration
- Loading branch information
Showing
17 changed files
with
497 additions
and
7 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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
node_modules/ | ||
dist/ | ||
**/**/*.log | ||
env/*.env | ||
src/migration/*.ts | ||
|
||
# Logs | ||
logs | ||
|
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 |
---|---|---|
|
@@ -3,4 +3,4 @@ DB_HOST='' | |
DB_PORT='' | ||
DB_USERNAME='' | ||
DB_PASSWORD='' | ||
DB_DATABASE='' | ||
DB_DATABASE='' |
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
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
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,38 @@ | ||
import { Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
ManyToOne, | ||
JoinColumn, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
} from 'typeorm'; | ||
import { Review } from './Review'; | ||
|
||
@Entity('comments') | ||
export class Comment { | ||
@PrimaryGeneratedColumn('increment', { type: 'bigint' }) | ||
id!: number; | ||
|
||
@ManyToOne(() => Review) | ||
@JoinColumn({ name: 'review_id' }) | ||
review!: Review; | ||
|
||
@Column({ type: 'bigint' }) | ||
parent_id!: number; | ||
|
||
@Column('text') | ||
comment_text!: string; | ||
|
||
@Column({ type: 'bigint' }) | ||
review_id!: number; | ||
|
||
@CreateDateColumn({ type: 'datetime' }) | ||
created_at!: Date; | ||
|
||
@UpdateDateColumn({ type: 'datetime' }) | ||
updated_at!: Date; | ||
|
||
constructor(commentData?: Partial<Comment>) { | ||
commentData && Object.assign(this, commentData); | ||
} | ||
} |
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,38 @@ | ||
import { Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
ManyToOne, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
JoinColumn | ||
} from 'typeorm'; | ||
import { Lesson } from './Lesson'; | ||
|
||
@Entity('components') | ||
export class Component { | ||
@PrimaryGeneratedColumn('increment', { type: 'bigint' }) | ||
id!: number; | ||
|
||
@ManyToOne(() => Lesson) | ||
@JoinColumn({ name: 'lesson_id' }) | ||
lesson!: Lesson; | ||
|
||
@Column({ | ||
type: 'enum', | ||
enum: ['video', 'url', 'pdf', 'text'], | ||
}) | ||
type!: string; | ||
|
||
@Column('text') | ||
content!: string; | ||
|
||
@CreateDateColumn({ type: 'datetime' }) | ||
created_at!: Date; | ||
|
||
@UpdateDateColumn({ type: 'datetime' }) | ||
updated_at!: Date; | ||
|
||
constructor(componentData?: Partial<Component>) { | ||
componentData && Object.assign(this, componentData); | ||
} | ||
} |
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,44 @@ | ||
import { Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
ManyToOne, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
JoinColumn | ||
} from 'typeorm'; | ||
import { User } from './User'; | ||
|
||
@Entity('courses') | ||
export class Course { | ||
@PrimaryGeneratedColumn('increment', { type: 'bigint' }) | ||
id!: number; | ||
|
||
@ManyToOne(() => User) | ||
@JoinColumn({ name: 'professor_id' }) | ||
professor!: User; | ||
|
||
@Column() | ||
name!: string; | ||
|
||
@Column('double') | ||
price!: number; | ||
|
||
@Column('text') | ||
description!: string; | ||
|
||
@Column('float') | ||
average_rating!: number; | ||
|
||
@Column({ type: 'bigint' }) | ||
professor_id!: number; | ||
|
||
@CreateDateColumn({ type: 'datetime' }) | ||
created_at!: Date; | ||
|
||
@UpdateDateColumn({ type: 'datetime' }) | ||
updated_at!: Date; | ||
|
||
constructor(courseData?: Partial<Course>) { | ||
courseData && Object.assign(this, courseData); | ||
} | ||
} |
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,49 @@ | ||
import { Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
ManyToOne, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
JoinColumn | ||
} from 'typeorm'; | ||
import { User } from './User'; | ||
import { Course } from './Course'; | ||
|
||
@Entity('enrollments') | ||
export class Enrollment { | ||
@PrimaryGeneratedColumn('increment', { type: 'bigint' }) | ||
id!: number; | ||
|
||
@ManyToOne(() => User) | ||
@JoinColumn({ name: 'user_id' }) | ||
user!: User; | ||
|
||
@ManyToOne(() => Course) | ||
@JoinColumn({ name: 'course_id' }) | ||
course!: Course; | ||
|
||
@Column({ type: 'datetime' }) | ||
enrollment_date!: Date; | ||
|
||
@Column('integer') | ||
progress!: number; | ||
|
||
@Column({ type: 'datetime' }) | ||
completion_date!: Date; | ||
|
||
@Column({ type: 'bigint' }) | ||
user_id!: number; | ||
|
||
@Column({ type: 'bigint' }) | ||
course_id!: number; | ||
|
||
@CreateDateColumn({ type: 'datetime' }) | ||
created_at!: Date; | ||
|
||
@UpdateDateColumn({ type: 'datetime' }) | ||
updated_at!: Date; | ||
|
||
constructor(enrollmentData?: Partial<Enrollment>) { | ||
enrollmentData && Object.assign(this, enrollmentData); | ||
} | ||
} |
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,46 @@ | ||
import { Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
ManyToOne, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
JoinColumn | ||
} from 'typeorm'; | ||
import { Enrollment } from './Enrollment'; | ||
import { Lesson } from './Lesson'; | ||
|
||
@Entity('enrollments_lessons') | ||
export class EnrollmentLesson { | ||
@PrimaryGeneratedColumn('increment', { type: 'bigint' }) | ||
id!: number; | ||
|
||
@ManyToOne(() => Enrollment) | ||
@JoinColumn({ name: 'enrollment_id' }) | ||
enrollment!: Enrollment; | ||
|
||
@ManyToOne(() => Lesson) | ||
@JoinColumn({ name: 'lesson_id' }) | ||
lesson!: Lesson; | ||
|
||
@Column('integer') | ||
progress!: number; | ||
|
||
@Column({ type: 'datetime' }) | ||
completion_date!: Date; | ||
|
||
@Column({ type: 'bigint' }) | ||
enrollment_id!: number; | ||
|
||
@Column({ type: 'bigint' }) | ||
lesson_id!: number; | ||
|
||
@CreateDateColumn({ type: 'datetime' }) | ||
created_at!: Date; | ||
|
||
@UpdateDateColumn({ type: 'datetime' }) | ||
updated_at!: Date; | ||
|
||
constructor(enrollmentLessonData?: Partial<EnrollmentLesson>) { | ||
enrollmentLessonData && Object.assign(this, enrollmentLessonData); | ||
} | ||
} |
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,41 @@ | ||
import { Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
ManyToOne, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
JoinColumn | ||
} from 'typeorm'; | ||
import { Section } from './Section'; | ||
|
||
@Entity('lessons') | ||
export class Lesson { | ||
@PrimaryGeneratedColumn('increment', { type: 'bigint' }) | ||
id!: number; | ||
|
||
@ManyToOne(() => Section) | ||
@JoinColumn({ name: 'section_id' }) | ||
section!: Section; | ||
|
||
@Column() | ||
name!: string; | ||
|
||
@Column('text') | ||
description!: string; | ||
|
||
@Column('integer') | ||
time!: number; | ||
|
||
@Column({ type: 'bigint' }) | ||
section_id!: number; | ||
|
||
@CreateDateColumn({ type: 'datetime' }) | ||
created_at!: Date; | ||
|
||
@UpdateDateColumn({ type: 'datetime' }) | ||
updated_at!: Date; | ||
|
||
constructor(lessonData?: Partial<Lesson>) { | ||
lessonData && Object.assign(this, lessonData); | ||
} | ||
} |
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,52 @@ | ||
import { Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
ManyToOne, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
JoinColumn | ||
} from 'typeorm'; | ||
import { User } from './User'; | ||
import { Course } from './Course'; | ||
|
||
@Entity('payments') | ||
export class Payment { | ||
@PrimaryGeneratedColumn('increment', { type: 'bigint' }) | ||
id!: number; | ||
|
||
@ManyToOne(() => User) | ||
@JoinColumn({ name: 'user_id' }) | ||
user!: User; | ||
|
||
@ManyToOne(() => Course) | ||
@JoinColumn({ name: 'course_id' }) | ||
course!: Course; | ||
|
||
@Column('double') | ||
amount!: number; | ||
|
||
@Column({ type: 'date' }) | ||
payment_date!: Date; | ||
|
||
@Column({ | ||
type: 'enum', | ||
enum: ['pending', 'done'], | ||
}) | ||
status!: string; | ||
|
||
@Column({ type: 'bigint' }) | ||
user_id!: number; | ||
|
||
@Column({ type: 'bigint' }) | ||
course_id!: number; | ||
|
||
@CreateDateColumn({ type: 'datetime' }) | ||
created_at!: Date; | ||
|
||
@UpdateDateColumn({ type: 'datetime' }) | ||
updated_at!: Date; | ||
|
||
constructor(paymentData?: Partial<Payment>) { | ||
paymentData && Object.assign(this, paymentData); | ||
} | ||
} |
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,43 @@ | ||
import { Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
ManyToOne, | ||
CreateDateColumn, | ||
UpdateDateColumn, | ||
JoinColumn | ||
} from 'typeorm'; | ||
import { User } from './User'; | ||
import { Course } from './Course'; | ||
|
||
@Entity('reviews') | ||
export class Review { | ||
@PrimaryGeneratedColumn('increment', { type: 'bigint' }) | ||
id!: number; | ||
|
||
@ManyToOne(() => User) | ||
@JoinColumn({ name: 'user_id' }) | ||
user!: User; | ||
|
||
@ManyToOne(() => Course) | ||
@JoinColumn({ name: 'course_id' }) | ||
course!: Course; | ||
|
||
@Column('integer') | ||
rating!: number; | ||
|
||
@Column({ type: 'bigint' }) | ||
user_id!: number; | ||
|
||
@Column({ type: 'bigint' }) | ||
course_id!: number; | ||
|
||
@CreateDateColumn({ type: 'datetime' }) | ||
created_at!: Date; | ||
|
||
@UpdateDateColumn({ type: 'datetime' }) | ||
updated_at!: Date; | ||
|
||
constructor(reviewData?: Partial<Review>) { | ||
reviewData && Object.assign(this, reviewData); | ||
} | ||
} |
Oops, something went wrong.