artist_profile.go 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. package models
  2. import (
  3. "database/sql"
  4. "time"
  5. "github.com/google/uuid"
  6. "github.com/guregu/null"
  7. "gorm.io/gorm"
  8. )
  9. var (
  10. _ = time.Second
  11. _ = sql.LevelDefault
  12. _ = null.Bool{}
  13. _ = uuid.UUID{}
  14. )
  15. /*
  16. DB Table Details
  17. -------------------------------------
  18. CREATE TABLE `artist_profile` (
  19. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  20. `user_id` bigint(20) unsigned NOT NULL,
  21. `team` varchar(128) COLLATE utf8mb4_bin DEFAULT NULL,
  22. `category` varchar(128) COLLATE utf8mb4_bin DEFAULT NULL,
  23. `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  24. `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  25. `deleted_at` timestamp NULL DEFAULT NULL,
  26. PRIMARY KEY (`id`),
  27. UNIQUE KEY `id_UNIQUE` (`id`),
  28. KEY `fk_artist_profile_user1_idx` (`user_id`),
  29. CONSTRAINT `fk_artist_profile_user1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
  30. ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
  31. JSON Sample
  32. -------------------------------------
  33. { "id": 77, "user_id": 27, "team": "XLHSRWXmwBCNMeFIfdWaXvAlH", "category": "AMGgQlTPXiKLixvTwUQEPFYqv", "created_at": "2290-06-11T21:00:26.124293847+09:00", "updated_at": "2129-07-09T15:31:48.860108485+09:00", "deleted_at": "2287-10-03T02:34:10.581044283+09:00"}
  34. Comments
  35. -------------------------------------
  36. [ 0] column is set for unsigned
  37. [ 1] column is set for unsigned
  38. */
  39. // ArtistProfile struct is a row record of the artist_profile table in the metarare database
  40. type ArtistProfile struct {
  41. //[ 0] id ubigint null: false primary: true isArray: false auto: true col: ubigint len: -1 default: []
  42. ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:ubigint;" json:"id"`
  43. //[ 1] user_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: []
  44. UserID uint64 `gorm:"column:user_id;type:ubigint;" json:"user_id"`
  45. //[ 2] team varchar(128) null: true primary: false isArray: false auto: false col: varchar len: 128 default: []
  46. Team null.String `gorm:"column:team;type:varchar;size:128;" json:"team"`
  47. //[ 3] category varchar(128) null: true primary: false isArray: false auto: false col: varchar len: 128 default: []
  48. Category null.String `gorm:"column:category;type:varchar;size:128;" json:"category"`
  49. //[ 4] created_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP]
  50. CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"created_at"`
  51. //[ 5] updated_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP]
  52. UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"updated_at"`
  53. //[ 6] deleted_at timestamp null: true primary: false isArray: false auto: false col: timestamp len: -1 default: []
  54. DeletedAt null.Time `gorm:"column:deleted_at;type:timestamp;" json:"deleted_at"`
  55. }
  56. var artist_profileTableInfo = &TableInfo{
  57. Name: "artist_profile",
  58. Columns: []*ColumnInfo{
  59. &ColumnInfo{
  60. Index: 0,
  61. Name: "id",
  62. Comment: ``,
  63. Notes: `column is set for unsigned`,
  64. Nullable: false,
  65. DatabaseTypeName: "ubigint",
  66. DatabaseTypePretty: "ubigint",
  67. IsPrimaryKey: true,
  68. IsAutoIncrement: true,
  69. IsArray: false,
  70. ColumnType: "ubigint",
  71. ColumnLength: -1,
  72. GoFieldName: "ID",
  73. GoFieldType: "uint64",
  74. JSONFieldName: "id",
  75. ProtobufFieldName: "id",
  76. ProtobufType: "uint64",
  77. ProtobufPos: 1,
  78. },
  79. &ColumnInfo{
  80. Index: 1,
  81. Name: "user_id",
  82. Comment: ``,
  83. Notes: `column is set for unsigned`,
  84. Nullable: false,
  85. DatabaseTypeName: "ubigint",
  86. DatabaseTypePretty: "ubigint",
  87. IsPrimaryKey: false,
  88. IsAutoIncrement: false,
  89. IsArray: false,
  90. ColumnType: "ubigint",
  91. ColumnLength: -1,
  92. GoFieldName: "UserID",
  93. GoFieldType: "uint64",
  94. JSONFieldName: "user_id",
  95. ProtobufFieldName: "user_id",
  96. ProtobufType: "uint64",
  97. ProtobufPos: 2,
  98. },
  99. &ColumnInfo{
  100. Index: 2,
  101. Name: "team",
  102. Comment: ``,
  103. Notes: ``,
  104. Nullable: true,
  105. DatabaseTypeName: "varchar",
  106. DatabaseTypePretty: "varchar(128)",
  107. IsPrimaryKey: false,
  108. IsAutoIncrement: false,
  109. IsArray: false,
  110. ColumnType: "varchar",
  111. ColumnLength: 128,
  112. GoFieldName: "Team",
  113. GoFieldType: "null.String",
  114. JSONFieldName: "team",
  115. ProtobufFieldName: "team",
  116. ProtobufType: "string",
  117. ProtobufPos: 3,
  118. },
  119. &ColumnInfo{
  120. Index: 3,
  121. Name: "category",
  122. Comment: ``,
  123. Notes: ``,
  124. Nullable: true,
  125. DatabaseTypeName: "varchar",
  126. DatabaseTypePretty: "varchar(128)",
  127. IsPrimaryKey: false,
  128. IsAutoIncrement: false,
  129. IsArray: false,
  130. ColumnType: "varchar",
  131. ColumnLength: 128,
  132. GoFieldName: "Category",
  133. GoFieldType: "null.String",
  134. JSONFieldName: "category",
  135. ProtobufFieldName: "category",
  136. ProtobufType: "string",
  137. ProtobufPos: 4,
  138. },
  139. &ColumnInfo{
  140. Index: 4,
  141. Name: "created_at",
  142. Comment: ``,
  143. Notes: ``,
  144. Nullable: false,
  145. DatabaseTypeName: "timestamp",
  146. DatabaseTypePretty: "timestamp",
  147. IsPrimaryKey: false,
  148. IsAutoIncrement: false,
  149. IsArray: false,
  150. ColumnType: "timestamp",
  151. ColumnLength: -1,
  152. GoFieldName: "CreatedAt",
  153. GoFieldType: "time.Time",
  154. JSONFieldName: "created_at",
  155. ProtobufFieldName: "created_at",
  156. ProtobufType: "uint64",
  157. ProtobufPos: 5,
  158. },
  159. &ColumnInfo{
  160. Index: 5,
  161. Name: "updated_at",
  162. Comment: ``,
  163. Notes: ``,
  164. Nullable: false,
  165. DatabaseTypeName: "timestamp",
  166. DatabaseTypePretty: "timestamp",
  167. IsPrimaryKey: false,
  168. IsAutoIncrement: false,
  169. IsArray: false,
  170. ColumnType: "timestamp",
  171. ColumnLength: -1,
  172. GoFieldName: "UpdatedAt",
  173. GoFieldType: "time.Time",
  174. JSONFieldName: "updated_at",
  175. ProtobufFieldName: "updated_at",
  176. ProtobufType: "uint64",
  177. ProtobufPos: 6,
  178. },
  179. &ColumnInfo{
  180. Index: 6,
  181. Name: "deleted_at",
  182. Comment: ``,
  183. Notes: ``,
  184. Nullable: true,
  185. DatabaseTypeName: "timestamp",
  186. DatabaseTypePretty: "timestamp",
  187. IsPrimaryKey: false,
  188. IsAutoIncrement: false,
  189. IsArray: false,
  190. ColumnType: "timestamp",
  191. ColumnLength: -1,
  192. GoFieldName: "DeletedAt",
  193. GoFieldType: "null.Time",
  194. JSONFieldName: "deleted_at",
  195. ProtobufFieldName: "deleted_at",
  196. ProtobufType: "uint64",
  197. ProtobufPos: 7,
  198. },
  199. },
  200. }
  201. // TableName sets the insert table name for this struct type
  202. func (a *ArtistProfile) TableName() string {
  203. return "artist_profile"
  204. }
  205. // BeforeSave invoked before saving, return an error if field is not populated.
  206. func (a *ArtistProfile) BeforeSave(*gorm.DB) error {
  207. return nil
  208. }
  209. // Prepare invoked before saving, can be used to populate fields etc.
  210. func (a *ArtistProfile) Prepare() {
  211. }
  212. // Validate invoked before performing action, return an error if field is not populated.
  213. func (a *ArtistProfile) Validate(action Action) error {
  214. return nil
  215. }
  216. // TableInfo return table meta data
  217. func (a *ArtistProfile) TableInfo() *TableInfo {
  218. return artist_profileTableInfo
  219. }