schema.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Code generated by entc, DO NOT EDIT.
  2. package migrate
  3. import (
  4. "github.com/facebookincubator/ent/dialect/sql/schema"
  5. "github.com/facebookincubator/ent/schema/field"
  6. )
  7. var (
  8. // CarsColumns holds the columns for the "cars" table.
  9. CarsColumns = []*schema.Column{
  10. {Name: "id", Type: field.TypeInt, Increment: true},
  11. {Name: "model", Type: field.TypeString},
  12. {Name: "registered_at", Type: field.TypeTime},
  13. {Name: "user_cars", Type: field.TypeInt, Nullable: true},
  14. }
  15. // CarsTable holds the schema information for the "cars" table.
  16. CarsTable = &schema.Table{
  17. Name: "cars",
  18. Columns: CarsColumns,
  19. PrimaryKey: []*schema.Column{CarsColumns[0]},
  20. ForeignKeys: []*schema.ForeignKey{
  21. {
  22. Symbol: "cars_users_cars",
  23. Columns: []*schema.Column{CarsColumns[3]},
  24. RefColumns: []*schema.Column{UsersColumns[0]},
  25. OnDelete: schema.SetNull,
  26. },
  27. },
  28. }
  29. // GroupsColumns holds the columns for the "groups" table.
  30. GroupsColumns = []*schema.Column{
  31. {Name: "id", Type: field.TypeInt, Increment: true},
  32. {Name: "name", Type: field.TypeString},
  33. }
  34. // GroupsTable holds the schema information for the "groups" table.
  35. GroupsTable = &schema.Table{
  36. Name: "groups",
  37. Columns: GroupsColumns,
  38. PrimaryKey: []*schema.Column{GroupsColumns[0]},
  39. ForeignKeys: []*schema.ForeignKey{},
  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. }
  47. // UsersTable holds the schema information for the "users" table.
  48. UsersTable = &schema.Table{
  49. Name: "users",
  50. Columns: UsersColumns,
  51. PrimaryKey: []*schema.Column{UsersColumns[0]},
  52. ForeignKeys: []*schema.ForeignKey{},
  53. }
  54. // GroupUsersColumns holds the columns for the "group_users" table.
  55. GroupUsersColumns = []*schema.Column{
  56. {Name: "group_id", Type: field.TypeInt},
  57. {Name: "user_id", Type: field.TypeInt},
  58. }
  59. // GroupUsersTable holds the schema information for the "group_users" table.
  60. GroupUsersTable = &schema.Table{
  61. Name: "group_users",
  62. Columns: GroupUsersColumns,
  63. PrimaryKey: []*schema.Column{GroupUsersColumns[0], GroupUsersColumns[1]},
  64. ForeignKeys: []*schema.ForeignKey{
  65. {
  66. Symbol: "group_users_group_id",
  67. Columns: []*schema.Column{GroupUsersColumns[0]},
  68. RefColumns: []*schema.Column{GroupsColumns[0]},
  69. OnDelete: schema.Cascade,
  70. },
  71. {
  72. Symbol: "group_users_user_id",
  73. Columns: []*schema.Column{GroupUsersColumns[1]},
  74. RefColumns: []*schema.Column{UsersColumns[0]},
  75. OnDelete: schema.Cascade,
  76. },
  77. },
  78. }
  79. // Tables holds all the tables in the schema.
  80. Tables = []*schema.Table{
  81. CarsTable,
  82. GroupsTable,
  83. UsersTable,
  84. GroupUsersTable,
  85. }
  86. )
  87. func init() {
  88. CarsTable.ForeignKeys[0].RefTable = UsersTable
  89. GroupUsersTable.ForeignKeys[0].RefTable = GroupsTable
  90. GroupUsersTable.ForeignKeys[1].RefTable = UsersTable
  91. }