removed unnecessary nullable:false - default behavior

This commit is contained in:
Kononnable 2019-10-07 13:51:39 +02:00
parent 099f4bcc9a
commit 577266a03b
16 changed files with 317 additions and 227 deletions

View File

@ -1,14 +1,26 @@
import { Index, Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable } from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable
} from "typeorm";
import { PostAuthor } from "./PostAuthor";
import { PostCategory } from "./PostCategory";
@Index("travel_travelplanextra_travel_plan_id_extra_id_f825ca51_uniq",["postAuthor","postCategory",],{unique:true})
@Index(
"travel_travelplanextra_travel_plan_id_extra_id_f825ca51_uniq",
["postAuthor", "postCategory"],
{ unique: true }
)
@Entity("Post")
export class Post {
@Column("int", {
nullable: false,
primary: true,
name: "Id"
})
@ -18,9 +30,7 @@ export class Post {
@JoinColumn()
postAuthor: PostAuthor;
@ManyToOne(type => PostCategory, PostCategory => PostCategory.Id)
@JoinColumn()
postCategory: PostCategory;
}

View File

@ -1,20 +1,26 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable,
RelationId
} from "typeorm";
import { Post } from "./Post";
@Entity("PostAuthor")
export class PostAuthor {
@Column("int",{
nullable:false,
primary:true,
name:"Id"
})
Id:number;
@Column("int", {
primary: true,
name: "Id"
})
Id: number;
@OneToMany(type => Post, Post => Post.Id)
posts:Post[];
posts: Post[];
}

View File

@ -1,20 +1,26 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable,
RelationId
} from "typeorm";
import { Post } from "./Post";
@Entity("PostCategory")
export class PostCategory {
@Column("int",{
nullable:false,
primary:true,
name:"Id"
})
Id:number;
@Column("int", {
primary: true,
name: "Id"
})
Id: number;
@OneToMany(type => Post, Post => Post.Id)
posts:Post[];
posts: Post[];
}

View File

@ -1,28 +1,30 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, JoinColumn} from "typeorm";
import {User} from "./User";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
JoinColumn
} from "typeorm";
import { User } from "./User";
@Entity("Post",{schema:"sch1"})
@Entity("Post", { schema: "sch1" })
export class Post {
@Column("integer", {
primary: true,
name: "id"
})
id: number;
@Column("integer",{
nullable:false,
primary:true,
name:"id"
})
id:number;
@ManyToOne(type=>User, userId=>userId.posts)
@JoinColumn({ name:"userId"})
userId:User;
@Column("text",{
nullable:true,
name:"body"
})
body:string;
@ManyToOne(type => User, userId => userId.posts)
@JoinColumn({ name: "userId" })
userId: User;
@Column("text", {
nullable: true,
name: "body"
})
body: string;
}

View File

@ -6,7 +6,6 @@ import {Post} from "./Post";
export class User {
@Column("integer",{
nullable:false,
primary:true,
name:"id"
})

View File

@ -1,20 +1,25 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, JoinColumn} from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
JoinColumn
} from "typeorm";
@Entity("Post")
export class Post {
@Column("integer", {
primary: true,
name: "id"
})
id: number;
@Column("integer",{
nullable:false,
primary:true,
name:"id"
})
id:number;
@Column({ unique: true })
body: string;
@Column({unique:true})
body:string;
@Column()
body2:string;
body2: string;
}

View File

@ -1,36 +1,43 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm";
import {users} from "./users";
import {quests} from "./quests";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable
} from "typeorm";
import { users } from "./users";
import { quests } from "./quests";
@Entity("feedextrainfo")
@Index("feedExtraInfo_FeedOwnerId_idx",["feedOwnerId",],{unique:true})
@Index("feedExtraInfo_ReaderId_idx",["readerId",],{unique:true})
@Index("feedExtraInfo_QuestId_idx",["questId",],{unique:true})
@Index("feedExtraInfo_FeedOwnerId_idx", ["feedOwnerId"], { unique: true })
@Index("feedExtraInfo_ReaderId_idx", ["readerId"], { unique: true })
@Index("feedExtraInfo_QuestId_idx", ["questId"], { unique: true })
export class feedextrainfo {
@OneToOne(type => users, FeedOwnerId => FeedOwnerId.feedextrainfo, {
primary: true
})
@JoinColumn({ name: "FeedOwnerId" })
feedOwnerId: users;
@OneToOne(type => quests, QuestId => QuestId.feedextrainfo, {
primary: true
})
@JoinColumn({ name: "QuestId" })
questId: quests;
@OneToOne(type=>users, FeedOwnerId=>FeedOwnerId.feedextrainfo,{primary:true, nullable:false, })
@JoinColumn({ name:'FeedOwnerId'})
feedOwnerId:users;
@OneToOne(type=>quests, QuestId=>QuestId.feedextrainfo,{primary:true, nullable:false, })
@JoinColumn({ name:'QuestId'})
questId:quests;
@OneToOne(type=>users, ReaderId=>ReaderId.feedextrainfo2,{primary:true, nullable:false, })
@JoinColumn({ name:'ReaderId'})
readerId:users;
@Column("int",{
nullable:false,
name:"MostUpdatedFeedEntryIdUserRead"
})
MostUpdatedFeedEntryIdUserRead:number;
@OneToOne(type => users, ReaderId => ReaderId.feedextrainfo2, {
primary: true
})
@JoinColumn({ name: "ReaderId" })
readerId: users;
@Column("int", {
name: "MostUpdatedFeedEntryIdUserRead"
})
MostUpdatedFeedEntryIdUserRead: number;
}

View File

@ -1,20 +1,25 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm";
import {feedextrainfo} from "./feedextrainfo";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable
} from "typeorm";
import { feedextrainfo } from "./feedextrainfo";
@Entity("quests")
export class quests {
@Column("int", {
primary: true,
name: "QuestId"
})
QuestId: number;
@Column("int",{
nullable:false,
primary:true,
name:"QuestId"
})
QuestId:number;
@OneToOne(type=>feedextrainfo, feedextrainfo=>feedextrainfo.questId)
feedextrainfo:feedextrainfo;
@OneToOne(type => feedextrainfo, feedextrainfo => feedextrainfo.questId)
feedextrainfo: feedextrainfo;
}

View File

@ -1,25 +1,28 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm";
import {feedextrainfo} from "./feedextrainfo";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable
} from "typeorm";
import { feedextrainfo } from "./feedextrainfo";
@Entity("users")
export class users {
@Column("int", {
primary: true,
name: "UserId"
})
UserId: number;
@Column("int",{
nullable:false,
primary:true,
name:"UserId"
})
UserId:number;
@OneToOne(type=>feedextrainfo, feedextrainfo=>feedextrainfo.feedOwnerId)
feedextrainfo:feedextrainfo;
@OneToOne(type=>feedextrainfo, feedextrainfo2=>feedextrainfo2.readerId)
feedextrainfo2:feedextrainfo;
@OneToOne(type => feedextrainfo, feedextrainfo => feedextrainfo.feedOwnerId)
feedextrainfo: feedextrainfo;
@OneToOne(type => feedextrainfo, feedextrainfo2 => feedextrainfo2.readerId)
feedextrainfo2: feedextrainfo;
}

View File

@ -1,24 +1,29 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable} from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable
} from "typeorm";
import { PostAuthor } from "./PostAuthor";
import { PostReader } from "./PostReader";
@Entity("Post")
export class Post {
@Column("int",{
nullable:false,
primary:true,
name:"Id"
})
Id:number;
@Column("int", {
primary: true,
name: "Id"
})
Id: number;
@OneToOne(type => PostAuthor, PostAuthor => PostAuthor.Id)
postAuthor: PostAuthor;
@OneToMany(type => PostReader, PostReader => PostReader.Id)
postReaders: PostReader[];
}

View File

@ -1,22 +1,29 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable,
RelationId
} from "typeorm";
import { Post } from "./Post";
@Entity("PostAuthor")
export class PostAuthor {
@Column("int",{
nullable:false,
primary:true,
name:"Id"
})
Id:number;
@Column("int", {
primary: true,
name: "Id"
})
Id: number;
@OneToOne(type => Post, Post => Post.Id)
@JoinColumn()
post:Post;
post: Post;
@RelationId((postAuthor: PostAuthor) => postAuthor.post)
postId: number;

View File

@ -1,20 +1,29 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable,
RelationId
} from "typeorm";
import { Post } from "./Post";
@Entity("PostReader")
export class PostReader {
@Column("int",{
nullable:false,
primary:true,
name:"Id"
})
Id:number;
@Column("int", {
primary: true,
name: "Id"
})
Id: number;
@ManyToOne(type => Post, Post => Post.Id)
@JoinColumn()
post:Post;
post: Post;
@RelationId((postReader: PostReader) => postReader.post)
postId: number[];

View File

@ -1,24 +1,30 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable,
RelationId
} from "typeorm";
import { Post } from "./Post";
@Entity("PostAuthor")
export class PostAuthor {
@Column("int", {
primary: true,
name: "Id"
})
Id: number;
@Column("int",{
nullable:false,
primary:true,
name:"Id"
})
Id:number;
@OneToOne(type => Post, Post => Post.Id,{
onDelete: "CASCADE",
@OneToOne(type => Post, Post => Post.Id, {
onDelete: "CASCADE"
// onUpdate: "CASCADE"
})
@JoinColumn()
post:Post;
post: Post;
}

View File

@ -1,25 +1,30 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable,
RelationId
} from "typeorm";
import { Post } from "./Post";
@Entity("PostCategory")
export class PostCategory {
@Column("int", {
primary: true,
name: "Id"
})
Id: number;
@Column("int",{
nullable:false,
primary:true,
name:"Id"
})
Id:number;
@OneToOne(type => Post, Post => Post.Id,
{
// onDelete: "RESTRICT",
// onUpdate: "RESTRICT"
})
@OneToOne(type => Post, Post => Post.Id, {
// onDelete: "RESTRICT",
// onUpdate: "RESTRICT"
})
@JoinColumn()
post:Post;
post: Post;
}

View File

@ -1,23 +1,30 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable,
RelationId
} from "typeorm";
import { Post } from "./Post";
@Entity("PostDetails")
export class PostDetails {
@Column("int", {
primary: true,
name: "Id"
})
Id: number;
@Column("int",{
nullable:false,
primary:true,
name:"Id"
})
Id:number;
@OneToOne(type => Post, Post => Post.Id,
{
onDelete: "SET NULL",
// onUpdate: "SET NULL"
})
@OneToOne(type => Post, Post => Post.Id, {
onDelete: "SET NULL"
// onUpdate: "SET NULL"
})
@JoinColumn()
post:Post;
post: Post;
}

View File

@ -1,19 +1,27 @@
import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, ManyToMany, JoinColumn, JoinTable, RelationId} from "typeorm";
import {
Index,
Entity,
PrimaryColumn,
Column,
OneToOne,
OneToMany,
ManyToOne,
ManyToMany,
JoinColumn,
JoinTable,
RelationId
} from "typeorm";
import { Post } from "./Post";
@Entity("PostReader")
export class PostReader {
@Column("int",{
nullable:false,
primary:true,
name:"Id"
})
Id:number;
@Column("int", {
primary: true,
name: "Id"
})
Id: number;
@OneToOne(type => Post, Post => Post.Id)
@JoinColumn()
post:Post;
post: Post;
}