Skip to content

Commit

Permalink
Merge pull request #134 from getamis/write-new-db
Browse files Browse the repository at this point in the history
Write new db
  • Loading branch information
markya0616 authored Feb 20, 2019
2 parents 39908df + d2cd2b7 commit e66b6a4
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 13 deletions.

This file was deleted.

14 changes: 14 additions & 0 deletions migration/db/migrate/20190220031810_add_new_reorg_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class AddNewReorgTable < ActiveRecord::Migration[5.2]
def change
# Create new table for reorg events
create_table :reorgs2 do |t|
t.integer :from, :limit => 8, :null => false
t.binary :from_hash, :limit => 32, :null => false
t.integer :to, :limit => 8, :null => false
t.binary :to_hash, :limit => 32, :null => false
t.datetime :created_at, :null => false
end
add_index :reorgs2, [:from, :to]
add_index :reorgs2, [:from_hash, :to_hash], :unique => true
end
end
13 changes: 11 additions & 2 deletions migration/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_02_13_032740) do
ActiveRecord::Schema.define(version: 2019_02_20_031810) do

create_table "accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.binary "address", limit: 20, null: false
Expand Down Expand Up @@ -97,7 +97,16 @@
t.binary "to_hash", limit: 32, null: false
t.datetime "created_at", null: false
t.index ["from", "to"], name: "index_reorgs_on_from_and_to"
t.index ["from_hash", "to_hash"], name: "index_reorgs_on_from_hash_and_to_hash", unique: true
end

create_table "reorgs2", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.bigint "from", null: false
t.binary "from_hash", limit: 32, null: false
t.bigint "to", null: false
t.binary "to_hash", limit: 32, null: false
t.datetime "created_at", null: false
t.index ["from", "to"], name: "index_reorgs2_on_from_and_to"
t.index ["from_hash", "to_hash"], name: "index_reorgs2_on_from_hash_and_to_hash", unique: true
end

create_table "subscriptions", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
Expand Down
2 changes: 1 addition & 1 deletion store/new_erc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var _ = Describe("New ERC20 Test", func() {
_, err = db.Exec("DELETE FROM total_balances")
Expect(err).Should(Succeed())

_, err = db.Exec("DELETE FROM reorgs")
_, err = db.Exec("DELETE FROM reorgs2")
Expect(err).Should(Succeed())

for _, e := range erc20s {
Expand Down
4 changes: 2 additions & 2 deletions store/reorg/reorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ type Store interface {
}

const (
insertSQL = "INSERT INTO `reorgs` (`from`, `from_hash`, `to`, `to_hash`, `created_at`) VALUES (%d, X'%s', %d, X'%s', '%s')"
listSQL = "SELECT * FROM `reorgs`"
insertSQL = "INSERT INTO `reorgs2` (`from`, `from_hash`, `to`, `to_hash`, `created_at`) VALUES (%d, X'%s', %d, X'%s', '%s')"
listSQL = "SELECT * FROM `reorgs2`"
)

type store struct {
Expand Down
2 changes: 1 addition & 1 deletion store/reorg/reorg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var _ = Describe("Reorg Database Test", func() {
})

BeforeEach(func() {
_, err := db.Exec("DELETE FROM reorgs")
_, err := db.Exec("DELETE FROM reorgs2")
Expect(err).Should(Succeed())
})

Expand Down
2 changes: 1 addition & 1 deletion store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ var _ = Describe("Manager Test", func() {
_, err = db.Exec("DELETE FROM total_balances")
Expect(err).Should(Succeed())

_, err = db.Exec("DELETE FROM reorgs")
_, err = db.Exec("DELETE FROM reorgs2")
Expect(err).Should(Succeed())

_, err = db.Exec(fmt.Sprintf("DROP TABLE %s", model.Transfer{
Expand Down
2 changes: 1 addition & 1 deletion store/transfer_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var _ = Describe("Subscription Test", func() {
_, err = db.Exec("DELETE FROM total_balances")
Expect(err).Should(Succeed())

_, err = db.Exec("DELETE FROM reorgs")
_, err = db.Exec("DELETE FROM reorgs2")
Expect(err).Should(Succeed())

_, err = db.Exec(fmt.Sprintf("DROP TABLE %s", model.Transfer{
Expand Down

0 comments on commit e66b6a4

Please sign in to comment.