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_authentication` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `user_id` bigint(20) unsigned NOT NULL, `email` varchar(256) COLLATE utf8mb4_bin NOT NULL, `password` varchar(256) COLLATE utf8mb4_bin DEFAULT NULL, `type` enum('google','kakao') 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`), KEY `fk_user_authentication_user1_idx` (`user_id`), CONSTRAINT `fk_user_authentication_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": 5, "user_id": 26, "email": "qpDGdUEuBlasqubyCsnPRFgDQ", "password": "tmwRMgeOqmqwtXsFpOuYWmHPg", "type": "mxoTTHLJTmOObSRIUfinPYFDk", "created_at": "2126-02-16T07:26:20.136151635+09:00", "updated_at": "2050-06-23T09:54:05.591551141+09:00", "deleted_at": "2060-04-23T03:36:34.555847934+09:00"} Comments ------------------------------------- [ 0] column is set for unsigned [ 1] column is set for unsigned */ // UserAuthentication struct is a row record of the user_authentication table in the metarare database type UserAuthentication 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] email varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] Email string `gorm:"column:email;type:varchar;size:256;" json:"email"` //[ 3] password varchar(256) null: true primary: false isArray: false auto: false col: varchar len: 256 default: [] Password null.String `gorm:"column:password;type:varchar;size:256;" json:"password"` //[ 4] type char(6) null: true primary: false isArray: false auto: false col: char len: 6 default: [] Type null.String `gorm:"column:type;type:char;size:6;" json:"type"` //[ 5] 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"` //[ 6] 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"` //[ 7] 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_authenticationTableInfo = &TableInfo{ Name: "user_authentication", 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: "email", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "Email", GoFieldType: "string", JSONFieldName: "email", ProtobufFieldName: "email", ProtobufType: "string", ProtobufPos: 3, }, &ColumnInfo{ Index: 3, Name: "password", Comment: ``, Notes: ``, Nullable: true, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "Password", GoFieldType: "null.String", JSONFieldName: "password", ProtobufFieldName: "password", ProtobufType: "string", ProtobufPos: 4, }, &ColumnInfo{ Index: 4, Name: "type", Comment: ``, Notes: ``, Nullable: true, DatabaseTypeName: "char", DatabaseTypePretty: "char(6)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "char", ColumnLength: 6, GoFieldName: "Type", GoFieldType: "null.String", JSONFieldName: "type", ProtobufFieldName: "type", ProtobufType: "string", ProtobufPos: 5, }, &ColumnInfo{ Index: 5, 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: 6, }, &ColumnInfo{ Index: 6, 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: 7, }, &ColumnInfo{ Index: 7, 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: 8, }, }, } // TableName sets the insert table name for this struct type func (u *UserAuthentication) TableName() string { return "user_authentication" } // BeforeSave invoked before saving, return an error if field is not populated. func (u *UserAuthentication) BeforeSave(*gorm.DB) error { return nil } // Prepare invoked before saving, can be used to populate fields etc. func (u *UserAuthentication) Prepare() { } // Validate invoked before performing action, return an error if field is not populated. func (u *UserAuthentication) Validate(action Action) error { return nil } // TableInfo return table meta data func (u *UserAuthentication) TableInfo() *TableInfo { return user_authenticationTableInfo }