get list of tables from schema
This commit is contained in:
parent
c31b1f30ed
commit
2e70a798e2
@ -67,7 +67,7 @@ func dumpCSVFileData(t *testing.T) {
|
|||||||
|
|
||||||
localOutputDir := filepath.Join(workingDir, file.CSVTestConfig.OutputDir)
|
localOutputDir := filepath.Join(workingDir, file.CSVTestConfig.OutputDir)
|
||||||
|
|
||||||
for _, tbl := range schema.Tables {
|
for _, tbl := range schema.EthTables {
|
||||||
err := test_helpers.DedupFile(file.TableFilePath(localOutputDir, tbl.Name))
|
err := test_helpers.DedupFile(file.TableFilePath(localOutputDir, tbl.Name))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ func NewCSVWriter(path string, watchedAddressesFilePath string, diff bool) (*CSV
|
|||||||
return nil, fmt.Errorf("unable to create directory '%s': %w", path, err)
|
return nil, fmt.Errorf("unable to create directory '%s': %w", path, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
writers, err := makeFileWriters(path, schema.Tables)
|
writers, err := makeFileWriters(path, schema.EthTables)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
var Tables = []*Table{
|
var EthTables = []*Table{
|
||||||
&TableIPLDBlock,
|
&TableIPLDBlock,
|
||||||
&TableNodeInfo,
|
&TableNodeInfo,
|
||||||
&TableHeader,
|
&TableHeader,
|
||||||
@ -29,6 +29,11 @@ var Tables = []*Table{
|
|||||||
&TableWithdrawal,
|
&TableWithdrawal,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var AllTables = append(
|
||||||
|
EthTables,
|
||||||
|
&TableWatchedAddresses,
|
||||||
|
)
|
||||||
|
|
||||||
var TableIPLDBlock = Table{
|
var TableIPLDBlock = Table{
|
||||||
Name: `ipld.blocks`,
|
Name: `ipld.blocks`,
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/database/sql"
|
"github.com/cerc-io/plugeth-statediff/indexer/database/sql"
|
||||||
|
"github.com/cerc-io/plugeth-statediff/indexer/shared/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DedupFile removes duplicates from the given file
|
// DedupFile removes duplicates from the given file
|
||||||
@ -71,20 +72,8 @@ func ClearDB(db sql.Database) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
statements := []string{
|
for _, tbl := range schema.AllTables {
|
||||||
`TRUNCATE nodes`,
|
stm := fmt.Sprintf("TRUNCATE %s", tbl.Name)
|
||||||
`TRUNCATE ipld.blocks`,
|
|
||||||
`TRUNCATE eth.header_cids`,
|
|
||||||
`TRUNCATE eth.uncle_cids`,
|
|
||||||
`TRUNCATE eth.transaction_cids`,
|
|
||||||
`TRUNCATE eth.receipt_cids`,
|
|
||||||
`TRUNCATE eth.state_cids`,
|
|
||||||
`TRUNCATE eth.storage_cids`,
|
|
||||||
`TRUNCATE eth.log_cids`,
|
|
||||||
`TRUNCATE eth.withdrawal_cids`,
|
|
||||||
`TRUNCATE eth_meta.watched_addresses`,
|
|
||||||
}
|
|
||||||
for _, stm := range statements {
|
|
||||||
if _, err = tx.Exec(ctx, stm); err != nil {
|
if _, err = tx.Exec(ctx, stm); err != nil {
|
||||||
return fmt.Errorf("error executing `%s`: %w", stm, err)
|
return fmt.Errorf("error executing `%s`: %w", stm, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user