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 `deposit` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `user_id` bigint(20) unsigned NOT NULL, `sale_id` bigint(20) unsigned NOT NULL, `type` enum('eth','mr','mf') COLLATE utf8mb4_bin NOT NULL, `eth_price` double unsigned DEFAULT NULL, `mf1_price` double unsigned DEFAULT NULL, `mr_price` double unsigned DEFAULT NULL, `status` enum('deposit','withdrawal') COLLATE utf8mb4_bin NOT 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_deposit_user1_idx` (`user_id`), KEY `fk_deposit_sale1_idx` (`sale_id`), CONSTRAINT `fk_deposit_sale1` FOREIGN KEY (`sale_id`) REFERENCES `sale` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_deposit_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": 15, "user_id": 15, "sale_id": 42, "type": "ZUVadboZActhXbCqcqkEmNZLP", "eth_price": 0.8648269980596258, "mf_1_price": 0.6687510484943536, "mr_price": 0.762288315291406, "status": "FCChVpwSLaSNAEJqRSgKsWxGB", "created_at": "2264-08-19T04:05:27.304906346+09:00", "updated_at": "2033-10-22T18:37:03.863970849+09:00", "deleted_at": "2031-01-19T09:51:31.038499828+09:00"} Comments ------------------------------------- [ 0] column is set for unsigned [ 1] column is set for unsigned [ 2] column is set for unsigned [ 4] column is set for unsigned [ 5] column is set for unsigned [ 6] column is set for unsigned */ // Deposit struct is a row record of the deposit table in the metarare database type Deposit 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] sale_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: [] SaleID uint64 `gorm:"column:sale_id;type:ubigint;" json:"sale_id"` //[ 3] type char(3) null: false primary: false isArray: false auto: false col: char len: 3 default: [] Type string `gorm:"column:type;type:char;size:3;" json:"type"` //[ 4] eth_price udouble null: true primary: false isArray: false auto: false col: udouble len: -1 default: [] EthPrice null.Float `gorm:"column:eth_price;type:udouble;" json:"eth_price"` //[ 5] mf1_price udouble null: true primary: false isArray: false auto: false col: udouble len: -1 default: [] Mf1Price null.Float `gorm:"column:mf1_price;type:udouble;" json:"mf_1_price"` //[ 6] mr_price udouble null: true primary: false isArray: false auto: false col: udouble len: -1 default: [] MrPrice null.Float `gorm:"column:mr_price;type:udouble;" json:"mr_price"` //[ 7] status char(10) null: false primary: false isArray: false auto: false col: char len: 10 default: [] Status string `gorm:"column:status;type:char;size:10;" json:"status"` //[ 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 depositTableInfo = &TableInfo{ Name: "deposit", 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: "sale_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: "SaleID", GoFieldType: "uint64", JSONFieldName: "sale_id", ProtobufFieldName: "sale_id", ProtobufType: "uint64", ProtobufPos: 3, }, &ColumnInfo{ Index: 3, Name: "type", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "char", DatabaseTypePretty: "char(3)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "char", ColumnLength: 3, GoFieldName: "Type", GoFieldType: "string", JSONFieldName: "type", ProtobufFieldName: "type", ProtobufType: "string", ProtobufPos: 4, }, &ColumnInfo{ Index: 4, Name: "eth_price", Comment: ``, Notes: `column is set for unsigned`, Nullable: true, DatabaseTypeName: "udouble", DatabaseTypePretty: "udouble", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "udouble", ColumnLength: -1, GoFieldName: "EthPrice", GoFieldType: "null.Float", JSONFieldName: "eth_price", ProtobufFieldName: "eth_price", ProtobufType: "float", ProtobufPos: 5, }, &ColumnInfo{ Index: 5, Name: "mf1_price", Comment: ``, Notes: `column is set for unsigned`, Nullable: true, DatabaseTypeName: "udouble", DatabaseTypePretty: "udouble", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "udouble", ColumnLength: -1, GoFieldName: "Mf1Price", GoFieldType: "null.Float", JSONFieldName: "mf_1_price", ProtobufFieldName: "mf_1_price", ProtobufType: "float", ProtobufPos: 6, }, &ColumnInfo{ Index: 6, Name: "mr_price", Comment: ``, Notes: `column is set for unsigned`, Nullable: true, DatabaseTypeName: "udouble", DatabaseTypePretty: "udouble", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "udouble", ColumnLength: -1, GoFieldName: "MrPrice", GoFieldType: "null.Float", JSONFieldName: "mr_price", ProtobufFieldName: "mr_price", ProtobufType: "float", ProtobufPos: 7, }, &ColumnInfo{ Index: 7, Name: "status", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "char", DatabaseTypePretty: "char(10)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "char", ColumnLength: 10, GoFieldName: "Status", GoFieldType: "string", JSONFieldName: "status", ProtobufFieldName: "status", 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 (d *Deposit) TableName() string { return "deposit" } // BeforeSave invoked before saving, return an error if field is not populated. func (d *Deposit) BeforeSave(*gorm.DB) error { return nil } // Prepare invoked before saving, can be used to populate fields etc. func (d *Deposit) Prepare() { } // Validate invoked before performing action, return an error if field is not populated. func (d *Deposit) Validate(action Action) error { return nil } // TableInfo return table meta data func (d *Deposit) TableInfo() *TableInfo { return depositTableInfo }