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 `admin_log` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `admin_id` bigint(20) unsigned NOT NULL, `action_type` enum('user','artist','collection','curation','system','admin') COLLATE utf8mb4_bin NOT NULL, `sub_action_type` enum('created','modified','deleted') COLLATE utf8mb4_bin NOT NULL, `actioned_at` timestamp NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `deleted_at` timestamp NULL DEFAULT NULL, `message` varchar(256) COLLATE utf8mb4_bin NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`), KEY `fk_template_table_admin1_idx` (`admin_id`), CONSTRAINT `fk_template_table_admin1` FOREIGN KEY (`admin_id`) REFERENCES `admin` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin JSON Sample ------------------------------------- { "id": 4, "admin_id": 30, "action_type": "cBmoqqFyEiFMooFcyJlZTCDbP", "sub_action_type": "vZlCmKpZChXYCloLDfhJldygF", "actioned_at": "2303-04-02T20:29:25.82546921+09:00", "created_at": "2306-04-30T13:49:17.570249449+09:00", "updated_at": "2157-05-21T06:34:54.550292418+09:00", "deleted_at": "2063-01-31T00:11:20.025696792+09:00", "message": "yYfyCNgbaxEDTwFQddalnKtLb"} Comments ------------------------------------- [ 0] column is set for unsigned [ 1] column is set for unsigned */ // AdminLog struct is a row record of the admin_log table in the metarare database type AdminLog 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] admin_id ubigint null: false primary: false isArray: false auto: false col: ubigint len: -1 default: [] AdminID uint64 `gorm:"column:admin_id;type:ubigint;" json:"admin_id"` //[ 2] action_type char(10) null: false primary: false isArray: false auto: false col: char len: 10 default: [] ActionType string `gorm:"column:action_type;type:char;size:10;" json:"action_type"` //[ 3] sub_action_type char(8) null: false primary: false isArray: false auto: false col: char len: 8 default: [] SubActionType string `gorm:"column:sub_action_type;type:char;size:8;" json:"sub_action_type"` //[ 4] actioned_at timestamp null: false primary: false isArray: false auto: false col: timestamp len: -1 default: [] ActionedAt time.Time `gorm:"column:actioned_at;type:timestamp;" json:"actioned_at"` //[ 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"` //[ 8] message varchar(256) null: false primary: false isArray: false auto: false col: varchar len: 256 default: [] Message string `gorm:"column:message;type:varchar;size:256;" json:"message"` } var admin_logTableInfo = &TableInfo{ Name: "admin_log", 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: "admin_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: "AdminID", GoFieldType: "uint64", JSONFieldName: "admin_id", ProtobufFieldName: "admin_id", ProtobufType: "uint64", ProtobufPos: 2, }, &ColumnInfo{ Index: 2, Name: "action_type", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "char", DatabaseTypePretty: "char(10)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "char", ColumnLength: 10, GoFieldName: "ActionType", GoFieldType: "string", JSONFieldName: "action_type", ProtobufFieldName: "action_type", ProtobufType: "string", ProtobufPos: 3, }, &ColumnInfo{ Index: 3, Name: "sub_action_type", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "char", DatabaseTypePretty: "char(8)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "char", ColumnLength: 8, GoFieldName: "SubActionType", GoFieldType: "string", JSONFieldName: "sub_action_type", ProtobufFieldName: "sub_action_type", ProtobufType: "string", ProtobufPos: 4, }, &ColumnInfo{ Index: 4, Name: "actioned_at", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "timestamp", DatabaseTypePretty: "timestamp", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "timestamp", ColumnLength: -1, GoFieldName: "ActionedAt", GoFieldType: "time.Time", JSONFieldName: "actioned_at", ProtobufFieldName: "actioned_at", ProtobufType: "uint64", 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, }, &ColumnInfo{ Index: 8, Name: "message", Comment: ``, Notes: ``, Nullable: false, DatabaseTypeName: "varchar", DatabaseTypePretty: "varchar(256)", IsPrimaryKey: false, IsAutoIncrement: false, IsArray: false, ColumnType: "varchar", ColumnLength: 256, GoFieldName: "Message", GoFieldType: "string", JSONFieldName: "message", ProtobufFieldName: "message", ProtobufType: "string", ProtobufPos: 9, }, }, } // TableName sets the insert table name for this struct type func (a *AdminLog) TableName() string { return "admin_log" } // BeforeSave invoked before saving, return an error if field is not populated. func (a *AdminLog) BeforeSave(*gorm.DB) error { return nil } // Prepare invoked before saving, can be used to populate fields etc. func (a *AdminLog) Prepare() { } // Validate invoked before performing action, return an error if field is not populated. func (a *AdminLog) Validate(action Action) error { return nil } // TableInfo return table meta data func (a *AdminLog) TableInfo() *TableInfo { return admin_logTableInfo }