123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- package models
- import (
- "database/sql"
- "time"
- "github.com/google/uuid"
- "github.com/guregu/null"
- "gorm.io/gorm"
- )
- var (
- _ = time.Second
- _ = sql.LevelDefault
- _ = null.Bool{}
- _ = uuid.UUID{}
- )
- /*
- DB Table Details
- -------------------------------------
- CREATE TABLE `user_profile` (
- `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
- `user_id` bigint(20) unsigned NOT NULL,
- `name` varchar(128) COLLATE utf8mb4_bin DEFAULT NULL,
- `description` text COLLATE utf8mb4_bin,
- `thumbnail_image` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,
- `cover_image` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL,
- `twitter` varchar(128) COLLATE utf8mb4_bin DEFAULT NULL,
- `phone` varchar(128) COLLATE utf8mb4_bin DEFAULT NULL,
- `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `deleted_at` timestamp NULL DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `id_UNIQUE` (`id`),
- UNIQUE KEY `name_UNIQUE` (`name`),
- KEY `fk_user_profile_user1_idx` (`user_id`),
- CONSTRAINT `fk_user_profile_user1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
- ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
- JSON Sample
- -------------------------------------
- { "id": 27, "user_id": 81, "name": "rFyDaRrWKkIBaWbBrSNUVFgcR", "description": "ZrshrLIUeHKyWXIaBOCvqxBiL", "thumbnail_image": "IqOPjBWjewHSrUiPfYjhlELCh", "cover_image": "haMZlpofHcflluQtJVUapfaVF", "twitter": "mcilISbCjSmiJYCBvxMIUgyMm", "phone": "lIxmtyEtdmcUPiqSnVvvaFtEZ", "created_at": "2285-03-04T03:11:06.107023701+09:00", "updated_at": "2164-11-10T10:42:59.086610084+09:00", "deleted_at": "2288-06-20T05:33:35.637597276+09:00"}
- Comments
- -------------------------------------
- [ 0] column is set for unsigned
- [ 1] column is set for unsigned
- */
- // UserProfile struct is a row record of the user_profile table in the metarare database
- type UserProfile struct {
- //[ 0] id ubigint null: false primary: true isArray: false auto: true col: ubigint len: -1 default: []
- ID uint64 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:ubigint;" json:"id"`
- //[ 1] user_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: []
- UserID uint64 `gorm:"column:user_id;type:ubigint;" json:"user_id"`
- //[ 2] name varchar(128) null: true primary: false isArray: false auto: false col: varchar len: 128 default: []
- Name null.String `gorm:"column:name;type:varchar;size:128;" json:"name"`
- //[ 3] description text(65535) null: true primary: false isArray: false auto: false col: text len: 65535 default: []
- Description null.String `gorm:"column:description;type:text;size:65535;" json:"description"`
- //[ 4] thumbnail_image varchar(256) null: true primary: false isArray: false auto: false col: varchar len: 256 default: []
- ThumbnailImage null.String `gorm:"column:thumbnail_image;type:varchar;size:256;" json:"thumbnail_image"`
- //[ 5] cover_image varchar(256) null: true primary: false isArray: false auto: false col: varchar len: 256 default: []
- CoverImage null.String `gorm:"column:cover_image;type:varchar;size:256;" json:"cover_image"`
- //[ 6] twitter varchar(128) null: true primary: false isArray: false auto: false col: varchar len: 128 default: []
- Twitter null.String `gorm:"column:twitter;type:varchar;size:128;" json:"twitter"`
- //[ 7] phone varchar(128) null: true primary: false isArray: false auto: false col: varchar len: 128 default: []
- Phone null.String `gorm:"column:phone;type:varchar;size:128;" json:"phone"`
- //[ 8] created_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP]
- CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"created_at"`
- //[ 9] updated_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [CURRENT_TIMESTAMP]
- UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:CURRENT_TIMESTAMP;" json:"updated_at"`
- //[10] deleted_at timestamp null: true primary: false isArray: false auto: false col: timestamp len: -1 default: []
- DeletedAt null.Time `gorm:"column:deleted_at;type:timestamp;" json:"deleted_at"`
- }
- var user_profileTableInfo = &TableInfo{
- Name: "user_profile",
- Columns: []*ColumnInfo{
- &ColumnInfo{
- Index: 0,
- Name: "id",
- Comment: ``,
- Notes: `column is set for unsigned`,
- Nullable: false,
- DatabaseTypeName: "ubigint",
- DatabaseTypePretty: "ubigint",
- IsPrimaryKey: true,
- IsAutoIncrement: true,
- IsArray: false,
- ColumnType: "ubigint",
- ColumnLength: -1,
- GoFieldName: "ID",
- GoFieldType: "uint64",
- JSONFieldName: "id",
- ProtobufFieldName: "id",
- ProtobufType: "uint64",
- ProtobufPos: 1,
- },
- &ColumnInfo{
- Index: 1,
- Name: "user_id",
- Comment: ``,
- Notes: `column is set for unsigned`,
- Nullable: false,
- DatabaseTypeName: "ubigint",
- DatabaseTypePretty: "ubigint",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "ubigint",
- ColumnLength: -1,
- GoFieldName: "UserID",
- GoFieldType: "uint64",
- JSONFieldName: "user_id",
- ProtobufFieldName: "user_id",
- ProtobufType: "uint64",
- ProtobufPos: 2,
- },
- &ColumnInfo{
- Index: 2,
- Name: "name",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(128)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 128,
- GoFieldName: "Name",
- GoFieldType: "null.String",
- JSONFieldName: "name",
- ProtobufFieldName: "name",
- ProtobufType: "string",
- ProtobufPos: 3,
- },
- &ColumnInfo{
- Index: 3,
- Name: "description",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "text",
- DatabaseTypePretty: "text(65535)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "text",
- ColumnLength: 65535,
- GoFieldName: "Description",
- GoFieldType: "null.String",
- JSONFieldName: "description",
- ProtobufFieldName: "description",
- ProtobufType: "string",
- ProtobufPos: 4,
- },
- &ColumnInfo{
- Index: 4,
- Name: "thumbnail_image",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "ThumbnailImage",
- GoFieldType: "null.String",
- JSONFieldName: "thumbnail_image",
- ProtobufFieldName: "thumbnail_image",
- ProtobufType: "string",
- ProtobufPos: 5,
- },
- &ColumnInfo{
- Index: 5,
- Name: "cover_image",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(256)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 256,
- GoFieldName: "CoverImage",
- GoFieldType: "null.String",
- JSONFieldName: "cover_image",
- ProtobufFieldName: "cover_image",
- ProtobufType: "string",
- ProtobufPos: 6,
- },
- &ColumnInfo{
- Index: 6,
- Name: "twitter",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(128)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 128,
- GoFieldName: "Twitter",
- GoFieldType: "null.String",
- JSONFieldName: "twitter",
- ProtobufFieldName: "twitter",
- ProtobufType: "string",
- ProtobufPos: 7,
- },
- &ColumnInfo{
- Index: 7,
- Name: "phone",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "varchar",
- DatabaseTypePretty: "varchar(128)",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "varchar",
- ColumnLength: 128,
- GoFieldName: "Phone",
- GoFieldType: "null.String",
- JSONFieldName: "phone",
- ProtobufFieldName: "phone",
- ProtobufType: "string",
- ProtobufPos: 8,
- },
- &ColumnInfo{
- Index: 8,
- Name: "created_at",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "timestamp",
- DatabaseTypePretty: "timestamp",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "timestamp",
- ColumnLength: -1,
- GoFieldName: "CreatedAt",
- GoFieldType: "time.Time",
- JSONFieldName: "created_at",
- ProtobufFieldName: "created_at",
- ProtobufType: "uint64",
- ProtobufPos: 9,
- },
- &ColumnInfo{
- Index: 9,
- Name: "updated_at",
- Comment: ``,
- Notes: ``,
- Nullable: false,
- DatabaseTypeName: "timestamp",
- DatabaseTypePretty: "timestamp",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "timestamp",
- ColumnLength: -1,
- GoFieldName: "UpdatedAt",
- GoFieldType: "time.Time",
- JSONFieldName: "updated_at",
- ProtobufFieldName: "updated_at",
- ProtobufType: "uint64",
- ProtobufPos: 10,
- },
- &ColumnInfo{
- Index: 10,
- Name: "deleted_at",
- Comment: ``,
- Notes: ``,
- Nullable: true,
- DatabaseTypeName: "timestamp",
- DatabaseTypePretty: "timestamp",
- IsPrimaryKey: false,
- IsAutoIncrement: false,
- IsArray: false,
- ColumnType: "timestamp",
- ColumnLength: -1,
- GoFieldName: "DeletedAt",
- GoFieldType: "null.Time",
- JSONFieldName: "deleted_at",
- ProtobufFieldName: "deleted_at",
- ProtobufType: "uint64",
- ProtobufPos: 11,
- },
- },
- }
- // TableName sets the insert table name for this struct type
- func (u *UserProfile) TableName() string {
- return "user_profile"
- }
- // BeforeSave invoked before saving, return an error if field is not populated.
- func (u *UserProfile) BeforeSave(*gorm.DB) error {
- return nil
- }
- // Prepare invoked before saving, can be used to populate fields etc.
- func (u *UserProfile) Prepare() {
- }
- // Validate invoked before performing action, return an error if field is not populated.
- func (u *UserProfile) Validate(action Action) error {
- return nil
- }
- // TableInfo return table meta data
- func (u *UserProfile) TableInfo() *TableInfo {
- return user_profileTableInfo
- }
|