github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/vent/sqldb/system_tables.go (about)

     1  package sqldb
     2  
     3  import (
     4  	"github.com/hyperledger/burrow/txs"
     5  	"github.com/hyperledger/burrow/vent/types"
     6  )
     7  
     8  // getSysTablesDefinition returns log, chain info & dictionary structures
     9  func (db *SQLDB) systemTablesDefinition() types.EventTables {
    10  	return types.EventTables{
    11  		tables.Log: {
    12  			Name: tables.Log,
    13  			Columns: []*types.SQLTableColumn{
    14  				{
    15  					Name:    columns.Id,
    16  					Type:    types.SQLColumnTypeSerial,
    17  					Primary: true,
    18  				},
    19  				{
    20  					Name: columns.ChainID,
    21  					Type: types.SQLColumnTypeVarchar,
    22  				},
    23  				{
    24  					Name: columns.TimeStamp,
    25  					Type: types.SQLColumnTypeTimeStamp,
    26  				},
    27  				{
    28  					Name: columns.TableName,
    29  					Type: types.SQLColumnTypeVarchar,
    30  				},
    31  				{
    32  					Name: columns.EventName,
    33  					Type: types.SQLColumnTypeVarchar,
    34  				},
    35  				{
    36  					Name: columns.EventFilter,
    37  					Type: types.SQLColumnTypeText,
    38  				},
    39  				// We use varchar for height - there is no uint64 type though numeric could have been used. We obtain the
    40  				// maximum height by maxing over the serial ID type
    41  				{
    42  					Name: columns.Height,
    43  					Type: types.SQLColumnTypeVarchar,
    44  				},
    45  				{
    46  					Name:   columns.TxHash,
    47  					Type:   types.SQLColumnTypeVarchar,
    48  					Length: txs.HashLengthHex,
    49  				},
    50  				{
    51  					Name:   columns.Action,
    52  					Type:   types.SQLColumnTypeVarchar,
    53  					Length: 50,
    54  				},
    55  				{
    56  					Name: columns.DataRow,
    57  					Type: types.SQLColumnTypeJSON,
    58  				},
    59  				{
    60  					Name: columns.SqlStmt,
    61  					Type: types.SQLColumnTypeText,
    62  				},
    63  				{
    64  					Name: columns.SqlValues,
    65  					Type: types.SQLColumnTypeText,
    66  				},
    67  			},
    68  		},
    69  		tables.Dictionary: {
    70  			Name: tables.Dictionary,
    71  			Columns: []*types.SQLTableColumn{
    72  				{
    73  					Name:    columns.TableName,
    74  					Type:    types.SQLColumnTypeVarchar,
    75  					Primary: true,
    76  				},
    77  				{
    78  					Name:    columns.ColumnName,
    79  					Type:    types.SQLColumnTypeVarchar,
    80  					Primary: true,
    81  				},
    82  				{
    83  					Name: columns.ColumnType,
    84  					Type: types.SQLColumnTypeInt,
    85  				},
    86  				{
    87  					Name: columns.ColumnLength,
    88  					Type: types.SQLColumnTypeInt,
    89  				},
    90  				{
    91  					Name: columns.PrimaryKey,
    92  					Type: types.SQLColumnTypeInt,
    93  				},
    94  				{
    95  					Name: columns.ColumnOrder,
    96  					Type: types.SQLColumnTypeInt,
    97  				},
    98  			},
    99  		},
   100  		tables.ChainInfo: {
   101  			Name: tables.ChainInfo,
   102  			Columns: []*types.SQLTableColumn{
   103  				{
   104  					Name:    columns.ChainID,
   105  					Type:    types.SQLColumnTypeVarchar,
   106  					Primary: true,
   107  				},
   108  				{
   109  					Name: columns.BurrowVersion,
   110  					Type: types.SQLColumnTypeVarchar,
   111  				},
   112  				{
   113  					Name: columns.Height,
   114  					Type: types.SQLColumnTypeNumeric,
   115  					// Maps to numeric(20, 0) - a 20 digit integer value
   116  					Length: digits(maxUint64),
   117  				},
   118  			},
   119  			NotifyChannels: map[string][]string{types.BlockHeightLabel: {columns.Height}},
   120  		},
   121  	}
   122  }