github.com/ztalab/ZACA@v0.0.1/database/mysql/cfssl-model/model/certificates.go (about)

     1  package model
     2  
     3  import (
     4  	"database/sql"
     5  	"time"
     6  
     7  	"github.com/guregu/null"
     8  	uuid "github.com/satori/go.uuid"
     9  )
    10  
    11  var (
    12  	_ = time.Second
    13  	_ = sql.LevelDefault
    14  	_ = null.Bool{}
    15  	_ = uuid.UUID{}
    16  )
    17  
    18  /*
    19  DB Table Details
    20  -------------------------------------
    21  
    22  
    23  CREATE TABLE `certificates` (
    24    `serial_number` varchar(128) NOT NULL,
    25    `authority_key_identifier` varchar(128) NOT NULL,
    26    `ca_label` varchar(128) DEFAULT NULL,
    27    `status` varchar(128) NOT NULL,
    28    `reason` int(11) DEFAULT NULL,
    29    `expiry` timestamp NULL DEFAULT NULL,
    30    `revoked_at` timestamp NULL DEFAULT NULL,
    31    `pem` text NOT NULL,
    32    `issued_at` timestamp NULL DEFAULT NULL,
    33    `not_before` timestamp NULL DEFAULT NULL,
    34    `metadata` json DEFAULT NULL,
    35    `sans` json DEFAULT NULL,
    36    `common_name` text,
    37    PRIMARY KEY (`serial_number`,`authority_key_identifier`)
    38  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
    39  
    40  JSON Sample
    41  -------------------------------------
    42  {    "common_name": "MScvMbPGahOUZxoOmsDxmNYFD",    "ca_label": "ULPoUZlfadBgOnGmGeTYpYlwr",    "pem": "fsrUtxDJCOpQbRZspCyJcqgNf",    "not_before": "2223-09-05T23:15:27.424784706+08:00",    "metadata": "swThVcEqvHBnUptLkmpCDXCQU",    "sans": "wVWFshOhaxDVLKoepAfWDCIyK",    "revoked_at": "2148-12-30T01:02:53.517625773+08:00",    "issued_at": "2022-06-24T10:47:05.902911131+08:00",    "serial_number": "IpDFkiGNIMlxfMZCDtIxJJdUt",    "authority_key_identifier": "VWhZXqDQGfeWADHfPHZUBcWJD",    "status": "jvpyBkTOqxxojTdhHuywdLWIH",    "reason": 32,    "expiry": "2299-08-23T23:34:03.786531333+08:00"}
    43  
    44  
    45  
    46  */
    47  
    48  // Certificates struct is a row record of the certificates table in the cap database
    49  type Certificates struct {
    50  	//[ 0] serial_number                                  varchar(128)         null: false  primary: true   isArray: false  auto: false  col: varchar         len: 128     default: []
    51  	SerialNumber string `gorm:"primary_key;column:serial_number;type:varchar;size:128;" json:"serial_number" db:"serial_number"`
    52  	//[ 1] authority_key_identifier                       varchar(128)         null: false  primary: true   isArray: false  auto: false  col: varchar         len: 128     default: []
    53  	AuthorityKeyIdentifier string `gorm:"primary_key;column:authority_key_identifier;type:varchar;size:128;" json:"authority_key_identifier" db:"authority_key_identifier"`
    54  	//[ 2] ca_label                                       varchar(128)         null: true   primary: false  isArray: false  auto: false  col: varchar         len: 128     default: []
    55  	CaLabel sql.NullString `gorm:"column:ca_label;type:varchar;size:128;" json:"ca_label" db:"ca_label"`
    56  	//[ 3] status                                         varchar(128)         null: false  primary: false  isArray: false  auto: false  col: varchar         len: 128     default: []
    57  	Status string `gorm:"column:status;type:varchar;size:128;" json:"status" db:"status"`
    58  	//[ 4] reason                                         int                  null: true   primary: false  isArray: false  auto: false  col: int             len: -1      default: []
    59  	Reason sql.NullInt64 `gorm:"column:reason;type:int;" json:"reason" db:"reason"`
    60  	//[ 5] expiry                                         timestamp            null: true   primary: false  isArray: false  auto: false  col: timestamp       len: -1      default: []
    61  	Expiry time.Time `gorm:"column:expiry;type:timestamp;" json:"expiry" db:"expiry"`
    62  	//[ 6] revoked_at                                     timestamp            null: true   primary: false  isArray: false  auto: false  col: timestamp       len: -1      default: []
    63  	RevokedAt time.Time `gorm:"column:revoked_at;type:timestamp;" json:"revoked_at" db:"revoked_at"`
    64  	//[ 7] pem                                            text(65535)          null: false  primary: false  isArray: false  auto: false  col: text            len: 65535   default: []
    65  	Pem string `gorm:"column:pem;type:text;size:65535;" json:"pem" db:"pem"`
    66  	//[ 8] issued_at                                      timestamp            null: true   primary: false  isArray: false  auto: false  col: timestamp       len: -1      default: []
    67  	IssuedAt time.Time `gorm:"column:issued_at;type:timestamp;" json:"issued_at" db:"issued_at"`
    68  	//[ 9] not_before                                     timestamp            null: true   primary: false  isArray: false  auto: false  col: timestamp       len: -1      default: []
    69  	NotBefore time.Time `gorm:"column:not_before;type:timestamp;" json:"not_before" db:"not_before"`
    70  	//[10] metadata                                       json                 null: true   primary: false  isArray: false  auto: false  col: json            len: -1      default: []
    71  	Metadata sql.NullString `gorm:"column:metadata;type:json;" json:"metadata" db:"metadata"`
    72  	//[11] sans                                           json                 null: true   primary: false  isArray: false  auto: false  col: json            len: -1      default: []
    73  	Sans sql.NullString `gorm:"column:sans;type:json;" json:"sans" db:"sans"`
    74  	//[12] common_name                                    text(65535)          null: true   primary: false  isArray: false  auto: false  col: text            len: 65535   default: []
    75  	CommonName sql.NullString `gorm:"column:common_name;type:text;size:65535;" json:"common_name" db:"common_name"`
    76  }
    77  
    78  var certificatesTableInfo = &TableInfo{
    79  	Name: "certificates",
    80  	Columns: []*ColumnInfo{
    81  
    82  		&ColumnInfo{
    83  			Index:              0,
    84  			Name:               "serial_number",
    85  			Comment:            ``,
    86  			Notes:              ``,
    87  			Nullable:           false,
    88  			DatabaseTypeName:   "varchar",
    89  			DatabaseTypePretty: "varchar(128)",
    90  			IsPrimaryKey:       true,
    91  			IsAutoIncrement:    false,
    92  			IsArray:            false,
    93  			ColumnType:         "varchar",
    94  			ColumnLength:       128,
    95  			GoFieldName:        "SerialNumber",
    96  			GoFieldType:        "string",
    97  			JSONFieldName:      "serial_number",
    98  			ProtobufFieldName:  "serial_number",
    99  			ProtobufType:       "string",
   100  			ProtobufPos:        1,
   101  		},
   102  
   103  		&ColumnInfo{
   104  			Index:              1,
   105  			Name:               "authority_key_identifier",
   106  			Comment:            ``,
   107  			Notes:              ``,
   108  			Nullable:           false,
   109  			DatabaseTypeName:   "varchar",
   110  			DatabaseTypePretty: "varchar(128)",
   111  			IsPrimaryKey:       true,
   112  			IsAutoIncrement:    false,
   113  			IsArray:            false,
   114  			ColumnType:         "varchar",
   115  			ColumnLength:       128,
   116  			GoFieldName:        "AuthorityKeyIdentifier",
   117  			GoFieldType:        "string",
   118  			JSONFieldName:      "authority_key_identifier",
   119  			ProtobufFieldName:  "authority_key_identifier",
   120  			ProtobufType:       "string",
   121  			ProtobufPos:        2,
   122  		},
   123  
   124  		&ColumnInfo{
   125  			Index:              2,
   126  			Name:               "ca_label",
   127  			Comment:            ``,
   128  			Notes:              ``,
   129  			Nullable:           true,
   130  			DatabaseTypeName:   "varchar",
   131  			DatabaseTypePretty: "varchar(128)",
   132  			IsPrimaryKey:       false,
   133  			IsAutoIncrement:    false,
   134  			IsArray:            false,
   135  			ColumnType:         "varchar",
   136  			ColumnLength:       128,
   137  			GoFieldName:        "CaLabel",
   138  			GoFieldType:        "sql.NullString",
   139  			JSONFieldName:      "ca_label",
   140  			ProtobufFieldName:  "ca_label",
   141  			ProtobufType:       "string",
   142  			ProtobufPos:        3,
   143  		},
   144  
   145  		&ColumnInfo{
   146  			Index:              3,
   147  			Name:               "status",
   148  			Comment:            ``,
   149  			Notes:              ``,
   150  			Nullable:           false,
   151  			DatabaseTypeName:   "varchar",
   152  			DatabaseTypePretty: "varchar(128)",
   153  			IsPrimaryKey:       false,
   154  			IsAutoIncrement:    false,
   155  			IsArray:            false,
   156  			ColumnType:         "varchar",
   157  			ColumnLength:       128,
   158  			GoFieldName:        "Status",
   159  			GoFieldType:        "string",
   160  			JSONFieldName:      "status",
   161  			ProtobufFieldName:  "status",
   162  			ProtobufType:       "string",
   163  			ProtobufPos:        4,
   164  		},
   165  
   166  		&ColumnInfo{
   167  			Index:              4,
   168  			Name:               "reason",
   169  			Comment:            ``,
   170  			Notes:              ``,
   171  			Nullable:           true,
   172  			DatabaseTypeName:   "int",
   173  			DatabaseTypePretty: "int",
   174  			IsPrimaryKey:       false,
   175  			IsAutoIncrement:    false,
   176  			IsArray:            false,
   177  			ColumnType:         "int",
   178  			ColumnLength:       -1,
   179  			GoFieldName:        "Reason",
   180  			GoFieldType:        "sql.NullInt64",
   181  			JSONFieldName:      "reason",
   182  			ProtobufFieldName:  "reason",
   183  			ProtobufType:       "int32",
   184  			ProtobufPos:        5,
   185  		},
   186  
   187  		&ColumnInfo{
   188  			Index:              5,
   189  			Name:               "expiry",
   190  			Comment:            ``,
   191  			Notes:              ``,
   192  			Nullable:           true,
   193  			DatabaseTypeName:   "timestamp",
   194  			DatabaseTypePretty: "timestamp",
   195  			IsPrimaryKey:       false,
   196  			IsAutoIncrement:    false,
   197  			IsArray:            false,
   198  			ColumnType:         "timestamp",
   199  			ColumnLength:       -1,
   200  			GoFieldName:        "Expiry",
   201  			GoFieldType:        "time.Time",
   202  			JSONFieldName:      "expiry",
   203  			ProtobufFieldName:  "expiry",
   204  			ProtobufType:       "uint64",
   205  			ProtobufPos:        6,
   206  		},
   207  
   208  		&ColumnInfo{
   209  			Index:              6,
   210  			Name:               "revoked_at",
   211  			Comment:            ``,
   212  			Notes:              ``,
   213  			Nullable:           true,
   214  			DatabaseTypeName:   "timestamp",
   215  			DatabaseTypePretty: "timestamp",
   216  			IsPrimaryKey:       false,
   217  			IsAutoIncrement:    false,
   218  			IsArray:            false,
   219  			ColumnType:         "timestamp",
   220  			ColumnLength:       -1,
   221  			GoFieldName:        "RevokedAt",
   222  			GoFieldType:        "time.Time",
   223  			JSONFieldName:      "revoked_at",
   224  			ProtobufFieldName:  "revoked_at",
   225  			ProtobufType:       "uint64",
   226  			ProtobufPos:        7,
   227  		},
   228  
   229  		&ColumnInfo{
   230  			Index:              7,
   231  			Name:               "pem",
   232  			Comment:            ``,
   233  			Notes:              ``,
   234  			Nullable:           false,
   235  			DatabaseTypeName:   "text",
   236  			DatabaseTypePretty: "text(65535)",
   237  			IsPrimaryKey:       false,
   238  			IsAutoIncrement:    false,
   239  			IsArray:            false,
   240  			ColumnType:         "text",
   241  			ColumnLength:       65535,
   242  			GoFieldName:        "Pem",
   243  			GoFieldType:        "string",
   244  			JSONFieldName:      "pem",
   245  			ProtobufFieldName:  "pem",
   246  			ProtobufType:       "string",
   247  			ProtobufPos:        8,
   248  		},
   249  
   250  		&ColumnInfo{
   251  			Index:              8,
   252  			Name:               "issued_at",
   253  			Comment:            ``,
   254  			Notes:              ``,
   255  			Nullable:           true,
   256  			DatabaseTypeName:   "timestamp",
   257  			DatabaseTypePretty: "timestamp",
   258  			IsPrimaryKey:       false,
   259  			IsAutoIncrement:    false,
   260  			IsArray:            false,
   261  			ColumnType:         "timestamp",
   262  			ColumnLength:       -1,
   263  			GoFieldName:        "IssuedAt",
   264  			GoFieldType:        "time.Time",
   265  			JSONFieldName:      "issued_at",
   266  			ProtobufFieldName:  "issued_at",
   267  			ProtobufType:       "uint64",
   268  			ProtobufPos:        9,
   269  		},
   270  
   271  		&ColumnInfo{
   272  			Index:              9,
   273  			Name:               "not_before",
   274  			Comment:            ``,
   275  			Notes:              ``,
   276  			Nullable:           true,
   277  			DatabaseTypeName:   "timestamp",
   278  			DatabaseTypePretty: "timestamp",
   279  			IsPrimaryKey:       false,
   280  			IsAutoIncrement:    false,
   281  			IsArray:            false,
   282  			ColumnType:         "timestamp",
   283  			ColumnLength:       -1,
   284  			GoFieldName:        "NotBefore",
   285  			GoFieldType:        "time.Time",
   286  			JSONFieldName:      "not_before",
   287  			ProtobufFieldName:  "not_before",
   288  			ProtobufType:       "uint64",
   289  			ProtobufPos:        10,
   290  		},
   291  
   292  		&ColumnInfo{
   293  			Index:              10,
   294  			Name:               "metadata",
   295  			Comment:            ``,
   296  			Notes:              ``,
   297  			Nullable:           true,
   298  			DatabaseTypeName:   "json",
   299  			DatabaseTypePretty: "json",
   300  			IsPrimaryKey:       false,
   301  			IsAutoIncrement:    false,
   302  			IsArray:            false,
   303  			ColumnType:         "json",
   304  			ColumnLength:       -1,
   305  			GoFieldName:        "Metadata",
   306  			GoFieldType:        "sql.NullString",
   307  			JSONFieldName:      "metadata",
   308  			ProtobufFieldName:  "metadata",
   309  			ProtobufType:       "string",
   310  			ProtobufPos:        11,
   311  		},
   312  
   313  		&ColumnInfo{
   314  			Index:              11,
   315  			Name:               "sans",
   316  			Comment:            ``,
   317  			Notes:              ``,
   318  			Nullable:           true,
   319  			DatabaseTypeName:   "json",
   320  			DatabaseTypePretty: "json",
   321  			IsPrimaryKey:       false,
   322  			IsAutoIncrement:    false,
   323  			IsArray:            false,
   324  			ColumnType:         "json",
   325  			ColumnLength:       -1,
   326  			GoFieldName:        "Sans",
   327  			GoFieldType:        "sql.NullString",
   328  			JSONFieldName:      "sans",
   329  			ProtobufFieldName:  "sans",
   330  			ProtobufType:       "string",
   331  			ProtobufPos:        12,
   332  		},
   333  
   334  		&ColumnInfo{
   335  			Index:              12,
   336  			Name:               "common_name",
   337  			Comment:            ``,
   338  			Notes:              ``,
   339  			Nullable:           true,
   340  			DatabaseTypeName:   "text",
   341  			DatabaseTypePretty: "text(65535)",
   342  			IsPrimaryKey:       false,
   343  			IsAutoIncrement:    false,
   344  			IsArray:            false,
   345  			ColumnType:         "text",
   346  			ColumnLength:       65535,
   347  			GoFieldName:        "CommonName",
   348  			GoFieldType:        "sql.NullString",
   349  			JSONFieldName:      "common_name",
   350  			ProtobufFieldName:  "common_name",
   351  			ProtobufType:       "string",
   352  			ProtobufPos:        13,
   353  		},
   354  	},
   355  }
   356  
   357  // TableName sets the insert table name for this struct type
   358  func (c *Certificates) TableName() string {
   359  	return "certificates"
   360  }