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 `log_relation` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `deleted_at` timestamp NULL DEFAULT NULL, `user_id` bigint(20) unsigned DEFAULT NULL, `collection_id` bigint(20) unsigned DEFAULT NULL, `token_id` bigint(20) unsigned DEFAULT NULL, `sale_id` bigint(20) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_log_relation_user1_idx` (`user_id`), KEY `fk_log_relation_collection1_idx` (`collection_id`), KEY `fk_log_relation_token1_idx` (`token_id`), KEY `fk_log_relation_sale1_idx` (`sale_id`), CONSTRAINT `fk_log_relation_collection1` FOREIGN KEY (`collection_id`) REFERENCES `collection` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_log_relation_sale1` FOREIGN KEY (`sale_id`) REFERENCES `sale` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_log_relation_token1` FOREIGN KEY (`token_id`) REFERENCES `token` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_log_relation_user1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin JSON Sample ------------------------------------- { "id": 73, "created_at": "2142-07-19T06:33:35.464349449+09:00", "updated_at": "2111-11-13T13:28:26.73839082+09:00", "deleted_at": "2076-11-27T17:15:21.29440524+09:00", "user_id": 44, "collection_id": 45, "token_id": 27, "sale_id": 94} Comments ------------------------------------- [ 0] column is set for unsigned [ 4] column is set for unsigned [ 5] column is set for unsigned [ 6] column is set for unsigned [ 7] column is set for unsigned */ // LogRelation struct is a row record of the log_relation table in the metarare database type LogRelation 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] 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"` //[ 2] 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"` //[ 3] 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"` //[ 4] user_id ubigint null: true primary: false isArray: false auto: false col: ubigint len: -1 default: [] UserID null.Int `gorm:"column:user_id;type:ubigint;" json:"user_id"` //[ 5] collection_id ubigint null: true primary: false isArray: false auto: false col: ubigint len: -1 default: [] CollectionID null.Int `gorm:"column:collection_id;type:ubigint;" json:"collection_id"` //[ 6] token_id ubigint null: true primary: false isArray: false auto: false col: ubigint len: -1 default: [] TokenID null.Int `gorm:"column:token_id;type:ubigint;" json:"token_id"` //[ 7] sale_id ubigint null: true primary: false isArray: false auto: false col: ubigint len: -1 default: [] Log Log SaleID null.Int `gorm:"column:sale_id;type:ubigint;" json:"sale_id"` User User Collection Collection Token Token Sale Sale } var log_relationTableInfo = &TableInfo{ Name: "log_relation", 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: "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: 2, }, &ColumnInfo{ Index: 2, 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: 3, }, &ColumnInfo{ Index: 3, 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: 4, }, &ColumnInfo{ Index: 4, Name: "user_id", Comment: ``, Notes: `column is set for unsigned`, Nullable: true, DatabaseTypeName: "ubigint", DatabaseTypePretty: "ubigint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "ubigint", ColumnLength: -1, GoFieldName: "UserID", GoFieldType: "null.Int", JSONFieldName: "user_id", ProtobufFieldName: "user_id", ProtobufType: "uint64", ProtobufPos: 5, }, &ColumnInfo{ Index: 5, Name: "collection_id", Comment: ``, Notes: `column is set for unsigned`, Nullable: true, DatabaseTypeName: "ubigint", DatabaseTypePretty: "ubigint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "ubigint", ColumnLength: -1, GoFieldName: "CollectionID", GoFieldType: "null.Int", JSONFieldName: "collection_id", ProtobufFieldName: "collection_id", ProtobufType: "uint64", ProtobufPos: 6, }, &ColumnInfo{ Index: 6, Name: "token_id", Comment: ``, Notes: `column is set for unsigned`, Nullable: true, DatabaseTypeName: "ubigint", DatabaseTypePretty: "ubigint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "ubigint", ColumnLength: -1, GoFieldName: "TokenID", GoFieldType: "null.Int", JSONFieldName: "token_id", ProtobufFieldName: "token_id", ProtobufType: "uint64", ProtobufPos: 7, }, &ColumnInfo{ Index: 7, Name: "sale_id", Comment: ``, Notes: `column is set for unsigned`, Nullable: true, DatabaseTypeName: "ubigint", DatabaseTypePretty: "ubigint", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "ubigint", ColumnLength: -1, GoFieldName: "SaleID", GoFieldType: "null.Int", JSONFieldName: "sale_id", ProtobufFieldName: "sale_id", ProtobufType: "uint64", ProtobufPos: 8, }, }, } // TableName sets the insert table name for this struct type func (l *LogRelation) TableName() string { return "log_relation" } // BeforeSave invoked before saving, return an error if field is not populated. func (l *LogRelation) BeforeSave(*gorm.DB) error { return nil } // Prepare invoked before saving, can be used to populate fields etc. func (l *LogRelation) Prepare() { } // Validate invoked before performing action, return an error if field is not populated. func (l *LogRelation) Validate(action Action) error { return nil } // TableInfo return table meta data func (l *LogRelation) TableInfo() *TableInfo { return log_relationTableInfo }