schema.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // Code generated by entc, DO NOT EDIT.
  2. package migrate
  3. import (
  4. "entgo.io/ent/dialect/entsql"
  5. "entgo.io/ent/dialect/sql/schema"
  6. "entgo.io/ent/schema/field"
  7. )
  8. var (
  9. // CarsColumns holds the columns for the "cars" table.
  10. CarsColumns = []*schema.Column{
  11. {Name: "id", Type: field.TypeInt, Increment: true},
  12. {Name: "model", Type: field.TypeString},
  13. {Name: "registered_at", Type: field.TypeTime},
  14. {Name: "user_cars", Type: field.TypeInt, Nullable: true},
  15. }
  16. // CarsTable holds the schema information for the "cars" table.
  17. CarsTable = &schema.Table{
  18. Name: "cars",
  19. Columns: CarsColumns,
  20. PrimaryKey: []*schema.Column{CarsColumns[0]},
  21. ForeignKeys: []*schema.ForeignKey{
  22. {
  23. Symbol: "cars_users_cars",
  24. Columns: []*schema.Column{CarsColumns[3]},
  25. RefColumns: []*schema.Column{UsersColumns[0]},
  26. OnDelete: schema.SetNull,
  27. },
  28. },
  29. }
  30. // GroupsColumns holds the columns for the "groups" table.
  31. GroupsColumns = []*schema.Column{
  32. {Name: "id", Type: field.TypeInt, Increment: true},
  33. {Name: "name", Type: field.TypeString},
  34. }
  35. // GroupsTable holds the schema information for the "groups" table.
  36. GroupsTable = &schema.Table{
  37. Name: "groups",
  38. Columns: GroupsColumns,
  39. PrimaryKey: []*schema.Column{GroupsColumns[0]},
  40. }
  41. // UsersColumns holds the columns for the "users" table.
  42. UsersColumns = []*schema.Column{
  43. {Name: "id", Type: field.TypeInt, Increment: true},
  44. {Name: "age", Type: field.TypeInt},
  45. {Name: "name", Type: field.TypeString, Default: "unknown"},
  46. {Name: "password", Type: field.TypeString, Nullable: true},
  47. {Name: "size", Type: field.TypeEnum, Enums: []string{"XS", "S", "M", "L", "XL"}, Default: "M"},
  48. {Name: "spouse_id", Type: field.TypeInt, Unique: true, Nullable: true},
  49. }
  50. // UsersTable holds the schema information for the "users" table.
  51. UsersTable = &schema.Table{
  52. Name: "users",
  53. Columns: UsersColumns,
  54. PrimaryKey: []*schema.Column{UsersColumns[0]},
  55. ForeignKeys: []*schema.ForeignKey{
  56. {
  57. Symbol: "users_users_spouse",
  58. Columns: []*schema.Column{UsersColumns[5]},
  59. RefColumns: []*schema.Column{UsersColumns[0]},
  60. OnDelete: schema.SetNull,
  61. },
  62. },
  63. Indexes: []*schema.Index{
  64. {
  65. Name: "user_age_name",
  66. Unique: true,
  67. Columns: []*schema.Column{UsersColumns[1], UsersColumns[2]},
  68. },
  69. {
  70. Name: "user_name",
  71. Unique: false,
  72. Columns: []*schema.Column{UsersColumns[2]},
  73. Annotation: &entsql.IndexAnnotation{
  74. Prefix: 10,
  75. },
  76. },
  77. },
  78. }
  79. // GroupUsersColumns holds the columns for the "group_users" table.
  80. GroupUsersColumns = []*schema.Column{
  81. {Name: "group_id", Type: field.TypeInt},
  82. {Name: "user_id", Type: field.TypeInt},
  83. }
  84. // GroupUsersTable holds the schema information for the "group_users" table.
  85. GroupUsersTable = &schema.Table{
  86. Name: "group_users",
  87. Columns: GroupUsersColumns,
  88. PrimaryKey: []*schema.Column{GroupUsersColumns[0], GroupUsersColumns[1]},
  89. ForeignKeys: []*schema.ForeignKey{
  90. {
  91. Symbol: "group_users_group_id",
  92. Columns: []*schema.Column{GroupUsersColumns[0]},
  93. RefColumns: []*schema.Column{GroupsColumns[0]},
  94. OnDelete: schema.Cascade,
  95. },
  96. {
  97. Symbol: "group_users_user_id",
  98. Columns: []*schema.Column{GroupUsersColumns[1]},
  99. RefColumns: []*schema.Column{UsersColumns[0]},
  100. OnDelete: schema.Cascade,
  101. },
  102. },
  103. }
  104. // UserFollowingColumns holds the columns for the "user_following" table.
  105. UserFollowingColumns = []*schema.Column{
  106. {Name: "user_id", Type: field.TypeInt},
  107. {Name: "follower_id", Type: field.TypeInt},
  108. }
  109. // UserFollowingTable holds the schema information for the "user_following" table.
  110. UserFollowingTable = &schema.Table{
  111. Name: "user_following",
  112. Columns: UserFollowingColumns,
  113. PrimaryKey: []*schema.Column{UserFollowingColumns[0], UserFollowingColumns[1]},
  114. ForeignKeys: []*schema.ForeignKey{
  115. {
  116. Symbol: "user_following_user_id",
  117. Columns: []*schema.Column{UserFollowingColumns[0]},
  118. RefColumns: []*schema.Column{UsersColumns[0]},
  119. OnDelete: schema.Cascade,
  120. },
  121. {
  122. Symbol: "user_following_follower_id",
  123. Columns: []*schema.Column{UserFollowingColumns[1]},
  124. RefColumns: []*schema.Column{UsersColumns[0]},
  125. OnDelete: schema.Cascade,
  126. },
  127. },
  128. }
  129. // UserFriendsColumns holds the columns for the "user_friends" table.
  130. UserFriendsColumns = []*schema.Column{
  131. {Name: "user_id", Type: field.TypeInt},
  132. {Name: "friend_id", Type: field.TypeInt},
  133. }
  134. // UserFriendsTable holds the schema information for the "user_friends" table.
  135. UserFriendsTable = &schema.Table{
  136. Name: "user_friends",
  137. Columns: UserFriendsColumns,
  138. PrimaryKey: []*schema.Column{UserFriendsColumns[0], UserFriendsColumns[1]},
  139. ForeignKeys: []*schema.ForeignKey{
  140. {
  141. Symbol: "user_friends_user_id",
  142. Columns: []*schema.Column{UserFriendsColumns[0]},
  143. RefColumns: []*schema.Column{UsersColumns[0]},
  144. OnDelete: schema.Cascade,
  145. },
  146. {
  147. Symbol: "user_friends_friend_id",
  148. Columns: []*schema.Column{UserFriendsColumns[1]},
  149. RefColumns: []*schema.Column{UsersColumns[0]},
  150. OnDelete: schema.Cascade,
  151. },
  152. },
  153. }
  154. // Tables holds all the tables in the schema.
  155. Tables = []*schema.Table{
  156. CarsTable,
  157. GroupsTable,
  158. UsersTable,
  159. GroupUsersTable,
  160. UserFollowingTable,
  161. UserFriendsTable,
  162. }
  163. )
  164. func init() {
  165. CarsTable.ForeignKeys[0].RefTable = UsersTable
  166. UsersTable.ForeignKeys[0].RefTable = UsersTable
  167. GroupUsersTable.ForeignKeys[0].RefTable = GroupsTable
  168. GroupUsersTable.ForeignKeys[1].RefTable = UsersTable
  169. UserFollowingTable.ForeignKeys[0].RefTable = UsersTable
  170. UserFollowingTable.ForeignKeys[1].RefTable = UsersTable
  171. UserFriendsTable.ForeignKeys[0].RefTable = UsersTable
  172. UserFriendsTable.ForeignKeys[1].RefTable = UsersTable
  173. }